Results 1 to 4 of 4

Thread: Positional data in pixel shader

  1. #1
    Junior Member
    Join Date
    Aug 2012

    Positional data in pixel shader

    I'm new to using OpenGL ES 2.0 pixel shaders on iOS.

    I'm rendering a full screen quad using 4 vertices and I want to obtain the interpolated positional vertex data in the pixel shader.

    Can someone explain how this is done, I've been searching for answers all night without success

  2. #2

    Re: Positional data in pixel shader

    Try using varying data type in shaders, so that you can pass interpolated values from vertex to fragment shader.
    Let me know whether it works or not.

  3. #3
    Junior Member
    Join Date
    Jan 2013

    Re: Positional data in pixel shader

    You can take uniform variable in fragment shader and assign that to gl_Fragcolor. Now in your draw function loop, change your local variable as per your color requirement and assign value of this local variable to uniform variable.

  4. #4
    Join Date
    Jun 2012

    Re: Positional data in pixel shader

    The interpolated positional vertex data is not available in the pixel shader for OpenGL ES 2.0, as you discovered.

    One solution is to use the texture coordinates instead because they are available in the pixel/fragment shader in interpolated form. This is what is normally used to sample textures, such as gsvTexCoord in this example:

    gl_FragColor = texture2D(gsuTexture, gsvTexCoord);

    The only real difference is that gsvTexCoord has a limited range of only 0.0 to 1.0.

    Regards, Clay

Similar Threads

  1. Replies: 1
    Last Post: 06-14-2012, 10:52 AM
  2. How to read Pixel data from the MultiSampled framebuffer ?
    By nitinsharma0608 in forum OpenGL ES
    Replies: 4
    Last Post: 01-06-2012, 07:30 PM

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