sampler2D spriteTex; float4x4 wM; float4 colour; float2 corners[4]; float4 animData1; // Fade and rotate animation data float4 animData2; // Keyframed animation data struct vertexOutput { float4 oPosition : POSITION; float2 oTexCoord : TEXCOORD0; }; vertexOutput spriteVS( float3 position : POSITION) { vertexOutput OUT = (vertexOutput)0; int posIndex = floor(position.z); OUT.oPosition.xy = corners[posIndex]; OUT.oPosition.zw = float2(0.f, 1.f); OUT.oTexCoord = position.xy; OUT.oTexCoord.y = -OUT.oTexCoord.y; OUT.oPosition = mul(wM, OUT.oPosition); // animData2.x This is the number of frames of animation // animData2.y This is the index of the row for this animation // animData2.z This is the width of each frame (0.0 - 1.0) ie. 1.0 / number of frames in the animation // animData2.w This is the height of each frame (0.0 - 1.0) ie. 1.0 / number of rows in the texture float texCoordX = (animData2.x * animData2.z) + (position.x * animData2.z); float texCoordY = (animData2.y * animData2.w) + (-position.y * animData2.w); OUT.oTexCoord = float2(texCoordX, texCoordY); return OUT; } float4 spritePS( vertexOutput IN ) : COLOR0 { float4 final = tex2D(spriteTex, IN.oTexCoord) * colour; final.a = final.a;// * animData1.a; return final; } technique loadingScreen { pass p0 { VertexProgram = compile arbvp1 spriteVS(); FragmentProgram = compile arbfp1 spritePS(); AlphaTestEnable = true; DepthTestEnable = true; DepthMask = true; BlendEnable = true; BlendFunc = int2(SrcAlpha, InvSrcAlpha); } }