• Advertisement
Sign in to follow this  

Vertex Attributes in GLSL

This topic is 3364 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 learned from http://www.gamedev.net/community/forums/topic.asp?topic_id=448107 that an attribute must be used, otherwise glGetAttribLocation() will return -1. I'm trying to make a normal mapping shader, so I'm passing in a vector as an attribute ("vert_tangent"), and trying to send it to the fragment shader (via "blah", for proof of concept). However, as mentioned in the first paragraph, glGetAttribLocation() returns -1 when I try to do this:
//VERTEX SHADER
varying vec3 blah;
attribute vec3 vert_tangent;
void main()
{
    //This line lets glGetAttribLocation() return 1.
    gl_Vertex.xyz *= vert_tangent;

    //This line makes glGetAttribLocation() return -1.  WHY???
    blah.xyz = vert_tangent;
Thanks, -G

Share this post


Link to post
Share on other sites
Advertisement
Do you have a fragment shader that is actually consuming the varying 'blah' ? If not, it will be optimized away. That fragment shader must be linked together with your vertex shader, and it must make use of the varying.

Share this post


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

  • Advertisement