Jump to content
  • Advertisement
Sign in to follow this  
INVERSED

Setting up GLSL attributes

This topic is 4876 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 everybody, I started messing around with some GLSL today, and I'm a bit stumped. I want to attempt to do some normal mapping, and for that I need to send normals and binormals per vertex. I figure the easiest way to do that is to just shove them into texture coords. My question is, however, how do you setup your own attribute? there is a render monkey example that has the binormal and tangent declared as
attribute vec3 Tangent;
attribute vec3 BiNormal;
or something similar. How do I set things up so that GLSL knows where to find my tangents and binormals. While I'm at it, does anyone know any good sources for calculating Tangents and BiNormals. I have seen the tutorial @ http://www.terathon.com/code/tangent.html, but the code is a tad hard to follow and it soen't explain the why. I think I can figure it out well enough, I was just curious as to whether anyone has any other links.

Share this post


Link to post
Share on other sites
Advertisement
hi,
you can use glMutiTexCoord or glVertexAttrib to pass them into your shader.

Before using glVertexAttrib, remember bind the user defined attribute and link the program again.

Share this post


Link to post
Share on other sites
So, let me see if I understand this. Do I pass in my attributes with VertexAttrib4f( index, values ), where index is the location of my attribute gotten with GetAttribLocation( my_program, "MyAttribName" )? If anyone knows of an example of how to do this that would help too. Looking at source is always easier. Except when it isn't.

Share this post


Link to post
Share on other sites
ppl often pass them in with texture coordinates

eg
tangent = gl_MultiTexCoord4.xyz;
bitangent = gl_MultiTexCoord5.xyz;
normal = gl_MultiTexCoord6.xyz;

Share this post


Link to post
Share on other sites
I can't get attribute location by using glGetAttribLocationARB. Because glGetAttribLocationARB is always return 0. I just pass the index which what I bind to glGetAttribLocationARB.

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!