Vertex Pixel Shaders CPS 124 Computer Graphics Ferdinand











- Slides: 11
Vertex & Pixel Shaders CPS 124 – Computer Graphics Ferdinand Schober
Shader History I • 1995/1996: 3 dfx Voodoo 1 first mass market GPU, hw accelerated rasterization GLIDE API, 16 bit buffers, texturing & shading Quake using Open. GL! • 1998: 3 dfx Voodoo 2 / Banshee AGP port, but no AGP texturing two texture units for single-pass multitexturing • 1999: Nvidia Geforce 256 / Matrox G 400 fixed function graphics pipeline (T&L) first hardware Open. GL support DDR memory introduction bump mapping
Shader History II • 2000: 3 dfx Voodoo 3 / Nvidia Geforce 2 multi-texturing unit, “Year of Nvidia”, per pixel shading, hardware transform + clipping + shading, full screen antialiasing • 2001: Nvidia Geforce 3 programmable T&L • 2002: Nvidia Geforce 4 Ti / Direct. X 9. 0 first full hardware/software shader support • 2003: Nvidia Geforce FX / ATI Radeon 9800 XT 256 -bit memory port, displacement mapping, 128 -bit color precision, Ultra Shadow, AGP 8 x
Current Graphic Cards • Geforce FX 5950 Ultra – – – – Graphics Core/Interface: 256 -bit Fill Rate: 3. 8 billion texels/sec. Vertices/sec. : 356 million Textures per Pixel: 16 Pixel Shaders (2. 0)/Vertex Shaders Supports Open. GL 1. 5 / DX 9. 0 Ultra. Shadow, Cine. FX 2. 0 Geforce FX Demo
Current Graphic Cards II • ATI Radeon 9800 XT – – – – Graphics Core/Interface: 256 -bit Fill Rate: 3. 3 gpixels/sec. Vertices/sec. : 412 million 2 x/4 x/6 x full screen antialiasing Pixel Shaders (2. 0)/Vertex Shaders Supports Open. GL 1. 5 / DX 9. 0 Smart. Shader, Truform 2. 0 Videoshader ATI Radeon 9800 XT Demo
Pixel vs. Vertex Shaders • Definition (wikipedia): “ 3 D hardware previously used fixed-function pipelines in which, for example, one was stuck with the lighting model chosen by the hardware vendor. Graphics hardware was able to do transformation and lighting (T&L for short) on the card, but it was not flexible. A vertex shader sidesteps the T&L stage in the pipeline and lets the user add on to it. Pixel shaders operate after the geometry pipeline and before final rasterization. They operate in parallel with multitexturing to produce a final pixel color and z-value for the final, rasterization step in the graphics pipeline (where alpha blending and depth testing occur). ”
Shader Languages • Different Standards: Nvidia: Cg Open. GL: GL 2 ATI: HSLS (Direct. X 9) Provide high level language for assembler-based shading code. Use optimized (JIT) compilers to transform to highly efficient machine code. Winner yet undecided. Example Shaders
Small Example (Cg) • Why Cg? – – Open source compiler Works with Open. GL & Direct. X C-like language can be used for multiple GPUs/Platforms
Small Example (Cg) II The program transforms an object-space position for a vertex by a 4 x 4 matrix containing the concatenation of the modeling, viewing, and projection transforms. The resulting vector is output as the clip-space position of the vertex. The per-vertex color is scaled by a floating-point parameter prior to output. Also, two texture coordinate sets are passed through unperturbed. void simple. Transform(float 4 object. Position : POSITION, float 4 color : COLOR, float 4 decal. Coord : TEXCOORD 0, float 4 light. Map. Coord : TEXCOORD 1, out float 4 clip. Position : POSITION, out float 4 o. Color : COLOR, out float 4 o. Decal. Coord : TEXCOORD 0, out float 4 o. Light. Map. Coord : TEXCOORD 1, uniform float brightness, uniform float 4 x 4 model. View. Projection) { clip. Position = mul(model. View. Projection, object. Position); o. Color = brightness * color; o. Decal. Coord = decal. Coord; o. Light. Map. Coord = light. Map. Coord; } vs. 1. 1 mov o. T 0, v 7 mov o. T 1, v 8 dp 4 o. Pos. x, c 1, v 0 dp 4 o. Pos. y, c 2, v 0 dp 4 o. Pos. z, c 3, v 0 dp 4 o. Pos. w, c 4, v 0 mul o. D 0, c 0. x, v 5
Eye Candy • And now some shader eye candy: • Radeon vertex shading/bump mapping demo • HSLS demo • Dynamic Fur • Radeon 9700 demos More in cutting-edge games lecture…
Vertex & Pixel Shaders The End し ゅ う え ん 終 演