public static class ClusterGridThe froxel grid clustered light culling bins into — the host's half of Raven/Library/Pipeline/ClusterCulling.rvn.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Every number here is duplicated from the shader, and that is not a smell to be refactored away: they are const there rather than permutations because they size an array inside a struct, and a struct's shape cannot depend on a variant while the host binds one buffer. So both sides have to agree by construction, and a test asserts they do rather than a comment asking.
A grid rather than screen tiles, which is one extra dimension for one specific problem: a 2D tile holding both a nearby wall and distant sky gets a list long enough for both, and every fragment in it pays. Slicing depth bounds that — a fragment only reads lights that reach its own slab.
The slices are exponential. A linear split spends most of its slices on distance nothing occupies; near · (far/near)^(k/n) gives every slice the same ratio of depths, which is how perspective actually distributes what a camera sees — and is invertible in closed form, so a fragment finds its slice with a logarithm instead of a search.
Fields and properties (8)
public const int TilesXTiles across the screen.
public const int TilesYTiles down it.
public const int SlicesDepth slices.
public const int CapacityHow many lights one cluster can hold.
public const int CountHow many clusters the grid has.
public static Int3 WorkgroupSizeThe workgroup size the culling shader declares.
public static Int3 GroupCountHow many workgroups a full cull dispatches.
public static long BufferSizeHow many bytes the cluster buffer needs.
Methods (8)
public static int Index(int x, int y, int slice)The flat index of a cluster, which is also its slot in the buffer.
public static float SliceDepth(int slice, float near, float far)The view-space depth at which a slice begins.
public static int SliceOf(float viewDepth, float near, float far)Which slice a view-space depth falls in — the inverse of SliceDepth.
public static float DepthOf(Vector3 positionView)How far in front of the camera a view-space position is.
public static Vector2 UvOf(Vector3 positionView, Vector2 tanHalfFov)The screen UV a view-space position projects to, as the shader computes it.
public static int Of(Vector3 positionView, Vector2 tanHalfFov, float near, float far)The cluster a shaded fragment belongs to, from its view-space position.
public static BoundingBox Bounds(int x, int y, int slice, Vector2 tanHalfFov, float near, float far)The view-space box one cluster occupies, as the culling pass builds it.
public static void Apply(ParameterCollection parameters, in RenderCamera camera, string shaderName)Writes the camera parameters that place a fragment in the grid, under one shader's names.
Used by (10)
- ArenaFrameThirdPersonShooter
- BufferTransferDeviceTestsVixen.Graphics.Golden.Tests
- ClusterCullingDeviceTestsVixen.Graphics.Golden.Tests
- ClusteredLightingTestsVixen.Rendering.Tests
- ClusteredShadingDeviceTestsVixen.Graphics.Golden.Tests
- ForwardFrameTestsVixen.Rendering.Tests
- IndexArrayVixen.Rendering
- IrradianceBounceDeviceTestsVixen.Graphics.Golden.Tests
- IrradianceShadingDeviceTestsVixen.Graphics.Golden.Tests
- SceneLightingVixen.Rendering