12_DXProgramming_3

12_DXProgramming_3 - DirectX Programming #3 Hyunna Lee...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
DirectX Programming #3 Hyunna Lee Computer Graphics, 2009 Fall
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Programmable Shader } For recent hardwares, vertex and pixel processing stage of the graphics pipeline is programmable } Programmable Vertex Shader } Programmable Pixel Shader Primitive Data Vertex Data Tessellation Vertex Processing Geometry Processing Pixel Processing Pixel Rendering Textured Surface Texture Sampler
Background image of page 2
Programming for Shader } In early stage, hardware-dependant mnemonic language is used to program for shader } Shader Assembler } Currently, C-like shading language is widely used } Cg, HLSL, GLSL } General programming platform to utilize GPU’s computing power for general purpose is being introduced lately } NVIDIA CUDA } OpenCL
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Brief History on Programmable Shader } Pixar RenderMan Interface Specification (1988) } Concept of Shader Language(SL) is introduced } Required special-purpose hardwares and used for studio works Luxo Jr. (SIGGRAPH, 1986)
Background image of page 4
Brief History on Programmable Shader } Programmable shader for consumer hardware } Microsoft DirectX 8 (ShaderModel 1.1) } Shader assembler is introduced for vertex and pixel shader programmability
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Brief History on Programmable Shader } NVIDIA Cg (1998) } Introduced to program NVIDIA’s programmable GPU } C-like grammar with reserved keywords // input vertex structVertIn { float4 pos : POSITION; float4 color : COLOR0; }; // output vertex structVertOut { float4 pos : POSITION; float4 color : COLOR0; }; // vertex shader main entry VertOut main(VertIn IN, uniform float4x4 modelViewProj) { VertOut OUT; OUT.pos = mul(modelViewProj, IN.pos); // calculate output coords OUT.color= IN.color; // copy input color to output OUT.color.z= 1.0f; // blue component of color = 1.0f return OUT; }
Background image of page 6
Brief History on Programmable Shader } Microsoft High-Level Shading Language (HLSL) } Introduced with Microsoft DirectX 9 (ShaderModel 2) } Developed alongside NVIDIA Cg } Very similar to Cg structVS_OUTPUT0 { float4 Pos : POSITION; // position float4 ObjSliceTex: TEXCOORD0; // Scaled Front slice Texture Coordinate float4 OutInterTex: TEXCOORD2; }; struct PS_OUTPUT0 { float4 Color : COLOR0; float Depth : DEPTH; }; VS_OUTPUT0 EmptySkipVShader(float4 inPos: POSITION, float4 inSliceTex: TEXCOORD0) { VS_OUTPUT0 Out = (VS_OUTPUT0) 0; float4 ttt= inPos+ sign(isFrontFace)*faceNormal; Out.Pos= mul( ttt, objectTransMatrix); // transform vertices by objectTransMatrix matrix Out.ObjSliceTex= inSliceTex; Out.OutInterTex= Out.Pos; return Out; }
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Shader Model } Programmability of the shader strongly rely on hardware implementations } Distinguished by some Generations } No de jure standards for shader model } Microsoft’s shader model, which inherited NVIDIA model, is de facto standard
Background image of page 8
Microsoft Shader Model } Shader Model 1.1 } Introduced in DirectX 8 } ShaderAssembler } ShaderModel 2 } DirectX 9.0 } HLSL introduced } No flow control } ShaderModel 3 } DirectX 9.0c } Identical to SM2 HLSL grammar } Dynamic flow control (conditional branch, loop …)
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 35

12_DXProgramming_3 - DirectX Programming #3 Hyunna Lee...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online