View Full Version : Positional data in pixel shader
08-27-2012, 04:19 PM
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 :(
10-08-2012, 04:41 AM
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.
01-02-2013, 05:45 AM
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.
01-20-2013, 02:30 PM
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.