Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
GpuParticles.hpp File Reference

Particles simulated by a compute kernel, drawn from the buffer the kernel wrote (WebGPU). More...

#include "../../core/Types.hpp"
#include "../graph/RenderGraph.hpp"
#include "../rhi/GfxEnums.hpp"
#include "../../math/Math.hpp"
#include <unordered_map>
#include <vector>
Include dependency graph for GpuParticles.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  esengine::GpuParticles

Namespaces

namespace  esengine
namespace  esengine::ecs
namespace  esengine::particle

Detailed Description

Particles simulated by a compute kernel, drawn from the buffer the kernel wrote (WebGPU).

An emitter that asks for it keeps its particles in a ring of GPU slots: a state buffer the kernel advances and an instance buffer it writes in the layout the particle draw already reads. The CPU decides only how many are born and how long the step is, so what costs a CPU emitter per particle per frame costs this one a dispatch: hundreds of thousands of particles are an ordinary emitter. Nothing is read back; the draw binds the instance buffer as it lies, which is why a storage buffer here is also a vertex buffer.

One compute pass per frame, declared into the render graph ahead of the scene pass it feeds. It carries every emitter the frame's collect asked to step, each with its own block of parameters.

It can collide with what the camera last saw (the depth a frame leaves is copied where next frame's kernel can read it, with the view it was seen by) and with the distance functions of ParticleCollider. It can tell other kernels: what an emitter fires is appended to a buffer, and a child emitter's kernel spawns from it with no trip to the CPU.

What it is not: the particles are not sorted (an additive or cut-out look is exact, a deep alpha-blended pile draws in slot order), and a scene query is not something a kernel can ask. Where the device cannot compute, ParticleSystem simulates the same emitter on the CPU, capped.

Definition in file GpuParticles.hpp.