November 2008
Beginner
510 pages
16h 24m
English
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.

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 tex2D( ...