//------------------------------------------------------------------------------------------------ // VARIABLES //------------------------------------------------------------------------------------------------ // TRANSFORMATIONS float4x4 mtxWorld : WORLD; float4x4 mtxWorldViewProj : WORLDVIEWPROJECTION; // GLOBALS float4x4 mtxReflect : GLOBAL; //------------------------------------------------------------------------------------------------ // SAMPLERS //------------------------------------------------------------------------------------------------ texture ReflectionMap < string NTM = "shader"; int NTMIndex = 0; >; texture Light < string NTM = "dark"; >; texture Gloss < string NTM = "gloss"; >; texture Marble < string NTM = "base"; >; sampler GlossSampler = sampler_state { Texture = (Gloss); AddressU = WRAP; AddressV = WRAP; MagFilter = LINEAR; MinFilter = LINEAR; MipFilter = LINEAR; }; sampler LightSampler = sampler_state { Texture = (Light); AddressU = WRAP; AddressV = WRAP; MagFilter = LINEAR; MinFilter = LINEAR; MipFilter = LINEAR; }; sampler ReflectionSampler = sampler_state { Texture = (ReflectionMap); AddressU = CLAMP; AddressV = CLAMP; MagFilter = LINEAR; MinFilter = LINEAR; MipFilter = LINEAR; }; sampler MarbleSampler = sampler_state { Texture = (Marble); AddressU = WRAP; AddressV = WRAP; MagFilter = LINEAR; MinFilter = LINEAR; MipFilter = LINEAR; }; //------------------------------------------------------------------------------------------------ // VERTEX OUTPUT FORMAT //------------------------------------------------------------------------------------------------ struct VS_OUTPUT { float4 f4Pos : POSITION; float2 f2TexCoords : TEXCOORD0; float2 f2GlossTexCoords : TEXCOORD1; float2 f2LightMapTexCoords : TEXCOORD2; float4 f4ReflectionCoords : TEXCOORD3; }; //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // VERTEX SHADER //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ VS_OUTPUT VS( float3 InPos : POSITION, float2 f2Tex : TEXCOORD0, float2 f2Tex2 : TEXCOORD1 ) { VS_OUTPUT Out = (VS_OUTPUT)0; // Transform the point into world coordinates float3 f3Pos = mul( float4( InPos, 1 ), mtxWorld ); // Transform the vertex into screen space Out.f4Pos = mul( float4( InPos, 1 ), mtxWorldViewProj ); // Push the object coordinates into a reflected (0, 1) space Out.f4ReflectionCoords = mul( float4( f3Pos, 1 ), mtxReflect ); Out.f2TexCoords = f2Tex; Out.f2GlossTexCoords = f2Tex; Out.f2LightMapTexCoords = f2Tex2; return Out; } //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // PIXEL SHADER //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ PIXELSHADER PS = asm { ps_1_1 def c0, -0.5, -0.5, -0.5, -0.5 tex t0 // Base Map tex t1 // Gloss Map tex t2 // Light Map tex t3 // Reflection Map mov r0, t0 lrp r0.rgb, t1, t3, r0 add r1, t2, c0 add r0.rgb, r0, r1 }; //------------------------------------------------------------------------------------------------ // TECHNIQUES //------------------------------------------------------------------------------------------------ technique TDanceReflections_11 { // Reflection pass pass P0 { // Enable depth writing ZEnable = TRUE; ZWriteEnable = TRUE; ZFunc = LESSEQUAL; // Clear render states Lighting = FALSE; FogEnable = FALSE; AlphaBlendEnable = TRUE; SrcBlend = SRCALPHA; DestBlend = INVSRCALPHA; AlphaTestEnable = FALSE; TextureTransformFlags[3] = PROJECTED; // Set the samplers Sampler[0] = ; Sampler[1] = ; Sampler[2] = ; Sampler[3] = ; // Set the texture coordinate indices (may have been modified from a previous FFP object, which could cause a crash). TexCoordIndex[0] = 0; TexCoordIndex[1] = 1; TexCoordIndex[2] = 2; TexCoordIndex[3] = 3; VertexShader = compile vs_1_1 VS(); PixelShader = ; } }