I recently got the hang of RenderMonkey (if you don't know about it, it's a great shader IDE by ATI, free). I wrote the basic directional lighting shader in it, the one below:
Code: Select all
uniform mat4 matWorldInverse;
uniform mat4 matWorldTranspose;
uniform vec3 mLightPos;
uniform vec4 mLightDiffuse;
uniform vec4 mLightAmbient;
uniform float mLightRadius;
void main(void)
{
gl_Position = ftransform();
vec4 normal = vec4(gl_Normal, 0.0);
normal = matWorldInverse * normal;
normal = normalize(normal);
vec4 worldpos = gl_Vertex * matWorldTranspose;
vec4 lightVector = worldpos - vec4(mLightPos,1.0);
lightVector = normalize(lightVector);
float tmp2 = dot(-lightVector, normal);
vec4 tmp = mLightAmbient + mLightDiffuse * tmp2;
gl_FrontColor = gl_BackColor = vec4(tmp.x, tmp.y, tmp.z, 0.0);
}
void main(void)
{
vec4 col = gl_Color;
gl_FragColor = col*2.0;
}
I also used the same model and shader in Irrlicht and I got per vertex with vertex colors interpolated on each face.