Jump to content
  • Advertisement


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


Vertex Color Shading Shananigans

This topic is 5304 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

Hey, I''ve come across a problem that I''ve no idea how to solve, let alone, where to start. What happens is that I draw a quad as usual, and I assign either the color value 1, 1, 1 or 0, 0, 0 to each vertex. This, obviously, gives the polygon an effect of a nice black to white shade. However, if three verteces are white and one is black or vice-versa, what happens is that the shading of the polygon looks correct until one of the verteces is off the visible screen. Then the shading become horribly off, like the vertex color is clipped/ignored WITH THE VERTEX! Here is the code I''ve used: disp_test_object(float x, float y, float z, float gam, int texture_index){ float high_light = 1, low_light = 0; float base_size = 1; float half_size = base_size / 2; float verteces[] = {0 - half_size, 0 - half_size, 0, 0 + half_size, 0 - half_size, 0, 0 + half_size, 0 + half_size, 0, 0 - half_size, 0 + half_size, 0}; glPushMatrix(); glTranslatef(x, y, z); glRotatef(gam, 0, 1, 0); glDisable(GL_TEXTURE_2D); //glBindTexture(GL_TEXTURE_2D, texture_index); glBegin(GL_QUADS); glTexCoord2f(0, 0); glColor4f(high_light, high_light, high_light, 1); glVertex3f(verteces[0], verteces[1], verteces[2]); //Down Left glTexCoord2f(1, 0); glColor4f(high_light, high_light, high_light, 1); glVertex3f(verteces[3], verteces[4], verteces[5]); //Down Right glTexCoord2f(1, 1); glColor4f(low_light, low_light, low_light, 1); glVertex3f(verteces[6], verteces[7], verteces[8]); //Up Right glTexCoord2f(0, 1); glColor4f(high_light, high_light, high_light, 1); glVertex3f(verteces[9], verteces[10], verteces[11]); //Up Left glEnd(); glPopMatrix(); glEnable(GL_TEXTURE_2D); }//END DISPLAY TEST OBJECT FUNCTION If anyone knows why this happens, or better yet, how to solve it, I would greatly appreciate an answer. If there''s any more information that could be relavent to this problem, please, feel free to ask me for it. I can also take snapshots of this and post it upon request. Thanks alot. Email: slyguy_555@hotmail.com

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!