Hey, i was trying to make animated textures lately, and make them blend smoothly between frames. But i came across the problem: i’m not really sure how mix two normal maps. Using simple mix function with 2 textures and blend factor works for diffuse, but it makes specular act incorrectly. the closer blend factor to 0.5, the lower specular intensity. So it creates pulsating effect during animation. But i can’t compensate it or find the reason. It also makes reflection coord to offset with simmilar amplitute.
i calculate specular like that:
pow(clamp(dot(eyeDir, reflect(-lightDir, normalMap)), 0.0, 1.0), Shininess) * Specular_Intensity;
tried to multiplicate specular with 1.0 - abs(BlendFactor - 0.5), with different values\variations\scale - it didn’t help.
I’m asking here because i’m not shure if that’s a correct way. And maybe someone dealt with simillar problems or any ideas how to avoid that.
i’ve just realized how stupid my question was. sorry. obviously, i need to blend results of lambert\specular calculation for both textures, not normal map samples(or find a way how to correctly blend them). that will reduce performance too much(yeah, i will use that shader on quite few objects…so maybe i should give it a try).
Thank’s for the reply and the link, tksuoran. But i can’t test it, for some reason, normalziing normal map makes specular intensity extremely low(something about 0.00000001) and too sensitive to angles.
And that actually made things look a bit worse in comparsion with simply blending two normal maps, and didn’t solve primary problem. Am i doing it wrong?
No, what kind of processing do you mean? I thought, i can start with emulating compressing\decompressing process inside fragment shader to see if it helps.