Graphics Reference
In-Depth Information
OpenGL and World Coordinates
World Coordinates are what you get when Model Coordinates are transformed into the
scene but are not yet transformed into the eye's coordinate space. Why don't we have
an example here of colors determined by world-space coordinates? Because OpenGL
doesn't capture world coordinates in a way that shaders can get access to them
through built-in variables. We can use the model coordinates because we can access
the vertex coordinates through the OpenGL variable aVertex , and we can use the eye
coordinates because we can access the model view matrix through the OpenGL variable
uModelViewMatrix . But the world coordinates are not available to us using OpenGL
fixed-function matrices. However, you can manage your own model transformations
and create world-space vertices in your vertex shader using code such as
uniform mat4 uWorldMatrix;
// created and passed in by app
. . .
vec3 WCposition = ( uWorldMatrix * aVertex ).xyz;
This vertex shader shows other useful techniques. It picks up the object's
color from the atribute aColor variable and passes it on as a new variable to
be used by the fragment shader, computes the light intensity using a standard
diffuse lighting technique and passes that on as well, so that the lighting can be
used in the fragment shader. However, if you want to use the full ADS light-
ing model, you must take into account much more than just the light intensity.
This is covered in Chapter 6.
Fixed-Function Processing after the Vertex Shader
Some parts of the graphics pipeline usually associated with the vertex process-
ing are not subsumed by a vertex shader. These include
all clipping, including view volume clipping and user-defined clipping,
homogeneous division,
viewport processing,
depth range scaling.
Finally, primitive assembly is done after all vertex processing is finished
and before the assembled vertices are sent to later shaders (such as tessellation
or geometry shaders) and finally to the rasterization stage.
Search WWH ::




Custom Search