Jump to content
  • Advertisement
Sign in to follow this  
Geometrian

OpenGL Vertex Attributes changing Lighting

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

Hi, I have an object which is rendered using vertex arrays. It is rendered:
location = glGetAttribLocation(shader.program,"vert_tangent")
#location seems to always be 1

glEnableClientState(GL_VERTEX_ARRAY)
glEnableClientState(GL_NORMAL_ARRAY)
glEnableClientState(GL_TEXTURE_COORD_ARRAY)
glEnableVertexAttribArray(location)

glVertexPointer(3,GL_FLOAT,0,self.vertices)
glNormalPointer(GL_FLOAT,0,self.normals)
glTexCoordPointer(2,GL_FLOAT,0,self.texturecoords)
glVertexAttribPointer(location,4,GL_FLOAT,GL_FALSE,0,self.tbnvectors)
glDrawArrays(GL_TRIANGLES,0,len(self.vertices))

glDisableVertexAttribArray(location)
glDisableClientState(GL_TEXTURE_COORD_ARRAY)
glDisableClientState(GL_NORMAL_ARRAY)
glDisableClientState(GL_VERTEX_ARRAY)

Later in the program, I draw a single quad:
glBegin(GL_QUADS)
glNormal3f(0,1,0)
size = 10
glTexCoord2f(0,1); glVertex3f(-size,-1, size)
glTexCoord2f(1,1); glVertex3f( size,-1, size)
glTexCoord2f(1,0); glVertex3f( size,-1,-size)
glTexCoord2f(0,0); glVertex3f(-size,-1,-size)
glEnd()
The lighting on this quad, however, is wrong. Removing the vertex attribute array completely in the first listing fixes the problem, but now I can't do normal mapping. I really need to know why the vertex attribute array seems to be changing something about the lighting later. But according to http://www.opengl.org/sdk/docs/tutorials/ClockworkCoders/attributes.php (see second listing at bottom), the location 1, which is what glGetAttribLocation() invariably returns, seems to be open to use. Ideas? Thanks, -Geometrian

Share this post


Link to post
Share on other sites
Advertisement
Why not save yourself a headache and upload the data as a generic vertex attribute with your own named attribute to keep it clear and simple...

Share this post


Link to post
Share on other sites
Quote:
Try to put the self.tbnvectors in one of the texcoord such as TEXCOORD1 and see what happens.
That should work, but all of my texcoords are currently being used, and the eventual solution should use vertex attributes anyway.
Quote:
Why not save yourself a headache and upload the data as a generic vertex attribute with your own named attribute to keep it clear and simple...
Like using gl_Color or something and binding it to your own name with glBindAttribLocation()? Not sure what you mean...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!