Hello,
I’ve been trying to implement PPL (in eye space) using OpenGL and Cg, but I can’t get it work correctly. When I change my camera position (I use gluLookAt), lighting gets wrong - it looks like I would be moving/rotating the object, not the camera.
Download this to see what I mean. Use N/M, U/I and J/K to move the camera.

Originally posted by Wingman: How can I transform it?
Do it in your vertex program. You need the tangent space vectors at every vertex (tangent, binormal, normal) and the light position in world space. Calculate the light vector from the vertex position and the light position and transform this vector with three DP3 instructions and the tangent space vectors.
This is basic bump mapping, so you should find a lot of sample source code floating around the net (i.e. nVidia developer site ).

Ok, thanks.
So if I get this right, I should actually do some sort of bump mapping to get correct lighting? Well, I guess I should just read on (Cg Tutorial book), becasue I don’t know bump mapping yet. I hope it will help, thanks again.

To do per-pixel lighting, you need to bring the normal and the light vector into the fragment program. Both of these need to be transformed into the same space, whether it is tangent space, world space, model space, or whatever. More than likely, you aren’t transforming one of them into the same space as the other.

If you look at the vertex program, you can see that I do transform object space vertex position and normal into eye space. You’re saying I should transform normal and light vector only, that’s all? And how can I transform world space to eye space within a shader, then?
But like I said, I already tried to transform everything into the same space, but it didn’t work - lighting looked the same. So I assume problem’s somewhere else as well, but don’t have any idea where.

It just sounds like you need to make sure that you know which coordinate space you specify your different vectors in, and how the vector specification works (for example, the coordinates for glLight are transformed by the MODELVIEW at the time of specification (only)). Then just work out what lighting equation you actually want, and implement it appropriately. There’s no silver bullet; just keeping things straight.