Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: default values for shader position attribute components?

  1. #1
    Intern Contributor
    Join Date
    Nov 2010
    Posts
    61

    default values for shader position attribute components?

    Hello,

    I'm looking at some code from a few years ago and trying to remember how it worked. My vertex shader has a position input specified like this:

    in vec4 position;

    But when I am setting up my vertex buffer objects, it looks like I am only providing vertices with 2 components, x and y. That's possible to do, right? Have 4 components for position in the shader but only supply 2 in the input buffer? Or not? The code seems to work fine.

    In that case, what is the value of the z and w components in the shader, is there a default? I'm porting the code to Metal, and using the value 1 for both z and w is what makes it work. But I am wondering if that is the default value in OpenGL or if there's something else in the code that I've missed.

    Thanks!

  2. #2
    Intern Contributor
    Join Date
    Nov 2010
    Posts
    61
    Ah nevermind, I found the documentation where it specifies that missing component values are taken from the vector (0,0,0,1). I suspect the reason my my z value needs to be 1 in the new code is due to the difference in Metal's normalized device coordinates, or the way I have my projection matrices set up.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •