PDA

View Full Version : headlight problem of volume rendering



med3d
03-02-2006, 05:03 PM
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
along z-axis.
Method 2. I use vec3 lightVec = vec3(-gl_NormalMatrix[0][2],-gl_NormalMatrix[1][2],-gl_NormalMatrix[2][2]);to transform light position.But the light stay fixed relative to my scene. I don't know why it doesn't work.