From 77f9dbee1721518e09f0beed10b3dbb78d893b08 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Fri, 13 Feb 2026 10:27:58 -0800 Subject: Ambient lighting. Defer texture filtering --- doc/lighting.md | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 doc/lighting.md (limited to 'doc/lighting.md') diff --git a/doc/lighting.md b/doc/lighting.md new file mode 100644 index 0000000..bc111b0 --- /dev/null +++ b/doc/lighting.md @@ -0,0 +1,64 @@ +# Lighting + +## Forward + +``` +for each triangle: + for each pixel: + for each light: + shade(pixel, light) +``` + +- Overdraw penalty. +- Client must specify all lights (for the object) up front. + +## Deferred + +### Forward Pass + +The forward pass generates: +- Depth +- Texture ID +- Texture coordinates + +Sampling of textures is deferred to avoid overdraw penalty. + +### Pixel-centric Shading + +``` +for each pixel: + for each light: + shade(pixel, light) +``` + +- Need a pixel-in-volume test. +- Inefficient if most pixels are not affected by a light. + - Ok: ambient, directional. + - Bad: point, area. + +### Light-centric Shading + +``` +for each light: + volume <- project light volume + for each pixel in volume: + shade(pixel, light) +``` + +- Need to project the light volume. +- Shades only the pixels that are covered by the volume. +- For ambient and directional, the volume is all space. + +## Clustered + +### Cluster Generation + +``` +for each light: + volume <- project light volume to NDC + for each cluster: + test(cluster, volume) +``` + +- Need a volume-AABB test (the cluster is an AABB in NDC space.) +- Lighting then proceeds as in deferred. -- cgit v1.2.3