Archived

This topic is now archived and is closed to further replies.

SirKnight

lighting problem

Recommended Posts

Im trying to get simple lighting to work in my Vertex Shader in OpenGL. Well im trying to follow the opengl and direct3d examples and its just not working correctly. For one thing, my light is always white, no mattere what color i specify. Second, the spinning quad im drawing is always lit whereas in the examples when the quad is not facing directly at the viewer the light intensity is darker and when the back of the quad is facing the viewer its all black. Yet mine is not like that. Here is my vertex program. I really hope someone can help me. Im doing the same things as in the examples. And what im doing seems to make sence. // Let c[0] to c[3] = GL_MODELVIEW_PROJECTION_NV, GL_IDENTITY_NV // Let c[5] = the light vector which is {0.0,0.0,-1.0,0.0} // Let c[10] to c[13] = GL_MODELVIEW, GL_INVERSE_NV // Let c[20] = diffuse color (white){1.0,1.0,1.0} // All v[X] registers contain what they are supposed to "!!VP1.0 # This is a sample vertex program!.\n" "DP4 o[HPOS].x, c[0], v[OPOS];" "DP4 o[HPOS].y, c[1], v[OPOS];" "DP4 o[HPOS].z, c[2], v[OPOS];" "DP4 o[HPOS].w, c[3], v[OPOS];" // Compute the object space light vector "MOV R3, c[5];" "DP3 R1.x, c[10], R3;" "DP3 R1.y, c[11], R3;" "DP3 R1.z, c[12], R3;" // Normalize vector "DP3 R1.w, R1, R1;" "RSQ R1.w, R1.w;" "MUL R1, R1, R1.w;" // Make vector point the other way and find the intensity "DP3 R0.x, v[NRML], -R1;" "MUL o[COL0], R0.x, c[20];" "MOV o[TEX0], v[TEX0];" // Copy texture coords over "END"; -SirKnight

Share this post


Link to post
Share on other sites