Pass informations from vertex to fragment shader

Hi
I compute some values in the vertex shader and then ,depending on their values, do some operations in the fragment shader. How can I pass this values/information, if it’s not the normal parameters (color, position, texture, etc…)?
Thanks

Hi
you have to create a global variable with the qualifier “varying”. It must be the same declaration in your vertex shader and in the fragment shader. Data between vertex and fragment shader are interpolated thanks to this.

Can I really do that in ARB program? Or do I have to use a special language or packages?

Using varying variables or passing things directly as texture coordinates.

GLSL:
Passing:
gl_TexCoord[0] = stuffToPass;

Retrieving:
vec4 passedStuff = gl_TexCoord[0]

ARB:
Passing:
MOV result.texcoord[0], stuffToPass;

Retrieving:
MOV passedStuff, fragment.texcoord[0];

Texture coordinates do not have to be used for textures. They’re just a 4-vector floating-point value that gets linearly interpolated (perspectively-correct) across the surface of a triangle.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.