ParticleRenderer
Abstract CPU particle renderer interface. The concrete backend (RHIParticleRenderer) is implemented on the Platform/ RHI API (Shader/Pipeline/VertexBuffer/DescriptorSet) and draws into an off-screen target via SetTargetFramebuffer. The GPU-compute path lives separately in GPUParticleRenderer.
- Module
- Particles
- Header
#include "Particles/ParticleRenderer.h"- Namespace
Mowo
Constructors
| Signature | Name | Description |
|---|---|---|
virtual ~ParticleRenderer() = default | ~ParticleRenderer |
Public functions
| Returns | Name | Description |
|---|---|---|
bool | Initialize | |
void | Shutdown | |
void | SetTargetFramebuffer | Off-screen target the renderer draws into (set before Initialize). |
void | SetBatchState | Open (or reuse) the batch subsequent AddParticle calls append to. |
void | AddParticle | Add a single particle quad to the current batch. |
FQuadSpan | ReserveQuads | |
void | WriteQuad | |
void | Render | |
void | RenderWithDS | Render with an externally-owned depth descriptor set (caller binds the scene depth) — backend-agnostic surface used by SceneRenderer so it never downcasts to the concrete backend. |
Ref<DescriptorSet> | AllocateDepthDS | |
Ref<Sampler> | GetNearestSampler | |
void | SetDepthLinearizeParams | Coefficients that turn an NDC depth back into a view-space distance, taken from the projection matrix: (m22, m23, m32, m33). |
void | Clear | |
void | EndFrame | Swap buffers for double-buffering (call at end of frame) |
bool | HasData | |
ParticleRenderer* | Create | Factory — returns the RHI-generic backend (RHIParticleRenderer). |
void | Destroy |
Function details
~ParticleRenderer
virtual ~ParticleRenderer() = defaultInitialize
virtual bool Initialize(const std::string& vfsShaderPath) = 0Shutdown
virtual void Shutdown() = 0SetTargetFramebuffer
virtual void SetTargetFramebuffer(const FramebufferSpecification& spec) = 0Off-screen target the renderer draws into (set before Initialize).
SetBatchState
void SetBatchState(const Ref<Image2D>& texture, ParticleBlendMode blend, bool depthTest, float softFadeDistance)Open (or reuse) the batch subsequent AddParticle calls append to.
AddParticle
void AddParticle(const Vec3& position, const Vec3& right, const Vec3& up, const Vec4& color, const Vec2& uvMin, const Vec2& uvSize)Add a single particle quad to the current batch. right and up are pre-scaled by half-size; uvMin/uvSize select the flipbook cell.
ReserveQuads
FQuadSpan ReserveQuads(uint32_t count)WriteQuad
void WriteQuad(const FQuadSpan& span, uint32_t quad, const Vec3& position, const Vec3& right, const Vec3& up, const Vec4& color, const Vec2& uvMin, const Vec2& uvSize)Render
virtual void Render(const Mat4& viewProjection, bool depthTest) = 0RenderWithDS
virtual void RenderWithDS(const Mat4& viewProjection, Ref<DescriptorSet> depthDS, uint32_t viewportWidth, uint32_t viewportHeight) = 0Render with an externally-owned depth descriptor set (caller binds the scene depth) — backend-agnostic surface used by SceneRenderer so it never downcasts to the concrete backend.
AllocateDepthDS
virtual Ref<DescriptorSet> AllocateDepthDS(const std::string& debugName) = 0GetNearestSampler
virtual Ref<Sampler> GetNearestSampler() const = 0SetDepthLinearizeParams
void SetDepthLinearizeParams(const Vec4& params)Coefficients that turn an NDC depth back into a view-space distance, taken from the projection matrix: (m22, m23, m32, m33). Without them the soft-particle fade has no way to work in world units.
Clear
void Clear()EndFrame
void EndFrame()Swap buffers for double-buffering (call at end of frame)
HasData
bool HasData() constCreate
static ParticleRenderer* Create()Factory — returns the RHI-generic backend (RHIParticleRenderer).
Destroy
static void Destroy(ParticleRenderer* renderer)