1 / 26

Shading Languages

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

emmy
Download Presentation

Shading Languages

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Shading Languages GeForce3, DirectX 8 Michael Oswald

  2. Shading Languages

  3. Shading Languages GeForce3, DirectX 8 Michael Oswald

  4. 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

  5. DirectX 8.0 • Common Rendering-Pipeline Generation Traversal Transform & Lighting Rasterization Display

  6. DirectX 8.0 • DirectX8 Pipeline Generation Traversal Transform & Lighting Rasterization Display Vertex-Shader Pixel-Shader

  7. 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

  8. Vertex Shaders Vertex Attributes Vertex Program Vertex Output

  9. Vertex Shaders e.g. position, normals, lightvector, colors, densities, weights, velocities... Vertex Attributes 16x4 registers Vertex Program Vertex Output

  10. Vertex Shaders Vertex Attributes Program Parameters 96x4 registers Vertex Program Temporary Registers 128 instructions 12x4 registers Vertex Output A0

  11. 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

  12. 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)

  13. 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

  14. 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)

  15. 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

  16. TC0 TC1 TC2 TC3 Pixel Shaders Hpos color d0 d1 Pixel ALU Pixel

  17. TC0 TC1 TC2 TC3 Pixel Shaders Hpos color d0 d1 texture Stage0 t0 Stage1 t1 Pixel ALU Stage2 t2 Stage3 t3 Texture Stages Pixel

  18. 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

  19. 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

  20. 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

  21. Pixel Shader Language • Texture Adressing Operations • Simple color-fetch: tex • Bump Env Map: texbem, texbeml • Turn coord into color: texcoord tDest • Kill Pixel: texkill

  22. Pixel Shader Language • Matrix Calculation Operations texm3x2pad, texm3x2textexm3x3pad, texm3x3spec, texm3x3vspec, texm3x3tex • Dependent texture-lookuptexreg2ar texreg2gb

  23. Vertex + Pixel Shader

  24. Vertex + Pixel Shader

  25. What to expect... • Extensive use of shading languages • More flexibility • More space for textures, matrices... • Faster Hardware • New bus-systems • Realtime Ray-Tracing?

  26. The End

More Related