string description = "Simple"; /************* UN-TWEAKABLES **************/ float4x4 vM : View; float4x4 wM : World; float4x4 pM : Projection; float4x4 vP; /*********** Tweakables **********************/ float OffsetU < string UIWidget = "slider"; float UIMin = 0.0; float UIMax = 1.0; float UIStep = 0.01; > = 0.0; float OffsetV < string UIWidget = "slider"; float UIMin = 0.0; float UIMax = 1.0; float UIStep = 0.01; > = 0.0; float ScaleU < string UIWidget = "slider"; float UIMin = -1.0; float UIMax = 2.0; float UIStep = 0.01; > = 1.0; float ScaleV < string UIWidget = "slider"; float UIMin = -1.0; float UIMax = 2.0; float UIStep = 0.01; > = 1.0; /************* Textures ******************/ texture cm : Diffuse < string ResourceType = "2D"; >; sampler2D baseColourMap = sampler_state { Texture = ; MinFilter = LinearMipMapLinear; MagFilter = Linear; }; float intensity < string UIWidget = "slider"; float UIMin = 0.0; float UIMax = 10.0; float UIStep = 0.01; > = 1.0; #include "selfIllumDepth.cgfx" /************* DATA STRUCTS **************/ /* data from application vertex buffer */ struct appdata { float4 position : POSITION; half3 normal : NORMAL; half2 texCoord : TEXCOORD0; }; /* data passed from vertex shader to pixel shader */ struct vertexOutput { float4 position : POSITION; half2 texCoord : TEXCOORD0; }; /*********** vertex program ******/ vertexOutput simpleVP(appdata IN) { vertexOutput OUT = (vertexOutput)0; float4 off = float4(0,0,0,1); off = mul(wM, off); off = mul(vM, off); float4 Pos = IN.position + float4(off.xyz, 0.0f); OUT.position = mul(pM, Pos); #ifdef _PRAETORIAN_ OUT.texCoord = IN.texCoord * float2(ScaleU, ScaleV) + float2(OffsetU, -OffsetV + ScaleV); #else OUT.texCoord = IN.texCoord * float2(ScaleU, ScaleV) + float2(OffsetU, OffsetV); #endif return OUT; } /********* fragment program ********/ float4 simpleFP(vertexOutput IN) : COLOR { float4 colour = tex2D(baseColourMap, IN.texCoord); colour.rgb *= intensity; colour.rgb *= colour.a; return colour; } /*************/ technique basic < string layer = "SelfIlluminated" ; > { pass p0 { VertexProgram = compile vp30 simpleVP(); FragmentProgram = compile fp30 simpleFP(); DepthTestEnable = true; DepthMask = true; BlendEnable = true; BlendFuncSeparate = int4( DstAlpha , OneMinusSrcAlpha , Zero , One ) ; AlphaTestEnable = true; } pass selfIllumDepthPass < string layer = "SelfIlluminatedDepth" ; string excludeLayer = "PostFog" ; > { VertexProgram = compile vp30 SIDepthVP(); FragmentProgram = compile fp30 SIDepthFP(); ColorMask = bool4( false , false , false , true ); DepthTestEnable = true; DepthMask = false; BlendEnable = false; } } /***************************** eof ***/