float4x4 World; float4x4 View; float4x4 Projection; float4 Amb; float4 Diff0; float4 Diff1; float4 Diff2; float4 Dir0; float4 Dir1; float4 Dir2; texture MyTexture0; sampler mySampler0 = sampler_state{ Texture = ; MagFilter = Linear; MinFilter = Linear; }; texture MyTexture1; sampler mySampler1 = sampler_state{ Texture = ; MagFilter = Linear; MinFilter = Linear; }; texture MyTexture3; sampler mySampler3 = sampler_state{ Texture = ; MagFilter = Linear; MinFilter = Linear; }; texture MyTexture5; sampler mySampler5 = sampler_state{ Texture = ; MagFilter = Linear; MinFilter = Linear; }; texture MyTexture6; sampler mySampler6 = sampler_state{ Texture = ; MagFilter = Linear; MinFilter = Linear; }; struct VertexShaderInput { float4 Position : POSITION0; float3 Normal: NORMAL0; float4 TextureCoordinate : TEXCOORD0; half4 patternNumber : TEXCOORD1; }; struct VertexShaderOutput { float4 Position : POSITION0; float4 TextureCoordinate : TEXCOORD0; float4 Color: COLOR0; half4 patternNumber : TEXCOORD1; }; VertexShaderOutput VertexShaderFunction(VertexShaderInput input) { VertexShaderOutput output; float4 worldPosition = mul(input.Position, World); float4 viewPosition = mul(worldPosition, View); output.Position = mul(viewPosition, Projection); output.TextureCoordinate = input.TextureCoordinate; float4 worldNormal = mul(input.Normal, World); float4 viewNormal = mul(worldNormal, View); float3 N = mul(viewNormal, Projection); float4 col0 = Diff0 * max(dot(N,Dir0),0) + Diff0 * Amb; float4 col1 = Diff1 * max(dot(N,Dir1),0) + Diff1 * Amb; float4 col2 = Diff2 * max(dot(N,Dir2),0) + Diff2 * Amb; output.Color = col0 + col1 + col2; output.patternNumber = input.patternNumber; return output; } float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 { if(input.patternNumber.x == 6) return tex2D(mySampler6, input.TextureCoordinate) * input.Color; else if(input.patternNumber.x == 5) return tex2D(mySampler5, input.TextureCoordinate) * input.Color; else if(input.patternNumber.x == 3) return tex2D(mySampler3, input.TextureCoordinate) * input.Color; else if(input.patternNumber.x == 1) return tex2D(mySampler1, input.TextureCoordinate) * input.Color; else return tex2D(mySampler0, input.TextureCoordinate) * input.Color; } technique Technique1 { pass Pass1 { VertexShader = compile vs_1_1 VertexShaderFunction(); // VertexShader = compile vs_2_0 VertexShaderFunction(); // PixelShader = compile ps_1_1 PixelShaderFunction(); PixelShader = compile ps_2_0 PixelShaderFunction(); } }