Skip to main content
GameDev.net gamedev.net
🔒 Locked

Initializing particles in a particle system

Started by Cirno May 24, 2013 at 6:32 AM 1 replies 2.3k views
Original Post
Cirno
Cirno

Hi everyone.

I am working on a particle system with HLSL on XNA Framework. The properties of the particles are stored in several textures. Now I find it hard to initialize a particle(set its property at the beginning or reset its property when it is added to the stage again). It is not easy to get a random number in HLSL and setting the color of a single pixel(to reset the property of a new-added particle) in a texture is inconvenient.So are there any other good solutions?

Thanks.

Jason Z
Jason Z

The random number can be obtained by having a 'random' texture and applying an offset to the texture coordinates used to look it up based on time. So over time the random value supplied to each pixel will change. You can then determine what size of texture works best for you, and how fast the offset should wrap around.

As long as you are capable to get a draw call that can be used to select the appropriate pixels to get executed in the pixel shader, you should be able to use this technique to add or reinitialize particles.

Jason Zink :: DirectX MVP   Direct3D 11 engine on CodePlex: Hieroglyph 3 Direct3D Books: 
Cirno
Cirno

applying an offset to the texture coordinates used to look it up based on time

This is the point. I thought that a 'random' texture can only give one pixel a particular 'random' value, but with the offset we can 'generate' some random values for a pixel.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.