// Camera Parameters float4x4 View; float4x4 Projection; // Particle texture and sampler. texture Texture; sampler Sampler = sampler_state { Texture = (Texture); MinFilter = Linear; MagFilter = Linear; MipFilter = Point; AddressU = Clamp; AddressV = Clamp; }; // Vertex shader input structure specifies the position, size, and // color of the particle, plus a 2x2 rotation matrix (packed into // a float4 value because we don't have enough color interpolators // to send this directly as a float2x2). struct VertexShaderInput { float3 Position : POSITION0; float2 Size : PSIZE0; float4 Color : COLOR0; }; // Vertex shader output structure specifies the position, size, and // color of the particle, plus a 2x2 rotation matrix (packed into // a float4 value because we don't have enough color interpolators // to send this directly as a float2x2). struct VertexShaderOutput { float4 Position : POSITION0; float Size : PSIZE0; float4 Color : COLOR0; }; // Custom vertex shader animates particles entirely on the GPU. VertexShaderOutput VertexShader(VertexShaderInput input) { VertexShaderOutput output; // Compute the particle position, size, color, and rotation. output.Position = mul(mul(float4(input.Position, 1), View), Projection); float size = lerp(input.Size.x, input.Size.y, (input.Size.x + input.Size.y)/2); if (output.Position.z <= 1) { output.Size = size; } else { output.Size = size * sqrt(1 / output.Position.z); } output.Color = input.Color; return output; } // Pixel shader input structure for particles that do not rotate. struct NonRotatingPixelShaderInput { float4 Color : COLOR0; #ifdef XBOX float2 TextureCoordinate : SPRITETEXCOORD; #else float2 TextureCoordinate : TEXCOORD0; #endif }; // Pixel shader for drawing particles that do not rotate. float4 NonRotatingPixelShader(NonRotatingPixelShaderInput input) : COLOR0 { return tex2D(Sampler, input.TextureCoordinate) * input.Color; } technique Technique1 { pass Pass1 { // TODO: set renderstates here. VertexShader = compile vs_1_1 VertexShader(); PixelShader = compile ps_1_1 NonRotatingPixelShader(); } }