View Full Version : Pass informations from vertex to fragment shader
05-07-2005, 05:34 AM
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...)?
05-07-2005, 06:22 AM
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.
05-07-2005, 07:02 AM
Can I really do that in ARB program? Or do I have to use a special language or packages?
Java Cool Dude
05-07-2005, 08:33 AM
Using varying variables or passing things directly as texture coordinates.
gl_TexCoord = stuffToPass;
vec4 passedStuff = gl_TexCoord
MOV result.texcoord, stuffToPass;
MOV passedStuff, fragment.texcoord;
05-07-2005, 12:29 PM
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.