VolumeManager
Per-frame volume evaluator.
- Module
- Volumes
- Header
#include "Volumes/VolumeManager.h"- Namespace
Mowo
VolumeManager owns no state of its own — it walks the world's VolumeComponent entities each call and computes a blended VolumeProfile using the camera's world position. The result is materialized into a ScenePostProcess (the renderer's existing input contract) so the existing rendering path picks up the blended values with no further changes.
Algorithm (per Evaluate call): 1. Seed the result profile from the scene's baseline ScenePostProcess (all slots marked overriding → backwards compat when no volumes exist). 2. Collect every enabled VolumeComponent + its TransformComponent. 3. Compute per-volume weight in [0,1]: - global → weight = component.weight - local → distanceToBox / blendDistance fade, multiplied by weight 4. Sort by ascending priority (lower first), so higher-priority volumes overwrite earlier slot values. 5. For each (volume, weight) pair, walk the profile's slots and merge: - bool/int/enum: snap to source when overrides && weight ≥ 0.5 - float / Vec3 : lerp current → source by weight 6. Materialize the blended profile into out.
Designed to run unconditionally each frame — when no volumes exist the cost is one ScenePostProcess copy and the world's component iterator returning empty, both negligible.
Public functions
| Returns | Name | Description |
|---|---|---|
void | Evaluate | Walk the world, compute the blended profile at cameraPos, and write the result into outPostProcess. |
VolumeProfile | EvaluateProfile | Lower-level — produces the blended VolumeProfile without writing back to a ScenePostProcess. |
void | Blend | Merge one profile's overriding slots into another at weight, with the per-type rules above. |
void | SetPreviewProfile | Editor preview. |
void | ClearPreviewProfile | |
bool | HasPreviewProfile |
Function details
Evaluate
static void Evaluate(World& world, const Vec3& cameraPos, const ScenePostProcess& seedDefaults, ScenePostProcess& outPostProcess)Walk the world, compute the blended profile at cameraPos, and write the result into outPostProcess. seedDefaults is the scene's baseline (Scene::Environment().postProcess) used as the seed so the path is backwards-compatible.
EvaluateProfile
static VolumeProfile EvaluateProfile(World& world, const Vec3& cameraPos, const VolumeProfile& seed)Lower-level — produces the blended VolumeProfile without writing back to a ScenePostProcess. Useful for tooling and tests.
Blend
static void Blend(VolumeProfile& dst, const VolumeProfile& src, float weight)Merge one profile's overriding slots into another at weight, with the per-type rules above. Public because the Volume Profile editor shows what a given blend weight resolves to, and a preview computed by a second copy of these rules is a preview of something the renderer never produces.
SetPreviewProfile
static void SetPreviewProfile(const VolumeProfile& profile)Editor preview. While a profile is set it blends LAST at full weight, above every authored volume, so an open .volume document is what the viewport shows without the author first having to place a volume around the camera. Only the editor sets this.
ClearPreviewProfile
static void ClearPreviewProfile()HasPreviewProfile
static bool HasPreviewProfile()