270 likes | 441 Views
Shading Languages. GeForce3, DirectX 8 Michael Oswald. Shading Languages. Shading Languages. GeForce3, DirectX 8 Michael Oswald. Shading Languages. Different approaches: RenderMan pure Software-solution ISL Interactive Compiles ISL to OpenGL Can be speed up by hardware PixelFlow
E N D
Shading Languages GeForce3, DirectX 8 Michael Oswald
Shading Languages GeForce3, DirectX 8 Michael Oswald
Shading Languages • Different approaches: • RenderMan • pure Software-solution • ISL • Interactive • Compiles ISL to OpenGL • Can be speed up by hardware • PixelFlow • Hardware-implementation • pfman generates C++-Code for OpenGL • GeForce3 • Own assembly-language for vertex- and pixel-shaders
DirectX 8.0 • Common Rendering-Pipeline Generation Traversal Transform & Lighting Rasterization Display
DirectX 8.0 • DirectX8 Pipeline Generation Traversal Transform & Lighting Rasterization Display Vertex-Shader Pixel-Shader
Vertex Shaders • Small assembler-programs executed per vertex • One input vertex generates one output vertex • No topological information • no edge, face, no neighbour-vertex information • Dynamically loadable
Vertex Shaders Vertex Attributes Vertex Program Vertex Output
Vertex Shaders e.g. position, normals, lightvector, colors, densities, weights, velocities... Vertex Attributes 16x4 registers Vertex Program Vertex Output
Vertex Shaders Vertex Attributes Program Parameters 96x4 registers Vertex Program Temporary Registers 128 instructions 12x4 registers Vertex Output A0
Vertex Shaders Vertex Attributes Program Parameters Vertex Program Temporary Registers homogeneous clip space position, diffuse and specular color, up to 4 texture coordinates, fog value, point size Vertex Output A0 15x4 registers
Vertex Shaders Language • Operand Modifiers: • Negation, „Swizzeling“, „Smearing“, Masking • Common commands • MOV, ADD, MUL, MIN, MAX • Special calculation-commands • MAD „multiply and add“ • RCP „reciprocal“ of scalar-value 1/x • RCS „reciprocal square root“ 1/sqrt(x)
Vertex Shaders Language • EXP, LOG (accurate to ~11 Bits) • Vector calculations • DP3 3-Component dot-product • DP4 4-Component dot-product • Conditionals • SGE Set greater or equal • SLT Set less than
Vertex Shaders Language • Lighting • LIT: calculates ambient, diffuse and specular lighting coefficients • Distance-vector • DST calculates a „distance attenuation“ vector (1, d, d², 1/d)
Vertex Shader Language • Macros:EXP, FRC, LOG full precision but slowM3x2, M3x3, M3x4, M4x3, M4x4 full matrix- multiplication • No branches! • Use SGE, SLT and multiply and accumulate
TC0 TC1 TC2 TC3 Pixel Shaders Hpos color d0 d1 Pixel ALU Pixel
TC0 TC1 TC2 TC3 Pixel Shaders Hpos color d0 d1 texture Stage0 t0 Stage1 t1 Pixel ALU Stage2 t2 Stage3 t3 Texture Stages Pixel
TC0 TC1 TC2 TC3 Pixel Shaders Hpos color d0 d1 texture constant Stage0 t0 c0 Stage1 t1 Pixel ALU c1 Stage2 t2 c2 Stage3 t3 c3 c4 Texture Stages temp r0 ... Pixel r1 c7
Pixel Shader Language • Define Constants: • DEF c#, x, y, z, w • Blending-Operations: • MOV, ADD, SUB ,MUL, MAD, DP3 • CND D, R0.a, S1, S2 • LRP D, factor, S1, S2
Pixel Shader Language • Argument Modifiers • Alpha replicate, Invert, Negate, Bias, Signed Scale • Instruction Modifiers • Double Result, Quadruple Result, Halve Result, Saturate • Saturation can be used together with scaling:dp3_x2_sat r1, r0_bx2, t0_bx2
Pixel Shader Language • Texture Adressing Operations • Simple color-fetch: tex • Bump Env Map: texbem, texbeml • Turn coord into color: texcoord tDest • Kill Pixel: texkill
Pixel Shader Language • Matrix Calculation Operations texm3x2pad, texm3x2textexm3x3pad, texm3x3spec, texm3x3vspec, texm3x3tex • Dependent texture-lookuptexreg2ar texreg2gb
What to expect... • Extensive use of shading languages • More flexibility • More space for textures, matrices... • Faster Hardware • New bus-systems • Realtime Ray-Tracing?