Some days ago, I tried to achieve a headlight effect for my volume rendering.
I send the fixed light position into the shader then calculate phong light in the shader.But the light
position seems to change when rotating the object. So I try to transform the normal to eye space or
transform the light position into model space. BUT all of them doesn’t work in my project!
I have some comments , please tell me what’s wrong in it.
Method 1. I use vec3 NN = normalize(gl_NormalMatrix * myNormalTexure.xyz); to transform normals.
These codes does work when rotating along x and y axis, but it goes wrong when rotating
Method 2. I use vec3 lightVec = vec3(-gl_NormalMatrix,-gl_NormalMatrix,-gl_NormalMatrix);to transform light position.But the light stay fixed relative to my scene. I don’t know why it doesn’t work.