Direct3D HLSL Programming using RenderMonkey IDE
Direct3D HLSL Programming using RenderMonkey IDE Direct3D HLSL Programming using RenderMonkey IDE
Computing Anisotropic Lighting: Pixel Shader StrandPair StrandLight(float3 normal, float3 light, float3 view, float3 dirAniso ) { StrandPair o; float LdA = dot( light, dirAniso ); float VdA = dot( view, dirAniso ); float2 fnLookup = tex2D(strand, float2(LdA,VdA) * 0.5 +(float2)0.5 ); float spec = fnLookup.y * fnLookup.y; float diff = fnLookup.x; float selfShadow = saturate( dot( normal, light ) ); o.Diffuse = diff * selfShadow; o.Specular = spec * selfShadow; return o; by sampling a precomputed } texture using direction of float4 main( PS_INPUT i ) : COLOR Diffuse anisotropy, and specular to the light final contributions and color view { are computed … vectors. using value float3 color = 0; resulted from the lookup plus self for (int l = 0; l < 2; l++) shadowing term. { StrandPair strand = StrandLight(normal, light[l], view, dirAniso); color += (strand.Diffuse + strand.Specular) * lightColor; } … Anisotropic lighting is computed For each light, accumulate its diffuse and specular contribution Game Developer Conference, San Jose, CA, March 7 th 2003
Assembling The Final Look • Ring color is determined by combining a sampled gradient texture and user-specified ring material color – Sample gradient texture by using previously computed ring volume coordinates • Ring ambient material color is added to the result • Final color is assembled from the anisotropic lighting contribution modulated by shadowing, final ring color and scene ambient color * 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 and 16: Specular Lighting: Vertex Shader st
- 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: Computing Anisotropic Lighting: Ver
- 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
Computing Anisotropic<br />
Lighting: Pixel Shader<br />
StrandPair StrandLight(float3 normal, float3 light, float3 view,<br />
float3 dirAniso )<br />
{<br />
StrandPair o;<br />
float LdA = dot( light, dirAniso );<br />
float VdA = dot( view, dirAniso );<br />
float2 fnLookup = tex2D(strand, float2(LdA,VdA) * 0.5 +(float2)0.5 );<br />
float spec = fnLookup.y * fnLookup.y;<br />
float diff = fnLookup.x;<br />
float selfShadow = saturate( dot( normal, light ) );<br />
o.Diffuse = diff * selfShadow;<br />
o.Specular = spec * selfShadow;<br />
return o;<br />
by sampling a precomputed<br />
}<br />
texture <strong>using</strong> direction of<br />
float4 main( PS_INPUT i ) : COLOR Diffuse anisotropy, and specular to the light final contributions and color view<br />
{<br />
are computed …<br />
vectors. <strong>using</strong> value<br />
float3 color = 0;<br />
resulted from the lookup plus self<br />
for (int l = 0; l < 2; l++) shadowing term.<br />
{<br />
StrandPair strand = StrandLight(normal, light[l], view, dirAniso);<br />
color += (strand.Diffuse + strand.Specular) * lightColor;<br />
}<br />
…<br />
Anisotropic lighting is computed<br />
For each light, accumulate its<br />
diffuse and specular contribution<br />
Game Developer Conference, San Jose, CA, March 7 th 2003