//shading: flat //lighting model: blinn //lighting type: directional // -------------------------------------------------------------------------------------------------- // 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; //material properties float4 cAmb : COLOR = {1, 1, 1, 1}; float4 cFog : COLOR = {0, 0, 0, 1}; //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; }; float4x4 tTex: TEXTUREMATRIX ; float3 point1, point2, gamma; float width, maxdepth; //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; float depth : TEXCOORD1; }; // -------------------------------------------------------------------------------------------------- // VERTEXSHADERS // -------------------------------------------------------------------------------------------------- vs2ps VS( float4 Pos : POSITION, float4 TexCd : TEXCOORD0, float depth : TEXCOORD1) { //inititalize all fields of output struct with 0 vs2ps Out = (vs2ps)0; //transform position float range=Pos.x+0.5; float3 curve=point1+((point2-point1)*range)+(range-pow(range,2))*gamma; curve.y+=Pos.y*width; Pos.xyz=curve; depth=saturate(maxdepth-mul(Pos,tWVP).z);//maxdepth); Out.depth=depth-(depth-pow(depth,2)); Out.Pos = mul(Pos, tWVP); //transform texturecoordinates Out.TexCd = mul(TexCd, tTex); return Out; } // -------------------------------------------------------------------------------------------------- // PIXELSHADERS: // -------------------------------------------------------------------------------------------------- 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 = cAmb; col.a=cAmb.a; if (maxdepth != 0.) { col.rgb=lerp(cFog.rgb,col.rgb,In.depth); } return col; } // -------------------------------------------------------------------------------------------------- // TECHNIQUES: // -------------------------------------------------------------------------------------------------- technique TConstant { pass P0 { //Wrap0 = U; // useful when mesh is round like a sphere VertexShader = compile vs_1_0 VS(); PixelShader = compile ps_1_0 PS(); } } technique TConstantFF { pass P0 { //transformations WorldTransform[0] = (tW); ViewTransform = (tV); ProjectionTransform = (tP); //material MaterialAmbient = {1, 1, 1, 1}; MaterialDiffuse = {1, 1, 1, 1}; //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 LightEnable[0] = TRUE; Lighting = TRUE; SpecularEnable = FALSE; LightType[0] = DIRECTIONAL; LightAmbient[0] = (cAmb); LightDiffuse[0] = {0, 0, 0, 0}; LightDirection[0] = {0, 0, 1, 1}; //shading ShadeMode = FLAT; VertexShader = NULL; PixelShader = NULL; } }