string description = "Basic Material Static"; /************* UN-TWEAKABLES **************/ float4x4 vM; float4x4 vP; float4 inverseParams; #include "Basic_Utils.cgfx" sampler2D baseColourMap; /************* DATA STRUCTS **************/ /* data from application vertex buffer */ struct appdata { float4 position : POSITION; half3 normal : NORMAL; float2 uvs : TEXCOORD0; }; /* data passed from vertex shader to pixel shader */ struct vertexOutput { float4 position : POSITION; half3 normal : TEXCOORD0; float2 screen : TEXCOORD1; float2 uvs : TEXCOORD2; }; /*********** vertex program ******/ vertexOutput simpleVP(appdata IN) { vertexOutput OUT = (vertexOutput)0; //postion and depth OUT.position = mul(vP, float4(IN.position.xyz, 1.f)); // BM: Transform normal and tangent into object space, calculate biNormal OUT.normal = mul(vM, float4(IN.normal, 0.f)).xyz; // we never use blue anyway... OUT.screen.xy = OUT.position.zw; OUT.uvs = IN.uvs/3276.8; OUT.uvs.y = 1.f - IN.uvs.y; return OUT; } /********* fragment program ********/ void simpleFP(vertexOutput IN, out float4 colour : COLOR0, out float4 normal : COLOR1 ) { float viewDepth = inverseParams.w / ((IN.screen.x/IN.screen.y) + inverseParams.z); half specularInt = 0.0h; half specularExp = 68.h; colour = half4(tex2D(baseColourMap, IN.uvs).rgb, 0);//abs(half4(IN.uvs.x, IN.uvs.y, 0, 0));///abs(half4(IN.uvs.x, IN.uvs.y, 0, 0));// normal = half4(IN.normal.x, IN.normal.y, clamp(specularInt, 0, 0.95h) + ceil(specularExp), viewDepth); } /*************/ technique basic { pass p0 { VertexProgram = compile vp30 simpleVP(); FragmentProgram = compile fp40 simpleFP(); DepthTestEnable = true; DepthMask = true; BlendEnable = false; } } /***************************** eof ***/