Programmable Pixel and Vertex Shaders Print E-mail
Written by Tuan "Solace" Nguyen
Saturday, February 24, 2001
Article Index
Programmable Pixel and Vertex Shaders
Pixel Shading
Vertex Programming
Vertex Programming Benefits
Pixel Shading

With the advent of the GeForce2 and the NSR, NVIDIA introduced a better method than EMBM to increase details on objects in a game. Since every game that goes through the graphics pipeline must eventually end up as pixels, NVIDIA sought to increase detail but individually manipulating each pixel.

What is per-pixel shading? It's a method of applying special rendering effects... per pixel. It allows material and real world effects to be applied individually to a pixel for more accuracy and intensity. Per-pixel shading will redefine the visual look and feel of imagery for PC graphics. Per-pixel shading has long been used in film production to create a more realistic and lifelike appearance for computer generated imagery. If you've seen Toy Story, you'll definitely remember Buzz Light-year. Remember the translucent reflection on Buzz's helmet? How the environment and light streaks reflected off the glass but also let the image underneath show through? That was done with per-pixel shading. Until now, it wasn't practical to use per-pixel shading on a PC because of the intense power and processing requirements needed. Sure, you could have done that in 3D Studio but could you have done it in real-time? Could the effect be applied to an entire frame at high resolution in 1/60th of a second? Not until now.

Per-pixel shading is useful for simulating natural phenomena and accurate surface attributes such as fur, cloth, metals, glass, rock, and other highly detailed surfaces.

Traditionally, effects were done on an entire triangle and sometimes an entire texture using a technique called interpolation. Special effects were done using calculations based on the vertices of the triangle and interpolating the entire area from the vertices. The end result is a generalized visual appearance… like an estimate or approximation of the final image. The key benefit of using interpolation is that it is fast and easy to apply. But, the downside to it is that with large triangles, the resulting image contains artifacts, which degrades overall image accuracy and quality.

   



Using per-pixel shading, effects and calculations are applied to individual pixels. Since the triangle will be composed of many pixels, the resulting image is highly accurate in representing what the image was intended to be. Let’s assume that a generic triangle is drawn together (including its area) using 100 pixels. Now, we also have a effect pallet of 10 effects. Each pixel then, can accept any one of the ten that are available. That’s an outcome of 10,000 different possible effects just for that one triangle. If interpolation was used, than the effect is fixed using that one out of ten effects and generalized across the entire triangle. Below is a visual comparison between interpolation and per-pixel shading.

Programmable Pixel Shaders

What if the game developer could control the way the shading procedure behaves? What if the developer could manipulate a set of pixels one way but another set in different way on the same texture? What if the developer could program the pixel shader itself to do whatever he or she wanted? Then we’d be talking about an infinite number of manipulating possibilities.

The GeForce2 could do Dot3 (Dot Product) and other advanced bump mapping and shading effects on a per-pixel basis.


Only two texture-blend operations per pass in the NSR
Although developers could create wonderful effects in a single pass or multiple passes, there was no loop-back operation. Because the process could not be reapplied to the same pixel over again in different ways, effects that required textures to be read dependently were not possible. While this was definitely a growing limitation, the NSR’s fixed pipeline was already capable of creating Dot3 bump mapping very convincingly and realistically. This enabled games to have a great amount of detail without increasing the actual geometric detail of the object.


From the given features, this is the vertex shading pipeline we assume the GF3 will follow
Explained: It is believed and assumed that the GeForce3 will handle four or more textures at a time. Logically, the GeForce3 would have to be able to handle them independantly to accomplish the "infinite" number of effects that Nvidia claims it is capable of doing. Besides juggling textures independantly, they are also able to apply effects to each texture independantly using the DirectX8 shader, as been said by Nvidia.

With the new engine, it is possible to have effects like a texture surface that’s shiny, bumpy, and dynamically changing. Also, with the nfiniteFX engine (programmable pixel and vertex shaders), the developer can custom program the engine itself to do whatever they want it to do from an unlimited number combinations and permutations.

Once the texture combination calls are completed, there can be an unlimited number of combinations that you can do with the 8 texture blends. All of this wraps under the DirectX 8 pixel shaders.

Improvement

Basically, Nvidia has now made the entire NSR Shading pipeline fully programmable, while at the same time enhancing its texture management and operating capabilities. If you haven’t seen some of the basic things the NSR in the GeForce2 can do, I’ve included some screenshots from the hit game Giants: Citizen Kabuto.




Click on the images to see a full size screenshot.
All the images above have been rendered on a GeForce2 Ultra in real time. We’re talking about in-game screenshots. The game actually looks like this w hen you’re playing it if you’re one of those who haven’t had the chance to see Giants. The clouds and sky scenes in Giants is the best in any game I’ve ever seen.

Keep in mind that these are basic functions of the NSR. We haven’t even seen the capabilities of the new nfiniteFX engine. Soon though -- all in good time.