You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This might have been related to toksvig normal mapping technique, I remember it was implemented to fight normals aliasing, but then there were some changes for it. Which might have affected our AA with normals.
More information here:
I tried reverting the envAtlas back to the prefilteredCubemaps approach, but the result was similar — a significant amount of specular aliasing.
Activity
MAG-AdrianMeredith commentedon Feb 3, 2026
I've noticed this also, I wonder if its sampling too high quality
[-]Specular antialias after using envAtlas[/-][+]Specular aliasing after using envAtlas[/+]Maksims commentedon Feb 3, 2026
This might have been related to toksvig normal mapping technique, I remember it was implemented to fight normals aliasing, but then there were some changes for it. Which might have affected our AA with normals.
scarletsky commentedon Feb 3, 2026
@Maksims
Do you mean #4260 Toksvig specular doesn't work ?
But my project does not use normal maps. It is geometric normal.
mvaligursky commentedon Feb 3, 2026
It's definitely worth reviewing, it seems significantly worse.
TAA is not a bad solution for these cases (when suitable): https://playcanvas.vercel.app/#/graphics/taa
Maksims commentedon Feb 3, 2026
Oh, I've assumed it was normal map based, I can see in a project that it is geometry indeed.
scarletsky commentedon Feb 4, 2026
Hi, guys. I did some research on v1.51.7.
Based on Algorithms for the Detection and Elimination of Specular Aliasing, ChatGPT told me to change
reflectionEnvPS:vec2 dy2 = dFdy(uv2); // calculate min of both sets of dF to handle discontinuity at the azim edge - float maxd = min(max(dot(dx, dx), dot(dy, dy)), max(dot(dx2, dx2), dot(dy2, dy2))); + float maxd = max(max(dot(dx, dx), dot(dy, dy)), max(dot(dx2, dx2), dot(dy2, dy2))); return clamp(0.5 * log2(maxd) - 1.0, 0.0, 6.0); } @@ -24,34 +25,38 @@ vec3 calcReflection(vec3 tReflDirW, float tGlossiness) { vec3 dir = cubeMapProject(tReflDirW) * vec3(-1.0, 1.0, 1.0); vec2 uv = toSphericalUv(dir); - // calculate roughness level - float level = saturate(1.0 - tGlossiness) * 5.0; - float ilevel = floor(level); + float levelBrdf = saturate(1.0 - tGlossiness) * 5.0; + float levelMin = shinyMipLevel(uv * atlasSize); + float levelFinal = max(levelBrdf, levelMin); - // accessing the shiny (top level) reflection - perform manual mipmap lookup - float level2 = shinyMipLevel(uv * atlasSize); - float ilevel2 = floor(level2); + float ilevel = floor(levelFinal); vec2 uv0, uv1; float weight; - if (ilevel == 0.0) { + + if (levelFinal < 1.0) { + float ilevel2 = floor(levelFinal); uv0 = mapMip(uv, ilevel2); uv1 = mapMip(uv, ilevel2 + 1.0); - weight = level2 - ilevel2; + weight = levelFinal - ilevel2; + + vec3 linearA = $DECODE(texture2D(texture_envAtlas, uv0)); + vec3 linearB = $DECODE(texture2D(texture_envAtlas, uv1)); + return processEnvironment(mix(linearA, linearB, weight)); } else { - // accessing rough reflection - just sample the same part twice - uv0 = uv1 = mapRoughnessUv(uv, ilevel); - weight = 0.0; + vec2 uva = mapRoughnessUv(uv, ilevel); + vec2 uvb = mapRoughnessUv(uv, ilevel + 1.0); + weight = levelFinal - ilevel; + + vec3 linearA = $DECODE(texture2D(texture_envAtlas, uva)); + vec3 linearB = $DECODE(texture2D(texture_envAtlas, uvb)); + return processEnvironment(mix(linearA, linearB, weight)); } - - vec3 linearA = $DECODE(texture2D(texture_envAtlas, uv0)); - vec3 linearB = $DECODE(texture2D(texture_envAtlas, uv1)); - vec3 linear0 = mix(linearA, linearB, weight); - vec3 linear1 = $DECODE(texture2D(texture_envAtlas, mapRoughnessUv(uv, ilevel + 1.0))); - - return processEnvironment(mix(linear0, linear1, level - ilevel)); }For convenience, I updated my code with this (I am not familar with the new shader chunks system, so I use the old system):
The results are great, but there are still a few artifacts:
20260204172919_rec_-convert.mp4
20260204173606_rec_-convert.mp4
willeastcott commentedon Jun 23, 2026
@scarletsky Can you please take a look at this PR: #8955
Is this a step in the right direction?
scarletsky commentedon Jun 24, 2026
The results are somewhat better than before, but this approach still falls short of the previous
prefilteredCubemapssolution.Test on https://playcanvas.com/editor/scene/2418205 with the following code:
20260624095416_rec_.mp4
scarletsky commentedon Jun 24, 2026
More information here:
I tried reverting the
envAtlasback to theprefilteredCubemapsapproach, but the result was similar — a significant amount of specular aliasing.Until I commented out the line below. After doing so, the effect reverted back to the previous state with no specular aliasing.
https://github.com/playcanvas/engine/blob/main/src/framework/handlers/cubemap.js#L129
In the old implementation,
mipmapswere generated forprefilteredCubemapsat all mip levels.