shading languages geforce3, directx 8 michael oswald

26
Shading Languages Shading Languages GeForce3, DirectX 8 GeForce3, DirectX 8 Michael Oswald Michael Oswald

Post on 20-Dec-2015

223 views

Category:

Documents


1 download

TRANSCRIPT

Shading LanguagesShading Languages

GeForce3, DirectX 8GeForce3, DirectX 8

Michael OswaldMichael Oswald

2 / 26Michael Oswald

Shading LanguagesShading Languages

Shading LanguagesShading Languages

GeForce3, DirectX 8GeForce3, DirectX 8

Michael OswaldMichael Oswald

4 / 26Michael Oswald

Shading LanguagesShading Languages Different approaches:Different approaches:

RenderMan RenderMan pure Software-solutionpure Software-solution

ISL ISL Interactive Interactive Compiles ISL to OpenGLCompiles ISL to OpenGL Can be speed up by hardwareCan be speed up by hardware

PixelFlow PixelFlow Hardware-implementation Hardware-implementation pfman generates C++-Code for OpenGLpfman generates C++-Code for OpenGL

GeForce3 GeForce3 Own assembly-language for vertex- and pixel-shadersOwn assembly-language for vertex- and pixel-shaders

5 / 26Michael Oswald

DirectX 8.0DirectX 8.0 Common Rendering-PipelineCommon Rendering-Pipeline

Transform & Lighting

Rasterization Display

Generation Traversal

6 / 26Michael Oswald

DirectX 8.0DirectX 8.0 DirectX8 PipelineDirectX8 Pipeline

Transform & Lighting

Rasterization Display

Generation Traversal

Vertex-Shader

Pixel-Shader

7 / 26Michael Oswald

Vertex ShadersVertex Shaders Small assembler-programs executed per Small assembler-programs executed per

vertexvertex One input vertex generates one output One input vertex generates one output

vertexvertex No topological informationNo topological information

no edge, face, no neighbour-vertex no edge, face, no neighbour-vertex informationinformation

Dynamically loadableDynamically loadable

8 / 26Michael Oswald

VertexVertex Shaders Shaders

Vertex Attributes

Vertex Program

Vertex Output

9 / 26Michael Oswald

Vertex ShadersVertex Shaders

Vertex Attributes

Vertex Program

Vertex Output

16x4 registers

e.g. position, normals, lightvector, colors, densities, weights, velocities...

10 / 26Michael Oswald

Vertex ShadersVertex Shaders

Vertex Attributes

Vertex Program

Vertex Output

Program Parameters

Temporary Registers

A0

128 instructions

96x4 registers

12x4 registers

11 / 26Michael Oswald

Vertex ShadersVertex Shaders

Vertex Attributes

Vertex Program

Vertex Output

Program Parameters

Temporary Registers

A015x4 registers

homogeneous clip space position, diffuse and specular color, up to 4 texture coordinates, fog value, point size

12 / 26Michael Oswald

Vertex Shaders LanguageVertex Shaders Language Operand Modifiers:Operand Modifiers:

Negation, „Swizzeling“, „Smearing“, Negation, „Swizzeling“, „Smearing“, Masking Masking

Common commandsCommon commands MOV, ADD, MUL, MIN, MAXMOV, ADD, MUL, MIN, MAX

Special calculation-commandsSpecial calculation-commands MAD „multiply and add“ MAD „multiply and add“ RCP „reciprocal“ of scalar-value RCP „reciprocal“ of scalar-value 1/x1/x RCS „reciprocal square root“ RCS „reciprocal square root“ 1/sqrt(x)1/sqrt(x)

13 / 26Michael Oswald

Vertex Shaders LanguageVertex Shaders Language EXP, LOG (accurate to ~11 Bits)EXP, LOG (accurate to ~11 Bits)

Vector calculationsVector calculations DP3DP3 3-Component dot-product3-Component dot-product DP4DP4 4-Component dot-product4-Component dot-product

ConditionalsConditionals SGESGE Set greater or equalSet greater or equal SLTSLT Set less thanSet less than

14 / 26Michael Oswald

Vertex Shaders LanguageVertex Shaders Language LightingLighting

LIT:LIT: calculates ambient, calculates ambient, diffuse and specular lighting coefficientsdiffuse and specular lighting coefficients

Distance-vectorDistance-vector DSTDST calculates a „distance calculates a „distance

attenuation“ vector (1, d, d², 1/d) attenuation“ vector (1, d, d², 1/d)

15 / 26Michael Oswald

Vertex Shader LanguageVertex Shader Language Macros:Macros:

EXP, FRC, LOGEXP, FRC, LOG full precision but full precision but slowslowM3x2, M3x3, M3x4, M3x2, M3x3, M3x4, M4x3, M4x4M4x3, M4x4 full matrix- full matrix-

multiplicationmultiplication No branches!No branches!

Use SGE, SLT and multiply and Use SGE, SLT and multiply and accumulateaccumulate

16 / 26Michael Oswald

Pixel ShadersPixel Shaders

Pixel

Hpos

d0 d1TC0 TC1 TC2 TC3

Pixel ALU

color

17 / 26Michael Oswald

Pixel ShadersPixel Shaders

Pixel

t3

t2

t0

Hpos

d0 d1TC0 TC1 TC2 TC3

Pixel ALU

t1

Stage3

Stage0

Stage2

Stage1

TextureStages

color

texture

18 / 26Michael Oswald

Pixel ShadersPixel Shaders

Pixel

c0

t3

t2

t0

r1

c1

c2

c3

c7

c4

... Hpos

d0 d1TC0 TC1 TC2 TC3

r0

Pixel ALU

t1

Stage3

Stage0

Stage2

Stage1

TextureStages

temp

color

texture constant

19 / 26Michael Oswald

Pixel Shader LanguagePixel Shader Language Define Constants:Define Constants:

DEF c#, x, y, z, wDEF c#, x, y, z, w Blending-Operations:Blending-Operations:

MOV, ADD, SUB ,MUL, MAD, DP3MOV, ADD, SUB ,MUL, MAD, DP3 CND D, R0.a, S1, S2CND D, R0.a, S1, S2 LRP D, factor, S1, S2LRP D, factor, S1, S2

20 / 26Michael Oswald

Pixel Shader LanguagePixel Shader Language Argument ModifiersArgument Modifiers

Alpha replicate, Invert, Negate, Bias, Alpha replicate, Invert, Negate, Bias, Signed ScaleSigned Scale

Instruction ModifiersInstruction Modifiers Double Result, Quadruple Result, Double Result, Quadruple Result,

Halve Result, Saturate Halve Result, Saturate Saturation can be used together with Saturation can be used together with

scaling:scaling:

ddp3_x2_sat r1, r0_bx2, t0_bx2p3_x2_sat r1, r0_bx2, t0_bx2

21 / 26Michael Oswald

Pixel Shader LanguagePixel Shader Language Texture Adressing OperationsTexture Adressing Operations

Simple color-fetch: tex Simple color-fetch: tex Bump Env Map:Bump Env Map:

texbem, texbemltexbem, texbeml Turn coord into color: texcoord tDestTurn coord into color: texcoord tDest Kill Pixel: texkill Kill Pixel: texkill

22 / 26Michael Oswald

Pixel Shader LanguagePixel Shader Language Matrix Calculation OperationsMatrix Calculation Operations

texm3x2pad, texm3x2textexm3x2pad, texm3x2textexm3x3pad, texm3x3spec, texm3x3pad, texm3x3spec, texm3x3vspec, texm3x3vspec, texm3x3textexm3x3tex

Dependent texture-lookupDependent texture-lookuptexreg2artexreg2ar texreg2gbtexreg2gb

23 / 26Michael Oswald

Vertex + Pixel ShaderVertex + Pixel Shader

24 / 26Michael Oswald

Vertex + Pixel ShaderVertex + Pixel Shader

25 / 26Michael Oswald

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

26 / 26Michael Oswald

The EndThe End