View Full Version : GPU/Game Particles

12 December 2007, 08:52 AM
I'm doing some effects work for an XBLA game. I've decided to make my own particle emitter with maxScript, using a shader from an XNA sample.

The easy part is, the particles completely animate on the GPU. I need to pass in some constants, which I am doing in the material editor (with a scripted material plugin but that doesn't really matter). That is easily done.

The difficult part is having to pass in the per-"sprite" data. These particles would be point sprites in the game engine, and AFAIK Max has no equivalent approximation of point sprites. I need to pass in, per sprite or vertex (interchangable in this case): initial position, initial velocity, a float3/color random value, and the time of creation.

My question is, how can I possibly store this info in each vertex and access it in the shader?
The data I know I can pass in is Tangent, Binormal, Texcoord (U, V, and W if I want), and Vertex Color/Alpha (though I'd rather not on this one since it requires some max map channel workarounds).

Position I can pass in as position and I can pass in the velocity as the normal. Easy enough and currently being done.

Binormals and tangents are dependent upon the UV coordinates. This means that I don't see how it is possible to use binormals and tangents to pass info, unless I can set them explicitly somehow, because to change them would require changing other UV coords and I would lose arbitrary control.

I can use UVW to pass in these values, I guess. I can just use W as time and have a float2 as the random value. Question/problem is, how can I set up the texture coords per-vertex? I know texture verts don't map up to mesh verts. Just now reading the help I came across the "Understanding Texture Coordinates and Vertex Colors", has anyone done anything similar and do they have a function they would share for "Finding the corresponding vertices" as per the help? Does this sound like a reasonable plan? I won't have time to try it until tonight and this post helped clear up my thoughts, so I may as well see if anyone has anything to say.

CGTalk Moderation
12 December 2007, 08:52 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.