candlewick 0.1.0
A renderer
|
Classes | |
class | candlewick::DepthPass |
Helper struct for depth or light pre-passes. More... | |
class | candlewick::ShadowMapPass |
Helper struct for shadow mapping pass. More... | |
void | candlewick::renderShadowPassFromAABB (CommandBuffer &cmdBuf, ShadowMapPass &passInfo, const DirectionalLight &dirLight, std::span< const OpaqueCastable > castables, const AABB &worldSceneBounds) |
Render shadow pass, using provided scene bounds. | |
void | candlewick::renderShadowPassFromFrustum (CommandBuffer &cmdBuf, ShadowMapPass &passInfo, 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, | ||
const DirectionalLight & | dirLight, | ||
std::span< const OpaqueCastable > | castables, | ||
const AABB & | worldSceneBounds ) |
Render shadow pass, using provided scene bounds.
The scene bounds are in world-space.
void candlewick::renderShadowPassFromFrustum | ( | CommandBuffer & | cmdBuf, |
ShadowMapPass & | passInfo, | ||
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. |