Results 1 to 2 of 2

Thread: GLSL vertex attributes - need some help please.

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2010
    Posts
    14

    GLSL vertex attributes - need some help please.

    Hi, I am very new to GLSL and have been experimenting with various shaders, testing code etc for the last week or so.

    I have been attempting to implement normal mapping that has driven me a bit loopy for the last coupel of days.
    I have been looking through dozens of online tutorials etc, for shaders just for standard per-pixel lighting and ofcourse now Normal mapping - I have perhaps jumped in one step to many... tutorials that just talk about shader code in the shader, not what has to be arranged for the shader for it to work(atleast in this case).

    I read tutorials that specify
    Code :
    attribute normal;
    attribute binormal;

    This is what I want to have confirmed...
    It was my assumption(stupid?) that these are calculated for me to use (in this case to create a TBN matrix), I thought I was just telling the shader I wanted to have them made available.

    I have been setting some uniforms in my shaders(getting location, then passing data etc)... Am i right in thinking that if I want to do a normal map shader I will have to compute the tangents myself, then pass them to the shaders attibute location?
    With binormals I could do this the same way, or in the vert shader I could do with a cross(norm, tang) - is this better since GPU excels at vector math?

    It did always bother me(well for a couple of days) why the normal had a predefined name, gl_Normal, and the others had no similar prefix, but I was letting tutorials lead me by the hand before so I did with this - not making that contection that it could be similar to when I specificy my uniforms.


    I ask this here because I just stumbled across a few references and it made me think, I am about to go to bed - and I am hoping someone can say yay or nay so when I get up in the morning and look over this(normal map) some more I may gain back some of my sanity

  2. #2
    Member Contributor
    Join Date
    Aug 2009
    Posts
    78

    Re: GLSL vertex attributes - need some help please.

    You have to provide attributes yourself.

    As you already noticed learning GLSL from browsing shader source code tutorials wont work out. You have to learn the basics first otherwise you will suffer for a long time

    I suggest reading the Orange book or similar. (You wont have to read it completely to understand the basics...

Similar Threads

  1. GLSL geometry shaders and attributes
    By underthesun in forum OpenGL: GLSL
    Replies: 1
    Last Post: 06-30-2011, 08:36 AM
  2. GLSL Attributes: tangent and binormal
    By BlackBox in forum OpenGL: GLSL
    Replies: 4
    Last Post: 10-27-2004, 02:03 PM
  3. Replies: 1
    Last Post: 06-11-2004, 02:52 PM
  4. glsl automatic generic attributes binding
    By imported_Ffelagund in forum OpenGL: GLSL
    Replies: 11
    Last Post: 03-26-2004, 11:35 AM
  5. glsl generic vertex attributes
    By selwakad in forum OpenGL: GLSL
    Replies: 5
    Last Post: 03-24-2004, 08:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean