Graphics Reference
In-Depth Information
The set of equations you could use to combine these inputs together was
quite limited. For example, in OpenGL ES 1.1, the equations listed in
Table 10-1 were available. The inputs A , B , and C to these equations could
come from the vertex color, texture color, or constant color.
Table 10-1
OpenGL ES 1.1 RGB Combine Functions
RGB Combine Function
Equation
REPLACE
A
A × B
MODULATE
A + B
ADD
ADD_SIGNED
A + B - 0.5
INTERPOLATE
A × C + B × (1 - C )
SUBTRACT
A - B
DOT3_RGB ( and DOT3_RGBA )
4 × (( A.r - 0.5) × ( B.r - 0.5) + ( A.g - 0.5) ×
( B.g - 0.5) + ( A.b - 0.5) × ( B.b × 0.5))
There actually was a great number of interesting effects one could achieve,
even with this limited set of equations. However, this was far from
programmable, as the fragment pipeline could be configured only in a
very fixed set of ways.
So why are we reviewing this history here? It helps give an understanding
of how traditional fixed-function techniques can be achieved with
shaders. For example, suppose we had configured the fixed-function
pipeline with a single base texture map that we wanted to modulate
(multiply) by the vertex color. In fixed-function OpenGL ES (or OpenGL),
we would enable a single texture unit, choose a combine equation of
MODULATE , and set up the inputs to the equation to come from the vertex
color and texture color. The code to do this in OpenGL ES 1.1 is provided
here for reference:
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCEl_RGB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCEl_ALPHA, GL_TEXTURE);
 
Search WWH ::




Custom Search