// Vertex Shader
// March 25th 2004
// Copyright © [1999-2004] [Hugo Ferreira] [Positronic Dreams]
struct sOut
{
float4 pos : POSITION;
float4 col : COLOR;
float2 tuv : TEXCOORD0;
};
sOut main( float4 pos : POSITION,
float2 tuv : TEXCOORD0,
float3 normal : NORMAL,
uniform float4 Kd,
uniform float4 lp1, // Light Position
uniform float4x4 ModelViewProj,
uniform float4x4 ModelView,
uniform float4x4 ModelViewIT )
{
sOut OUT;
OUT.pos = mul(ModelViewProj, pos);
float3 P = pos.xyz;
float3 N = normal;
float4 D = lp1;
D[3]=1;
OUT.pos = mul(ModelView, D);
float3 L = normalize( lp1 - P );
D[0] = max(dot(N, L), 0);
OUT.tuv = tuv;
OUT.col.x = D[0];
OUT.pos = mul(ModelViewProj, pos);
return OUT;
}
Here is the pseudo-code of what Im doing:
glPushMatrix();
glTranslatef ( tx, ty, tz);
glRotatef ( rx, 1, 0, 0);
glRotatef ( ry, 0, 1, 0);
glRotatef ( rz, 0, 0, 1);
cgGLSetStateMatrixParameter(modelViewMatrix, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY);
cgGLSetStateMatrixParameter(ModelView, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_IDENTITY);
cgGLSetStateMatrixParameter(ModelViewIT, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_INVERSE_TRANSPOSE);
Draw_Model;
glPopMatrix();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ok, so I rotate/translate the model, then I set the matrices for the Cg code, then I call the Draw_Model function to render my model.
The effect i''m geting is that everything is rendered correctly, but when i rotate the model, the rotation isnt taken into effect....
I''m I passing the light coordinates wrong?... They''re passed in world-space...
Help Please!
[Hugo Ferreira][Positronic Dreams][Colibri 3D Engine][Entropy HL2 MOD][My DevDiary][Yann L.][Enginuity] [Penny Arcade] [MSDN][VS RoadMap][Humus][BSPs][UGP][NeHe]
Prozak - The GameDever formally known as pentium3id