Jump to content

  • Log In with Google      Sign In   
  • Create Account

Initializing particles in a particle system


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Cirno   Members   -  Reputation: 130

Like
0Likes
Like

Posted 24 May 2013 - 12:32 AM

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.



Sponsor:

#2 Jason Z   Crossbones+   -  Reputation: 5316

Like
3Likes
Like

Posted 24 May 2013 - 04:33 AM

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.



#3 Cirno   Members   -  Reputation: 130

Like
0Likes
Like

Posted 24 May 2013 - 07:15 AM

 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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS