Direct3D HLSL Programming using RenderMonkey IDE
Direct3D HLSL Programming using RenderMonkey IDE Direct3D HLSL Programming using RenderMonkey IDE
Specular Lighting: Pixel Shader float4 ambient; float4 diffuse; float4 specular; float Ka; float Ks; float Kd; float N; float4 main( float4 Diff : COLOR0, float3 Normal: TEXCOORD0, float3 Light : TEXCOORD1, float3 View : TEXCOORD2 ) : COLOR { // Compute the reflection vector: float3vReflect = normalize(2*dot(Normal, Light)*Normal - Light); } Compute reflection Specular vector contribution // Final color is composed of ambient, diffuse and specular // contributions: float4 FinalColor = Ka * ambient + Kd * diffuse * dot( Normal, Light ) + Ks * specular * pow( max( dot( vReflect, View), 0), N ) ; return FinalColor; Game Developer Conference, San Jose, CA, March 7 th 2003
Advanced Shader Examples • Marble shader • Anisotropic metal shader • Translucent iridescent shader 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 and 14: Diffuse Lighting Effect: Pixel Shad
- Page 15: Specular Lighting: Vertex Shader st
- 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: Pixel Shader<br />
float4 ambient;<br />
float4 diffuse;<br />
float4 specular;<br />
float Ka;<br />
float Ks;<br />
float Kd;<br />
float N;<br />
float4 main( float4 Diff : COLOR0, float3 Normal: TEXCOORD0,<br />
float3 Light : TEXCOORD1, float3 View : TEXCOORD2 )<br />
: COLOR<br />
{<br />
// Compute the reflection vector:<br />
float3vReflect = normalize(2*dot(Normal, Light)*Normal - Light);<br />
}<br />
Compute reflection<br />
Specular vector contribution<br />
// Final color is composed of ambient, diffuse and specular<br />
// contributions:<br />
float4 FinalColor = Ka * ambient +<br />
Kd * diffuse * dot( Normal, Light ) +<br />
Ks * specular * pow( max( dot( vReflect,<br />
View), 0), N ) ;<br />
return FinalColor;<br />
Game Developer Conference, San Jose, CA, March 7 th 2003