|
candlewick 0.10.0-4-g76c0
A tiny cross-platform renderer based on SDL3
|
Classes | |
| class | candlewick::DepthPass |
| Helper struct for depth or light pre-passes. More... | |
| struct | candlewick::ShadowPassConfig |
| class | candlewick::ShadowMapPass |
| Class for defining the shadow maps (as an atlas) and rendering into it. More... | |
| void | candlewick::renderShadowPassFromAABB (CommandBuffer &cmdBuf, ShadowMapPass &passInfo, std::span< const DirectionalLight > dirLight, std::span< const OpaqueCastable > castables, const AABB &worldAABB) |
| Render shadow pass, using provided scene bounds. | |
| void | candlewick::renderShadowPassFromFrustum (CommandBuffer &cmdBuf, ShadowMapPass &passInfo, std::span< const DirectionalLight > dirLight, std::span< const OpaqueCastable > castables, const FrustumCornersType &worldSpaceCorners) |
| Render shadow pass, using a provided world-space frustum. | |
| Mat4f | candlewick::shadowOrthographicMatrix (const Float2 &sizes, float zMin, float zMax) |
| Orthographic matrix which maps to the negative-Z half-volume of the NDC cube, for depth-testing/shadow mapping purposes. | |
passes.
When using a depth pre-pass with EQUAL depth comparison in the main pass, ensure identical vertex transformations between passes by:
Failing to do this can result in z-fighting/Moiré patterns due to floating-point precision differences between CPU and GPU matrix calculations.
SDL GPU is based on modern graphics APIs like Vulkan, which tests depths for objects located in the \(z \in [-1,0]\) half-volume of the NDC cube. This means that to get your geometry rendered to a shadow map, the light space projection matrix needs to map everything to this half-volume.
| void candlewick::renderShadowPassFromAABB | ( | CommandBuffer & | cmdBuf, |
| ShadowMapPass & | passInfo, | ||
| std::span< const DirectionalLight > | dirLight, | ||
| std::span< const OpaqueCastable > | castables, | ||
| const AABB & | worldAABB ) |
Render shadow pass, using provided scene bounds.
| cmdBuf | Command buffer |
| passInfo | Shadow map pass object |
| dirLight | Array (view) of directional lights |
| castables | Collection of shadow-casting objects |
| worldAABB | World-space scene AABB |
| void candlewick::renderShadowPassFromFrustum | ( | CommandBuffer & | cmdBuf, |
| ShadowMapPass & | passInfo, | ||
| std::span< const DirectionalLight > | dirLight, | ||
| std::span< const OpaqueCastable > | castables, | ||
| const FrustumCornersType & | worldSpaceCorners ) |
Render shadow pass, using a provided world-space frustum.
This routine creates a bounding sphere around the frustum, and compute light-space view and projection matrices which will enclose this bounding sphere within the light volume. The frustum can be obtained from the world-space camera.
Orthographic matrix which maps to the negative-Z half-volume of the NDC cube, for depth-testing/shadow mapping purposes.
This matrix maps a rectangular cuboid centered on the xy-plane and spanning from zMin to zMax in Z-direction, to the negative-Z half-volume of the NDC cube. This is useful for mapping an axis-aligned bounding-box (AABB) to an orthographic projection where the entire box is in front of the camera.
https://en.wikipedia.org/wiki/Rectangular_cuboid
| sizes | xy-plane dimensions of the cuboid/bounding box. |
| zMin | view-space Z-coordinate the box starts at, equivalent to the near argument in other routines. |
| zMax | view-space Z-coordinate the box ends at, equivalent to far in other routines. |