// -------------------------------------------------------------------------------------------------- // PARAMETERS: // -------------------------------------------------------------------------------------------------- //transforms float4x4 tW: WORLD; //the models world matrix float4x4 tV: VIEW; //view matrix as set via Renderer (EX9) float4x4 tP: PROJECTION; //projection matrix as set via Renderer (EX9) float4x4 tWVP: WORLDVIEWPROJECTION; //texture texture Tex ; sampler Samp = sampler_state //sampler for doing the texture-lookup { Texture = (Tex); //apply a texture to the sampler MipFilter = LINEAR; //sampler states MinFilter = LINEAR; MagFilter = LINEAR; }; //define some input pins float param1; float param2; //texture transformation marked with semantic TEXTUREMATRIX to achieve symmetric transformations float4x4 tTex: TEXTUREMATRIX ; //the data structure: "vertexshader to pixelshader" //used as output data with the VS function //and as input data with the PS function struct vs2ps { float4 Pos : POSITION; float4 TexCd : TEXCOORD0; }; // -------------------------------------------------------------------------------------------------- // VERTEXSHADERS // -------------------------------------------------------------------------------------------------- vs2ps VS( float4 Pos : POSITION, float4 TexCd : TEXCOORD0) { //inititalize all fields of output struct with 0 vs2ps Out = (vs2ps)0; //transform position Out.Pos = mul(Pos, tWVP); //transform texturecoordinates Out.TexCd = mul(TexCd, tTex); return Out; } // -------------------------------------------------------------------------------------------------- // PIXELSHADERS: // -------------------------------------------------------------------------------------------------- float4 col : Color; float4 PS(vs2ps In): COLOR { //In.TexCd = In.TexCd / In.TexCd.w; // for perpective texture projections (e.g. shadow maps) ps_2_0 float4 col = tex2D(Samp, In.TexCd); return col; } float4 PS2(vs2ps In): COLOR { //In.TexCd = In.TexCd / In.TexCd.w; // for perpective texture projections (e.g. shadow maps) ps_2_0 float4 col = tex2D(Samp, In.TexCd); return col; } // -------------------------------------------------------------------------------------------------- // TECHNIQUES: // -------------------------------------------------------------------------------------------------- technique TMyShader1 { pass P0 { //Wrap0 = U; // useful when mesh is round like a sphere VertexShader = compile vs_1_1 VS(); PixelShader = compile ps_1_0 PS(); } } technique TMyShader2 { pass P0 { //Wrap0 = U; // useful when mesh is round like a sphere VertexShader = compile vs_1_1 VS(); PixelShader = compile ps_1_4 PS2(); } } technique TFixedFunctionPipeline { pass P0 { //transforms WorldTransform[0] = (tW); ViewTransform = (tV); ProjectionTransform = (tP); //texturing Sampler[0] = (Samp); TextureTransform[0] = (tTex); TexCoordIndex[0] = 0; TextureTransformFlags[0] = COUNT4 | PROJECTED; //Wrap0 = U; // useful when mesh is round like a sphere Lighting = FALSE; //shaders VertexShader = NULL; PixelShader = NULL; } }