Particle drawing with a processor instead of a graphics processor (XNA)

I am trying to make changes to the following particle system. http://create.msdn.com/en-US/education/catalog/sample/particle_3d

I have such a function that when I click Space, all particles have their positions and speeds set to 0.

for (int i = 0; i < particles.GetLength(0); i++)  
{  
    particles[i].Position = Vector3.Zero;      
    particles[i].Velocity = Vector3.Zero;  
}

However, when I press the spacebar, the particles are still moving. If I go to FireParticleSystem.cs, I can rotate the settings. Gravity is up to 0 and the particles stop moving, but the particles are still not moving (0,0,0).

As I understand it, the problem is that the GPU processes all the positions of the particles and calculates where the particles should be based on their starting position, their initial speed and multiplying by their age. Therefore, all I managed to do was change the initial position and particle velocity, but I can’t do it on the fly, since the GPU processes everything.

I want the CPU to calculate the positions of the particles individually. This is due to the fact that later I will introduce some kind of wind to push particles around. How to stop the capture of the GPU? I think this has something to do with VertexBuffers and the draw function, but I don't know how to change it to make it work.

+3
source share
3 answers
+1

... , , / , . , , , ... , , FarSeer, . CPU.

0

I would recommend DPSF (Dynamic Particle System Framework) for this. It performs calculations on the processor, is fully customizable and very flexible, has great help in documents and tutorials, and even provides the complete source code for the FireParticleSystem from the Particle3D sample that you use. You should be able to integrate the particle system into your game and do what you want in minutes.

0
source

Source: https://habr.com/ru/post/1789298/


All Articles