Today I've investigated a set of test failures in guc's test suite. In this specific example, we have a normal-mapped plane where the MaterialX renderer exhibits artifacts that do not exist in the glTF and UsdPreviewSurface reference images:
| MaterialX |
UsdPreviewSurface |
glTF Reference |
 |
 |
 |
(Consider the circular artifact on the circle in the top left corner.)
Initially this reminded me a bit of the bump terminator problem so I visualized the angle between shading normal and geometric normal (green = angle is zero or negative):
| main |
debug |
 |
 |
And after some more debugging I stumbled upon this line in the oren_nayar implementation, which flips the shading normal depending on the view direction:
What seems to happen is that the normal-mapped shading normal gets flipped because the view direction lies outside its hemisphere. With the line commented out, the result looks correct:
Could it be that we actually want to flip the shading normal depending on dot(N_geom, V)? But then the problem is that we already calculated the effect of the normal map. We would need to do it before calculating the new normal with in, scale, and the TBN-frame.. but then again there needs to be a guarantee that the flip happens before BRDF evaluation.
I have not investigated further, but wanted to log this issue so that it can be discussed, as there are people in the community who are much more familiar with the GLSL BRDF implementations.
Example material in question (needs the MaterialX plane mesh): Material_07.zip
Today I've investigated a set of test failures in guc's test suite. In this specific example, we have a normal-mapped plane where the MaterialX renderer exhibits artifacts that do not exist in the glTF and UsdPreviewSurface reference images:
(Consider the circular artifact on the circle in the top left corner.)
Initially this reminded me a bit of the bump terminator problem so I visualized the angle between shading normal and geometric normal (green = angle is zero or negative):
And after some more debugging I stumbled upon this line in the oren_nayar implementation, which flips the shading normal depending on the view direction:
What seems to happen is that the normal-mapped shading normal gets flipped because the view direction lies outside its hemisphere. With the line commented out, the result looks correct:
Could it be that we actually want to flip the shading normal depending on
dot(N_geom, V)? But then the problem is that we already calculated the effect of the normal map. We would need to do it before calculating the new normal with in, scale, and the TBN-frame.. but then again there needs to be a guarantee that the flip happens before BRDF evaluation.I have not investigated further, but wanted to log this issue so that it can be discussed, as there are people in the community who are much more familiar with the GLSL BRDF implementations.
Example material in question (needs the MaterialX plane mesh): Material_07.zip