Friday 29 June 2012

3D Scaled PointSprite Particles



Well as mentioned in my previous post, here is the 3D particle system again only this time the particles are scaled. Now I didn't think that you could scale pointsprites, but it turns out you can :P

I found out after going to an XNA meeting set up by the .NET Developer Network, a friend of mine, Dave, was giving a talk there and so I tagged along and was interested to see another speaker, Peter McGann, describing his game being demoed and as he was talking us through it he happened to mention that his particles were point sprite particles and I noticed they were being scaled, so I asked how he was doing it and he said he would mail me the shader. In the mean time I got home, and me being me wanted to know how it was done so mailed Leaf, who sent me almost an identical chunk of code as Peter McGann then sent me.

So thanks to both of you for showing me how this is done.

Basically you need to set up a parameter in your vertex shader return structure that tells the hardware to scale the point sprites, this is done with the PSIZE semantic. In the vertex shader you can then calculate the size the given particle needs to be. In my shader I have set a default particle size that can be altered by passing in a new value as well as the height of the view port.

You will find 4 projects in the download, 2 for XNA 1.0 Refresh with one being for the PC the other for the XBox and the same again for XNA 2.0

3D Scaled PointSprite Particles

No comments:

Post a Comment