/************* UN-TWEAKABLES **************/ /*********** Tweakables **********************/ /************* Textures ******************/ /************* DATA STRUCTS **************/ /* data from application vertex buffer */ struct VFX_BasicDepthAppdata { float4 position : POSITION; float4 tangent : TEXCOORD0; float4 scale : TEXCOORD1; float4 texCoord : TEXCOORD2; }; /* data passed from vertex shader to pixel shader */ struct VFX_BasicDepthVertexOutput { float4 position : POSITION; float4 texCoord : TEXCOORD0; float4 colour : TEXCOORD1; float4 normal : TEXCOORD2; float4 screen : TEXCOORD3; float4 binormal : TEXCOORD4; }; /*********** vertex program ******/ VFX_BasicDepthVertexOutput VFX_BasicDepthVP(VFX_BasicDepthAppdata IN) { VFX_BasicDepthVertexOutput OUT = (VFX_BasicDepthVertexOutput)0; OUT.position = mul( vM, float4( IN.position.xyz, 1.f)); // Get the vertex's Index float indexf = IN.position.w / 10.0f; int index = round(indexf); // Get vertex's offsets half3 offset = offsets[index]; // Get the Opacity float opacity = IN.position.w - (index * 10.0f); // Get the Tangent (normalised in code) half3 tangent = IN.tangent.xyz; // Get the Scale half3 scale = IN.scale.xyz; // Get the Normal in view space OUT.normal.xyz = float3(0, 0, -1);//- mul(vM, float4(IN.position.xyz, 1.f)).xyz; OUT.normal.xyz = normalize(OUT.normal.xyz); // Get the binormal OUT.binormal.xyz = GetBiNormal(OUT.normal.xyz, tangent); OUT.binormal.w = scale.x; // Calculate the offsets offset *= scale; offset = ((OUT.binormal.xyz * offset.x) + (tangent.xyz * offset.y) + (OUT.normal.xyz * offset.z)); OUT.position.xyz += offset; OUT.position = mul(pM, OUT.position); OUT.texCoord.xy = IN.texCoord.xy; OUT.texCoord.z = opacity; OUT.colour.r = IN.tangent.w; OUT.colour.gb = IN.texCoord.zw; // we never use blue anyway... OUT.screen = OUT.position; // pack the tangent OUT.texCoord.w = tangent.x; OUT.colour.w = tangent.y; OUT.normal.w = tangent.z; return OUT; } /********* fragment program ********/ void VFX_BasicDepthFP(VFX_BasicDepthVertexOutput IN, out float4 colour : COLOR0) { half4 texColour = tex2D(baseColourMap, IN.texCoord.xy); texColour.a *= IN.texCoord.z; if(texColour.a <= 0.01f) discard; colour = float4(0.f); } /*************/ /***************************** eof ***/