string description = "Basic Depth Only Material"; /************* UN-TWEAKABLES **************/ float4x4 wM; float4x4 vP; /*********** Tweakables **********************/ float uvTileBase < string UIWidget = "slider"; float UIMin = 0.0; float UIMax = 5.0; float UIStep = 0.01; > = 1.0; /************* Textures ******************/ sampler2D baseColourMap; sampler2D alphaStipple; /************* DATA STRUCTS **************/ /* data from application vertex buffer */ struct appdata { float4 position : POSITION; float2 texCoord : TEXCOORD0; }; /* data passed from vertex shader to pixel shader */ struct vertexOutput { float4 position : POSITION; float2 texCoord : TEXCOORD0; float4 screen : TEXCOORD1; }; /*********** vertex program ******/ vertexOutput simpleVP(appdata IN) { vertexOutput OUT = (vertexOutput)0; OUT.position = mul(wM, IN.position); OUT.position = mul(vP, OUT.position); OUT.screen = OUT.position; OUT.texCoord.xy = IN.texCoord * uvTileBase; return OUT; } /********* fragment program ********/ void simpleFP(vertexOutput IN, out float4 colour : COLOR0) { half4 texColour = tex2D(baseColourMap, IN.texCoord.xy); const float2 targetDimensions = float2(1024.f, 1024.f); const float2 stippleDimensions = float2(128.f, 128.f); float2 texCoord = ((IN.screen.xy/IN.screen.w) + 1.f.xx) * 0.5h.xx; half4 mask = tex2D(alphaStipple, texCoord.xy * (targetDimensions / stippleDimensions) ); if(texColour.a < mask.a) discard; /* int tile = int(1.f/texColour.a); int2 sample = texCoord.xy * targetDimensions; // use floats and round to reduce error? int2 tileIndices = int2(sample.x %tile, sample.y %tile); if((tileIndices.x != 0) || (tileIndices.y != 0)) discard; */ colour = float4(0.f); } /*************/ technique basic { pass p0 { VertexProgram = compile vp20 simpleVP(); FragmentProgram = compile fp20 simpleFP(); DepthTestEnable = true; DepthMask = true; ColorMask = bool4( false , false , false , false ); BlendEnable = false; AlphaTest = false; CullFaceEnable = false; } } /***************************** eof ***/