Reputation: 8414
I'm reading the Procedural Texturing chapter in the red book (OpenGL Programming Guide). In their procedural texturing example, one of the parameters that gets passed in from the application to the shaders is the texture coordinates. However, they do not show how to generate the texture coordinates.
Can someone provide an example of how to go about generating texture coordinates when doing procedural texturing?
Upvotes: 0
Views: 1258
Reputation: 2917
I don't have the OpenGL Programming Guide, so I can't comment specifically on their example, but in general:
If your procedural texture calculates colours based on two dimensional coordinates, these are no different from ordinary texture coordinates. Just pass them in from the application (or calculate them based on some projection in the vertex shader) as you would normally.
If your procedural texture calculates colours based on three dimensional coordinates, you will typically use the (untransformed) vertex positions as input to the procedural texture calculation. Copy the vertex position attribute to a varying
(or out
in recent GLSL dialects) vec3
variable in your vertex shader.
Upvotes: 2