//**************************************************************// // Effect File exported by RenderMonkey 1.6 // // - Although many improvements were made to RenderMonkey FX // file export, there are still situations that may cause // compilation problems once the file is exported, such as // occasional naming conflicts for methods, since FX format // does not support any notions of name spaces. You need to // try to create workspaces in such a way as to minimize // potential naming conflicts on export. // // - Note that to minimize resulting name collisions in the FX // file, RenderMonkey will mangle names for passes, shaders // and function names as necessary to reduce name conflicts. //**************************************************************// //--------------------------------------------------------------// // CellShade //--------------------------------------------------------------// //--------------------------------------------------------------// // Outline //--------------------------------------------------------------// string CellShade_Outline_Model : ModelData = "D:\\TankGame\\TestApp\\Resources\\Models\\Tanks\\tank2.x"; float4x4 matWorldViewProjection : WorldViewProjection; float4x4 matWorldView; float4x4 matWorld : World; float4 lightDir < string UIName = "lightDir"; string UIWidget = "Direction"; bool UIVisible = false; float4 UIMin = float4( -10.00, -10.00, -10.00, -10.00 ); float4 UIMax = float4( 10.00, 10.00, 10.00, 10.00 ); bool Normalize = true; > = float4( 0.19, 0.10, -0.98, 0.00 ); struct VS_INPUT { float4 Position : POSITION0; float4 Color : COLOR; float3 Normal : NORMAL; }; struct VS_OUTPUT { float4 Position : POSITION0; float4 Color : COLOR; float3 Tex0 : TEXCOORD0; }; VS_OUTPUT CellShade_Outline_Vertex_Shader_vs_main( VS_INPUT Input ) { VS_OUTPUT Output; Output.Position = mul( Input.Position, matWorldViewProjection ); float4 normal = mul(-Input.Normal, matWorld); normal += float4(1.0, 1.0, 1.0, 1.0); Output.Color = normal * 0.5; float4 toLight = normalize(-lightDir); toLight += float4(1.0, 1.0, 1.0, 1.0); Output.Tex0 = toLight * 0.5; return( Output ); } float4x4 CellShade_Outline_Pixel_Shader_matWorldView : WorldView; float outline < string UIName = "outline"; string UIWidget = "Numeric"; bool UIVisible = true; float UIMin = 0.00; float UIMax = 1.00; > = float( 0.48 ); float shade < string UIName = "shade"; string UIWidget = "Numeric"; bool UIVisible = true; float UIMin = 0.00; float UIMax = 1.00; > = float( 0.07 ); float4 myColor < string UIName = "myColor"; string UIWidget = "Color"; bool UIVisible = true; > = float4( 0.49, 0.78, 0.95, 1.00 ); float shininess < string UIName = "shininess"; string UIWidget = "Numeric"; bool UIVisible = true; float UIMin = 0.00; float UIMax = 0.00; > = float( 0.30 ); struct PS_INPUT { float4 Color : COLOR; float4 Tex0 : TEXCOORD0; }; float4 CellShade_Outline_Pixel_Shader_ps_main(PS_INPUT Input) : COLOR0 { const float4 camView = float4(0.0, 0.0, 1.0, 1.0); float4 norm = Input.Color; norm *= 2.0; norm -= float4(1.0, 1.0, 1.0, 1.0); norm = normalize(norm); float4 toLight = Input.Tex0; toLight *= 2.0; toLight -= float4(1.0, 1.0, 1.0, 1.0); toLight = normalize(toLight); float4 vnorm = mul(norm, CellShade_Outline_Pixel_Shader_matWorldView); float4 vLight = mul(toLight, CellShade_Outline_Pixel_Shader_matWorldView); float dpL = saturate(dot(toLight, norm)); float dpV = saturate(dot(camView, vnorm)); float4 ref = normalize(camView + toLight) ; float dpR = saturate(dot(ref, norm)); float spec = pow(dpR, 2.0); if(dpV < outline) { return( float4(0.0, 0.0, 0.0, 0.0) ); } else { if(spec > 1.0 - shininess) { return( float4(1.0, 1.0, 1.0, 1.0)); } else { if(dpL < shade) { return( myColor * 0.5); } else { return( myColor); } } } } //--------------------------------------------------------------// // Reflect //--------------------------------------------------------------// string CellShade_Reflect_Model : ModelData = "D:\\TankGame\\TestApp\\Resources\\Models\\Tanks\\tank2.x"; float4x4 CellShade_Reflect_Vertex_Shader_matWorldViewProjection : WorldViewProjection; float4x4 CellShade_Reflect_Vertex_Shader_matWorldView : WorldView; float4x4 CellShade_Reflect_Vertex_Shader_matWorld; struct CellShade_Reflect_Vertex_Shader_VS_INPUT { float4 Position : POSITION0; float3 Normal : NORMAL; }; struct CellShade_Reflect_Vertex_Shader_VS_OUTPUT { float4 Position : POSITION0; float4 Color : COLOR; }; CellShade_Reflect_Vertex_Shader_VS_OUTPUT CellShade_Reflect_Vertex_Shader_vs_main( CellShade_Reflect_Vertex_Shader_VS_INPUT Input ) { CellShade_Reflect_Vertex_Shader_VS_OUTPUT Output; Output.Position = mul( Input.Position, CellShade_Reflect_Vertex_Shader_matWorldViewProjection ); float4 normal = mul(-Input.Normal, CellShade_Reflect_Vertex_Shader_matWorldView); normal += float4(1.0, 1.0, 1.0, 1.0); Output.Color = normal * 0.5; return( Output ); } float CellShade_Reflect_Pixel_Shader_shininess < string UIName = "CellShade_Reflect_Pixel_Shader_shininess"; string UIWidget = "Numeric"; bool UIVisible = true; float UIMin = 0.00; float UIMax = 0.00; > = float( 0.30 ); struct CellShade_Reflect_Pixel_Shader_PS_INPUT { float4 Color : COLOR; float3 Tex0 : TEXCOORD0; }; texture TexCube_Tex < string ResourceName = "..\\..\\..\\Program Files\\ATI Research Inc\\RenderMonkey 1.62\\Examples\\Media\\Textures\\Snow.dds"; >; samplerCUBE Texture0 = sampler_state { Texture = (TexCube_Tex); }; float4 CellShade_Reflect_Pixel_Shader_ps_main(CellShade_Reflect_Pixel_Shader_PS_INPUT Input) : COLOR0 { float3 norm = Input.Color.xyz; norm *= 2.0; norm -= float3(1.0, 1.0, 1.0); const float3 toCam = float3(0.0, 0.0, 1.0); float3 ref = reflect( norm, toCam); return( float4(texCUBE(Texture0, ref).xyz, CellShade_Reflect_Pixel_Shader_shininess) ); } //--------------------------------------------------------------// // Technique Section for CellShade //--------------------------------------------------------------// technique CellShade { pass Outline { VertexShader = compile vs_2_0 CellShade_Outline_Vertex_Shader_vs_main(); PixelShader = compile ps_2_0 CellShade_Outline_Pixel_Shader_ps_main(); } pass Reflect { ALPHABLENDENABLE = TRUE; DESTBLEND = INVSRCALPHA; SRCBLEND = SRCALPHA; BLENDOP = ADD; VertexShader = compile vs_2_0 CellShade_Reflect_Vertex_Shader_vs_main(); PixelShader = compile ps_2_0 CellShade_Reflect_Pixel_Shader_ps_main(); } }