Graphics Reference
In-Depth Information
Another example GLIB file comes from the function graphing shader of
Chapter 2; in this example, you will see the following features:
Perspective is identified, with a field of view of 70°.
The vertex and fragment shaders ripple.vert and ripple.frag are
specified.
The color is specified with RGB of (1.0, 0.5, 0.0).
A QuadXY is specified with range −5 to 5 and with 200 sub-quads in each
direction (this makes the function graph show up very smoothly).
You should be able to see something of these in Figure 3.4 in the earlier
chapter.
##OpenGL GLIB
Perspective 70
Vertex ripple.vert
Fragment ripple.frag
Program Ripple
Color 1. 0.5 0
QuadXY .2 5. 200 200
More on Textures and Noise
Textures and noise are two important concepts for fragment shaders, and
glman gives you good access to them. This section covers a few important ideas
in working with them.
Using Textures
As indicated above, there are two ways to input a 2D texture in glman : as a
BMP file or as a raw texture file. If you input the texture as a BMP file, the file
must be 24-bit RGB, uncompressed. If you want this texture to be useable on
any graphics card, even an older one,, be sure the image dimensions are pow-
ers of two. Some graphics cards quietly don't require this to be true, but many
still do.
The 2D raw texture format is very simple. The first 8 bytes are two
4-byte integers, declaring the S and T image dimensions. The next bytes are
the RGBA values for each texel. These RGBA values can be unsigned bytes or
floats. Either way, glman will look at the size of the file and do the right thing.
Search WWH ::




Custom Search