[SOLVED] Shader question, strange behavior of normal

Simplified and non valid shader code below just to describe what I have.



VertexShader

varying Normal = inNormal * g_NormalMatrix;



FragmentShader

gl_FragColor = vec4(Normal*0.5 + 0.5, 0.0);





I have a spinning sphere in my scene and my camera is still. As I understand it g_NormalMatrix will translate my model space normals (inNormal) to view space. Since my camera is still I expect the colors (normals) of the sphere not to rotate, but they do. Is my logic wrong?

Found my error.



I should swap inNormal and g_NormalMatrix around… silly misstake. Isn’t it ironic, one can spend hours looking for errors and once you ask you find the answer yourself in like 3 minutes…

@kwando said:
Found my error.

I should swap inNormal and g_NormalMatrix around... silly misstake. Isn't it ironic, one can spend hours looking for errors and once you ask you find the answer yourself in like 3 minutes..


Yeah.

Maybe we need a special forum group for that. :)

I can sometimes find my bugs by explaining them to my wife. She looks at me like I'm speaking a completely different language and just nods her head slowly... but sometimes in the explaining, I figure out my problem.
Isn’t it ironic, one can spend hours looking for errors and once you ask you find the answer yourself in like 3 minutes..


I cannot count how often this happened before and shortly after posting in java-forum.org^^ ;)

I can sometimes find my bugs by explaining them to my wife. She looks at me like I’m speaking a completely different language and just nods her head slowly… but sometimes in the explaining, I figure out my problem.


I encountered exactly the same with my girlfriend lately^^ :D

Ok… You guys are finding bugs in your wifes? O_o Damn I love being single! :wink:

1 Like