top of page
Search

Adding a particle system to the Null Engine Part II

  • Writer: Anthon Reid
    Anthon Reid
  • Jul 1
  • 2 min read
Flame System Particles built using a 3 emitter setup
Flame System Particles built using a 3 emitter setup

Since last post, I have been working on adding texture support for the system.


Unlike my entities, where I build the instance buffer on the CPU right before flushing, I do not have access to particle instances at this stage. In fact, since the system occurs fully within the compute shader, particles are never directly interacted with on the CPU side. Because of that, I needed a different approach to tell them which textures to use.

I ended up binding all textures used this frame and passing in a separate lookup map that tells each particle which slot to sample from. With this setup, each particle can fetch the correct texture index from the lookup table and sample accordingly.


However, this method limits me to 31 unique textures per particle render call due to hardware or shader binding limits.


Once my textures started showing, I added an animation modifier to allow the use of sprite-sheet animation on the particles.


Adding texture to emitter and enabling animation modifier
Adding texture to emitter and enabling animation modifier
Editing Particle Size with Custom Curves
Editing Particle Size with Custom Curves

Once I had textures working, I turned my attention toward adding an additional emission shape.


Thinking about UE5, I wondered if I could sample the alpha values of a texture and use that as the shape of my emitter.


I basically generate a random UV and sample the texture. If that location's alpha value is greater than our threshold, then I use it as a spawn point. I also added the ability to invert the alpha mask.


t’s possible to completely reveal the outline of a texture by spawning a large number of particles.

Spawning particles using a texture as the emission shape
Spawning particles using a texture as the emission shape

With that addition, I think my particle system is complete for now, and it’s time to shift my focus to other systems.


I can think of a few ways to improve it, with bindless textures being something worth looking into down the line. But for now, the system is serviceable.


 
 
 

Comentários


bottom of page