Shader Programming The University of Tennessee Dr Jian Huang Presented by Jamison Daniel www cs utk edu daniel shaders Specialized and Expensive Graphics Hardware Silicon Graphics SGI and Evans Sutherland designed specialized and expensive graphics hardware Introduced vertex transformation and texture mapping Extremely expensive no mass market success Noninteractive Shading Languages Renderman Shading Language developed by Pixar Animation Studio in the late 1980s Inspired by an earlier idea called shade trees Rob Cook SIGGRAPH 1984 Open ended control of the appearance of rendered surfaces in the pursuit of photorealism requires programmability Pixar Animation Studio PhotoRealistic Renderman Dumb Frame Buffers IBM introduced Video Graphics Array VGA hardware in 1987 CPU was responsible for updating all the pixels All aspects of computer graphics were programmable First Generation GPUs up to 1998 nVidia s TNT2 ATI s Rage and 3dfx s Voodoo3 Capable of rasterizing pre transformed triangles and applying one or two textures Completely relieve the CPU from updating individual pixels Lack the ability to transform vertices of 3D objects vertex transformations occur on the CPU Limited set of math operations for combining textures to compute the color of rasterized pixels Second Generation GPUs nVidia s GeForce 256 and GeForce2 ATI s Radeon 7500 and S3 s Savage3D Offload 3D vertex transformation and lighting T L from the CPU Expanded set of math operations for combining textures and coloring pixels including cube map textures and signed math operations Not programmable Third Generation GPUs nVidia s GeForce3 and GeForce4 Ti Microsoft s Xbox and ATI s Radeon 8500 Provides vertex programmability rather than merely offering more configurability More pixel level configurability but not programmability ARB vertex program exposes vertexlevel programmability to applications Fourth Generation GPUs 2002 nVidia s GeForce FX family with CineFX architecture and ATI s Radeon 9700 9800 Provide both vertex level and pixel level programmability Both ARB vertex program and ARB fragment program Generating Realistic Interactive Images is an embarrassingly parallel problem Graphics hardware designers can repeatedly split up the problem of creating realistic images into more chunks of work that are smaller and easier to tackle Then hardware engineers can arrange in parallel the ever greater number of transistors available to execute all these various chunks of work The graphics pipeline is a sequence of stages operating in parallel and in a fixed order Each stage receives its input from the prior stage and sends its output to the subsequent stage Vertex Transformation First processing stage in the graphics hardware pipeline that performs a series of math operations on each vertex Includes transforming the vertex position into a screen position for use by the rasterizer generating texture coordinates and lighting the vertex to determine its color Primitive Assembly and Rasterization Assembles vertices into geometric primitives based on the geometric primitive batching information that accompanies a sequence of vertices Polygons that survive the clipping and culling steps must be rasterized The results of rasterization are a set of pixel locations as well as a set of fragments Fragment vs Pixel A pixel represents the contents of the frame buffer at a specific location A fragment is the state required potentially to update a particular pixel A fragment has an associated pixel location a depth value and a set of interpolated parameters Interpolation Texturing and Coloring Once a primitive is rasterized into a collection of fragments the interpolation texturing and coloring stage interpolates the fragment parameters as necessary performs a sequence of texturing and math operations and determines a final color for each fragment Raster Operations The raster operation stage checks each fragment based on a number of tests including the scissor alpha stencil and depth tests If any test fails this stage discards the fragment without updating the pixel s color value Finally a frame buffer write operation replaces the pixel s color with the blended color Fixed Function Limitations The fundamental limitations thus far in PC graphics accelerators has been that they are fixed function Silicon designers have hard coded specific graphics algorithms into the graphics chips and as a result application developers have been limited to using these specific algorithms OpenGL Unextended OpenGL mandates a certain set of configurable per vertex computations defining vertex transformation texture coordinate generation and transformation and lighting Several extensions have added further pervertex computations to OpenGL ARB texture cube map NV texgen reflection NV texgen emboss EXT vertex weighting Each such extension adds a small set of relatively flexible per vertex computations OpenGL The per vertex computations for standard OpenGL given a particular set of lighting and texture coordinate generation modes along with any state for extensions defining per vertex computations is in essence a vertex program However the sequence of operations is defined implicitly by the current OpenGL state settings rather than defined explicitly as a sequence of instructions Vertex Program A vertex program is a sequence of floating point 4 component vector operations that determines how a set of program parameters defined outside of OpenGL s Begin End pair and an input set of pervertex parameters are transformed to a set of per vertex result parameters Two Ways To Process Vertices 1 Fixed function pipeline This is the standard Transform and Lighting T L pipeline where the functionality is essentially fixed The T L pipeline can be controlled by setting render states matrices and lighting and material properties 2 Vertex Shaders Vertex Shader Application Procedural geometry cloth soap bubbles Isidoro Gosslin Skinning and vertex blending Gosselin Texture Generation Riddle Zecha Advanced Keyframe Interpolation complex facial expressions and speech Particle System Rendering Real time modification of the Perspective View lens effects underwater effect Many more that no one has discovered yet Vertex Processor Flow Load each vertex s attribute into the vertex processor The vertex processor then repeatedly fetches the next instruction and executes it until the vertex program terminates The vertex attribute registers are read only and contain the application
View Full Document
Unlocking...