I spent a good portion of today debugging a shader in Max 2012 (updated to SP2) due to issues with the Lambert lighting on it looking wrong, even when a blank (i.e. 0.5,0.5,1.0) normal map was applied. I tried walking it back to Max 2011, and it appeared correct! I went in and broke it down and did some debug renders of just the tangent, binormal, and normal vectors (range compressed back to 0~1.)
It looks like the TBN generation for Max 2012 is completely different, but for reasons I don’t understand. I’m using the same shader in both cases (the built-in RTTNormalMap.fx shader in /maps/fx/,) the same spherical UV mapping, viewed from the same angle, both cases using the DirectX9 shader (not Nitrous.) Why would these vectors be so dramatically different between Max versions? Has anyone else run into this?
Also, the TBN interpolation across faces in 2012 seems wack too - I get weird shifts within a face - but not along edges, as you might expect. These shifts meander in and around a face, even when they are manually triangulated. When I unweld all the points, things come out fine, but if the faces are connected and part of a smoothing group, all hell breaks loose. What gives?
Max 2012 has gamma correction turned on by default and it applies this gamma correction to all textures - including normal maps. :(: Disable gamma correction under Customize->preferences->Gamma and LUT. Then reload the max file. I’m pretty sure that will fix it for you.
Awesome, that does fix it. Thanks Ben! However, it only raises more questions for me - while the final diffuse output renders correctly, rendering the individual vectors still shows up different from 2011. In fact, turning off and on the gamma correct setting changes the color rendering entirely!
I was expecting maybe some shifts in value or saturation, but instead I have some huge changes in hue altogether. Why is that? In this case there is no texture sampling happening - I’m straight rendering the vector from the vertex shader, so it should only receive the final bit of gamma correction when it renders to screen (rather than allowing the gamma correctness to alter the math as would be the case when using a normal map.)
Also you can really see the weirdness of the interpolation across the face in the Z-component-only bit in the above image. I would expect changes to occur along edges at vertices, not within a face, when it comes to vertex data like this. Why is it zigzagging through the face?