Adding a Particle Effect File

First, you'll want to create a folder for your effects. Right-click the Content node in Solution Explorer and select Add → New Folder. Name the folder Effects. Then, right-click the new Content\Effects folder and select Add → New Item.... Select the Effect File template on the right side of the window and name the file Particle.fx, as shown in Figure 14-3.

Creating a new effect file for your particles

Figure 14-3. Creating a new effect file for your particles

Replace all of the code in your new Particle.fx file with the following effect code:

float4x4 WorldViewProjection; Texture theTexture; sampler ColoredTextureSampler = sampler_state { texture = <theTexture> ; magfilter = LINEAR; minfilter = LINEAR; mipfilter= POINT; AddressU = Clamp; AddressV = Clamp; }; struct VertexShaderInput { float4 Position : POSITION0; float2 textureCoordinates : TEXCOORD0; float pointSize : PSIZE0; }; struct VertexShaderOutput { float4 Position : POSITION0; float2 textureCoordinates : TEXCOORD0; float pointSize : PSIZE0; }; struct PixelShaderInput { float2 textureCoordinates : TEXCOORD0; }; VertexShaderOutput VertexShaderFunction(VertexShaderInput input) { VertexShaderOutput output; output.Position = mul(input.Position, WorldViewProjection); output.textureCoordinates = input.textureCoordinates; output.pointSize = input.pointSize; return output; } float4 PixelShaderFunction(PixelShaderInput input) : COLOR0 { return ...

Get Learning XNA 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.