When I have a world of polygons and some moving lights it works perfectly. But If I try to use rotatef or translatef or multMatrix then the lighting is not correct. Maybe need convert the ocject space matrix to word space matrix? How I will do that? Using A vertex Program maybe? And What I will write in the vertex program?

What space are your normal maps in? If they are tangent space normal maps (most likely) then you need a vertex program to transform your light vectors and such into tangent space before you do the lighting.

I thing I have the same problem. If I use glRotatef, then glTranslate and then I render any geometry, it works properly. This is part of my vertex shader:

# get the light vector
DP4 lightpos.x, mvi[0], state.light[0].position;
DP4 lightpos.y, mvi[1], state.light[0].position;
DP4 lightpos.z, mvi[2], state.light[0].position;
DP4 lightpos.w, mvi[3], state.light[0].position;
SUB lightvec, lightpos, vertex.position;
# transform light vector into tangent space
DP3 result.texcoord[1].x, lightvec, tangent;
DP3 result.texcoord[1].y, lightvec, binormal;
DP3 result.texcoord[1].z, lightvec, normal;
MOV result.texcoord[1].w, 1.0;

But if I use another glRotatef and another glTranslatef, it is not correct. How can I do this to work?

I think the problem might be that the light position provided by the state variables is in eye space. You will need to pass in the world space light position as a uniform variable and transform it to tangent space, or maybe transform the light position into object space outside the vertex program and then transform it to tangent space per vertex. For bump mapping to work you need the light direction in tangent space dotted with the normal. Haven’t got time for a detailed explanation now, but I’m sure someone will be able to provide more details sooner than I can.

Originally posted by SirKnight:
[b]What space are your normal maps in? If they are tangent space normal maps (most likely) then you need a vertex program to transform your light vectors and such into tangent space before you do the lighting.

-SirKnight[/b]
Any Idea how I can do that? … not an expert in vertex_programs

unreal:
You don’t need to know how vertex shaders work. I thing that you are calculating light vectors and sending it to card via texture coordinates of cube map. This calculation can be done on cpu (how you do that now) or in vertex shader on gpu. It isn’t so important to do it in vertex shader, but it’s better to save a little performance on cpu.

Now how to calculate light vectors… If you have rotation matrix of object as M1, rotation matrix of camera as M2, both transposed, you can calculate light position in object space this way:
LightPosInObjectSpace = (M1 * M2) * (LightPos-ObjPos)
And now you can calculate light vectors and transform them to tangent space. This works only if you use glRotatef and then glTranslatef for you camera.