OpenGL Shading Language Tutorials
Tutorial 4: Varying Variables
Varying variables provide an interface between Vertex and Fragment Shader. Vertex Shaders compute values per vertex and fragment shaders compute values per fragment. If you define a varying variable in a vertex shader, its value will be interpolated (perspective-correct) over the primitve being rendered and you can access the interpolated value in the fragment shader.
Varying can be used only with the data types float, vec2, vec3, vec4, mat2, mat3, mat4. (arrays of them too.)
I set the interpolated value as output color, this results in the color cube.
Using 3 varying float variables is bad design. Change it so it uses one vec3.
Author: Martin Christen, email@example.com
(source code is included in Tutorial Version 0.1 and higher)
© 2003 by Martin Christen. All Rights Reserved.