Direct3D HLSL Programming using RenderMonkey IDE
Direct3D HLSL Programming using RenderMonkey IDE Direct3D HLSL Programming using RenderMonkey IDE
Specular Lighting Effect • Built upon previous example • Computes diffuse and specular lighting • Parameters: – Previous example’s parameters – Specular contribution and power coefficients – Specular material color Steps: 1. Compute View vector 2. Compute Reflection vector 3. Compute specular component: n k s * specular _ color * ( R •V ) Game Developer Conference, San Jose, CA, March 7 th 2003
Specular Lighting: Vertex Shader struct VS_OUTPUT { float4 Pos : POSITION; float3 Normal: TEXCOORD0; float3 Light : TEXCOORD1; float3 View : TEXCOORD2; }; VS_OUTPUT main( float4 Pos: POSITION, float3 Norm: NORMAL ) { VS_OUTPUT Out = (VS_OUTPUT) 0; } Out.Pos = mul( view_proj_matrix, Pos ); // Transformed position Out.Normal = normalize( mul(view_matrix, Norm) ); // Normal Out.Light = normalize(-lightDir); // Light vector float3 Pview = mul( view_matrix, Pos ); // Compute view position Out.View = -normalize( Pview ); // Compute view vector return Out; Compute view vector Game Developer Conference, San Jose, CA, March 7 th 2003
- Page 1 and 2: Direct3D® High Level Shader Langua
- Page 3 and 4: RenderMonkey Addresses the Needs of
- Page 5 and 6: Program Your Shaders Using Our Intu
- Page 7 and 8: High Level Shading Language • Int
- Page 9 and 10: Creating an HLSL-based Effect Using
- Page 11 and 12: HLSL Shader Editor Plug-in • Allo
- Page 13: Diffuse Lighting Effect: Pixel Shad
- Page 17 and 18: Advanced Shader Examples • Marble
- Page 19 and 20: Veined Marble Shader • Based on t
- Page 21 and 22: Veined Marble Shader Algorithm: Bas
- Page 23 and 24: Vein Turbulence • Compute vein tu
- Page 25 and 26: Diffusely Reflective Marble Blendin
- Page 27 and 28: Anisotropic Metal Shader Game Devel
- Page 29 and 30: RenderMonkey Anisotropic Metal Exam
- Page 31 and 32: Determining Direction of Anisotropy
- Page 33 and 34: Computing Anisotropic Lighting: Ver
- Page 35 and 36: Assembling The Final Look • Ring
- Page 37 and 38: Translucent Iridescent Shader: Butt
- Page 39 and 40: RenderMonkey Butterfly Wings Shader
- Page 41 and 42: Translucent Iridescent Shader: Vert
- Page 43 and 44: Diffuse Illumination For Translucen
- Page 45 and 46: Making Butterly Wings Iridescent Ir
- Page 47 and 48: Example of Translucent Iridescent S
- Page 49 and 50: Generate Better PS_1_x Code Through
- Page 51 and 52: Summary • Use HLSL for your shade
Specular Lighting Effect<br />
• Built upon previous example<br />
• Computes diffuse and<br />
specular lighting<br />
• Parameters:<br />
– Previous example’s<br />
parameters<br />
– Specular contribution and<br />
power coefficients<br />
– Specular material color<br />
Steps:<br />
1. Compute View vector<br />
2. Compute Reflection vector<br />
3. Compute specular component:<br />
n<br />
k s * specular _ color * ( R •V<br />
)<br />
Game Developer Conference, San Jose, CA, March 7 th 2003