Tech-Hounds.com

Because gamers play games, not benchmarks





The Texture Component

If you look at the objects around you, you'll see that even if they have the same basic shape, they differ much in detail - textures, colors, materials etc. Take for example a brick wall - we know that a wall is actually just a simple plane and could be easily modeled as a box, even a cube. But then we lost the illusion of the bricks. While we can use polygons to model each brick in our brick wall, it would be to expensive and not very practical. Thankfully, we have an easier solution.

Remember before we talked about how we can fill a 2D shape with just about any color, even a combination of colors divided into pixels (the bitmap)? Well, we can also use it in 3D graphics. In this case, the bitmap becomes a texture element. We simply take a picture of a brick wall and place in in our 3D box. Now we have a 3D brick wall! Well, sort of anyway.

With textures, we can provide more realistic objects

Combined with Gouraud shading, the practice of texture mapping provides some very pleasing images. Of course, they're still lacking in some way - remember that Gouraud shading can't provide specular highlights and produce some artifacts with low polygon objects. This is a very huge problem for real time 3D graphics, since most early hardware can only do Gouraud shading and renders become very slow if you use high polygon objects. The solution is again very practical - process the lighting for the entire world even before rendering (usually with offline rendering methods such as ray tracing and radiosity). Then put the information INSIDE the textures, so no additional calculations will be needed. This method works beautifully on worlds and objects where the lights are static and doesn't move. For the ones that do, we could make use of simple Gouraud shading.

More effects with multi texturing

The methods described above does a pretty good job with the available hardware at the time. But that doesn't mean they were enough. Everyone wanted faster, better graphics and the industry was more than happy to oblige. We want shadows, bullet marks, smoke, water, reflections - you see it in real life - we want it. Blob shadows, decals for bullet marks, transparent alpha textures for smoke, and environment mapping become the norm. These special effects are made possible by better, faster more capable texturing hardware in consumer 3D graphics.

One of the important features that made all of this possible is multi texturing. Look back at Blinn shading, you'll notice that we essentially have a light, a surface, and information regarding the roughness of the surface (usually called a 'bump' map). Doing Blinn shading in real time is not very practical, but we could 'fake' Blinn shading with multiple textures - one for each component (light, surface and 'bump' map). Since most of the available hardware at the time can process two textures per cycle, doing this fake Blinn will only require two passes in most cases (more if you use better than bilinear filtering). But it's still a lot faster than doing it in software! If you don't want the performance penalty, just toss away the bump texture map, so the hardware will render in one pass. We could even forgo Gouraud shading entirely by using a texture for the light - typically a circle of solid color that gradually fades.

Multi texturing really opens up a whole new era of effects, but the most important part is the preliminary use of shaders. Think of shaders as equations - after all shading algorithms are actually just an equation. But since they're not design specifically for shader use, multitexturing have very limited capabilities and constraints when 'forced' to work with shaders. Even so, graphics programmers are 'hacking' their way to provide better effects. After this, it's very clear what the next step will be - developer controlled, multi texturing - programmable shaders.

Shaders

With programmable shaders, 3D graphics begins a new journey. Graphics programmers have more control over the rendering process. They can specify what data will be processed, but more importantly, how to process them. They can even use them to built the data to be used on the fly! Shaders have also extend themselves to polygons in the form of special vertex shaders. Vice versa, shaders dealing with textures are usually called pixel shaders. All of this innovation now allows the industry to offer consumers more realistic images, with shadows that looks like they do in real life. Real time 3D graphics have progressed rapidly and now provide comparable images to early offline rendering solution such as ray tracing and radiosity. Even effects such as depth of field, motion blur and bloom effects are now possible in real time, again with some caveats.

Now, you remember what we talked about shading algorithms and multitexturing, particularly 'faking' Blinn shading. With programmable shaders, the results are better. Remember that to produce convincing images, we need to calculate just how much light is reflected by the surface at every pixel. To find the specular component, we also have to compare the incidence of light and the camera. The pixels with the appropriate angles and normals will be filled with specular highlights while those around it will gradually fades (diffuse light). Under multitexturing hacks, all of these must be done through some creative and clever coding, but with shaders programmers can explicitly send the code the way it is originally written directly to the graphics chip. With the help of a shader compiler inside the graphics card drivers, this code is translated into instructions which the hardware can understand.

Newer hardware have more capable shader hardware and faster performance. With it, shaders can have much more instructions, branches, loops etc, just like the software that runs on your processor.

Floating point precision

One of the most intriguing changes with shaders is the move from integer number to floating point numbers. This is important because with integers, we might lose some accuracy when processing. Take this as an example: multiplying decimal numbers such as 0,33 or more accurately 1/3.. If we look at the shading algorithms, most of them involves multiply operation. The sum of one or two operations may not differ much, but what if we're doing more than that? 0,3^4 (0.01185921) is not the same with 1/3^4 (0.012345679012345679012345679012309 or 0.01234567).

As you can see from our very simple example above, the number of bits also plays an important role, since the more bits we have, the greater range of results we can show. But you have to remember that all these computations is going to every pixel drawn on your screen. The difference between these two numbers may not be noticeable by your eyes, particularly if the developer is smart enough. That's why not many people see a difference between 16, 24 and 32 bit floating point precision when looking at images from consumer 3D graphics hardware. But as more and more developer and programmers jump in the shader bandwagon and begin writing long, complex shaders, this small difference can make a difference someday. Right now, games are only beginning to rely on shaders - mostly because the hardware is more widespread now, but also because of performance. New graphics card can sometimes offer up to 50 % increase in shader processing power and this trend should continue into the future.

[Previous Page]
[Go to top]
[Next Page]
Disclaimer and Privacy policy.