GPUParticleRenderer
Abstract GPU particle renderer interface Manages compute simulation + billboard rendering for GPU-driven particle emitters.
- Module
- Particles
- Header
#include "Particles/GPUParticleRenderer.h"- Namespace
Mowo
Constructors
| Signature | Name | Description |
|---|---|---|
virtual ~GPUParticleRenderer() = default | ~GPUParticleRenderer |
Public functions
| Returns | Name | Description |
|---|---|---|
bool | Initialize | |
void | Shutdown | |
void | SetTargetFramebuffer | Off-screen target the render pipelines build against (set before Initialize). |
EmitterState* | CreateEmitterState | Create GPU state for an emitter with given max particle count |
void | DestroyEmitterState | |
void | EmitParticles | Move particles the CPU spawned (through the emitter's spawn modules) into the pool: dead slot → particle → alive list. |
void | PrepareSimulation | Snapshot the alive count and clear the indirect draw args (call BEFORE Simulate). |
void | Simulate | Dispatch compute simulation (call OUTSIDE render pass) |
void | ComputeBarrier | Compute→compute barrier between the prepare and simulate passes. |
void | InsertBarrier | Insert compute→graphics barrier (call after all Simulate, before render pass) |
void | ResetStaging | |
void | StageEmit | |
void | StageExpressions | The emitter's update scripts for this frame (layout: see Particles/GPUParticleExpression.comp.hlsl), run on its live particles after the simulate pass and before the sort. |
bool | SupportsExpressions | False when the expression pass could not be built (shader missing). |
void | StageSim | sortBackToFront orders the alive list far-to-near from the sim params' camera after the simulate pass; alpha-blended emitters need it, additive ones are order-independent and skip the cost. |
void | RecordStagedSimulation | |
void | BeginFrame | Per-frame render submission: clear, record the emitters to draw, query. |
void | SubmitEmitter | |
bool | HasSubmissions | |
void | UpdateDepthImage | Scene depth for the manual depth test / soft fade, and the fog the billboards are drawn through (call BEFORE the render pass). |
void | SetCollisionField | Bind the collision field's textures for the simulate pass (call before the world tick that drives Simulate). |
void | RenderSubmitted | Draw every submitted emitter (call INSIDE the render pass). |
bool | IsInitialized |
Function details
~GPUParticleRenderer
virtual ~GPUParticleRenderer() = defaultInitialize
virtual bool Initialize() = 0Shutdown
virtual void Shutdown() = 0SetTargetFramebuffer
virtual void SetTargetFramebuffer(const FramebufferSpecification& spec) = 0Off-screen target the render pipelines build against (set before Initialize).
CreateEmitterState
virtual EmitterState* CreateEmitterState(uint32_t maxParticles) = 0Create GPU state for an emitter with given max particle count
DestroyEmitterState
virtual void DestroyEmitterState(EmitterState* state) = 0EmitParticles
virtual void EmitParticles(EmitterState* state, const GPUParticle* particles, uint32_t count, const Vec4* custom = nullptr) = 0Move particles the CPU spawned (through the emitter's spawn modules) into the pool: dead slot → particle → alive list. custom carries each new particle's custom attributes (null = all zero).
PrepareSimulation
virtual void PrepareSimulation(EmitterState* state) = 0Snapshot the alive count and clear the indirect draw args (call BEFORE Simulate).
Simulate
virtual void Simulate(EmitterState* state, const GPUParticleSimParams& simParams) = 0Dispatch compute simulation (call OUTSIDE render pass)
ComputeBarrier
virtual void ComputeBarrier() = 0Compute→compute barrier between the prepare and simulate passes.
InsertBarrier
virtual void InsertBarrier() = 0Insert compute→graphics barrier (call after all Simulate, before render pass)
ResetStaging
virtual void ResetStaging() = 0StageEmit
virtual void StageEmit(EmitterState* state, const GPUParticle* particles, uint32_t count, const Vec4* custom = nullptr) = 0StageExpressions
virtual void StageExpressions(EmitterState* state, const uint32_t* words, uint32_t wordCount, const Vec3& emitterPos, float deltaTime) = 0The emitter's update scripts for this frame (layout: see Particles/GPUParticleExpression.comp.hlsl), run on its live particles after the simulate pass and before the sort.
SupportsExpressions
virtual bool SupportsExpressions() const = 0False when the expression pass could not be built (shader missing).
StageSim
virtual void StageSim(EmitterState* state, const GPUParticleSimParams& simParams, bool sortBackToFront) = 0sortBackToFront orders the alive list far-to-near from the sim params' camera after the simulate pass; alpha-blended emitters need it, additive ones are order-independent and skip the cost.
RecordStagedSimulation
virtual void RecordStagedSimulation() = 0BeginFrame
virtual void BeginFrame() = 0Per-frame render submission: clear, record the emitters to draw, query.
SubmitEmitter
virtual void SubmitEmitter(EmitterState* state, const GPURenderEmitterParams& params) = 0HasSubmissions
virtual bool HasSubmissions() const = 0UpdateDepthImage
virtual void UpdateDepthImage(Ref<Image2D> depthImage, const FParticleFogInputs& fog) = 0Scene depth for the manual depth test / soft fade, and the fog the billboards are drawn through (call BEFORE the render pass).
SetCollisionField
virtual void SetCollisionField(Ref<Image3D> sdf, Ref<Image2D> depth) = 0Bind the collision field's textures for the simulate pass (call before the world tick that drives Simulate). Null textures bind dummies; the per-emitter collision params ride in GPUParticleSimParams and gate whether an emitter samples them at all.
RenderSubmitted
virtual void RenderSubmitted(const Mat4& viewProjection, const Vec3& cameraPos, const Vec4& depthLinearize, uint32_t viewportWidth, uint32_t viewportHeight) = 0Draw every submitted emitter (call INSIDE the render pass). depthLinearize is the projection's (m22, m23, m32, m33), matching the CPU soft-particle fade.
IsInitialized
virtual bool IsInitialized() const = 0