Skip to Main Content
Learning XNA 3.0
book

Learning XNA 3.0

by Aaron Reed
November 2008
Beginner content levelBeginner
510 pages
16h 24m
English
O'Reilly Media, Inc.
Content preview from Learning XNA 3.0

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 tex2D( ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning XNA 4.0

Learning XNA 4.0

Aaron Reed
Beginning C# 7 Programming with Visual Studio 2017

Beginning C# 7 Programming with Visual Studio 2017

Benjamin Perkins, Jacob Vibe Hammer, Jon D. Reid

Publisher Resources

ISBN: 9780596154905Supplemental ContentErrata Page