Your vertex shader has on issue - your eye and light vectors aren’t in view space, but in world space (if you aren’t transforming them on CPU) - you need to transform them to view space - by multiplying them with viewMat.

Also we don’t transform normals by model view matrix, but so called normal matrix (inverse-transpose of first three rows and columns of model view matrix).

hello. I’ve just started with shader programming but I’m having problems getting a basic phong shader to work, I’m using RenderMonkey and the shader in question is one of the examples that comes with RenderMonkey (Textured Phong).

here is the vertex shader:

the first thing I dont understand is:

float3 fvObjectPosition = mul( Input.Position, matView ).

If the matView is the view matrix then this means it is transforming the vertex into view space wheras the light and eye vectors are both in world space, I’ve tried converting these vectors also into view space and also leaving the vertex in world space, but both of these don’t work.

here’s the pixel shader:

I convert this into the asm code and then place this in my application, I then set one vertex shader constant every time the world matrix changes, i.e.

and for every frame I set these constants:

but the lighting seems way off.

thanks in advance.