Jump to content
  • Advertisement


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


lighting problem

This topic is 6312 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!