summaryrefslogtreecommitdiff
path: root/doc/lighting.md
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2026-02-13 10:27:58 -0800
committer3gg <3gg@shellblade.net>2026-02-13 10:27:58 -0800
commit77f9dbee1721518e09f0beed10b3dbb78d893b08 (patch)
treeb9b26485ef1cff497867e120ae27428c6f82c029 /doc/lighting.md
parent5f7855b6aa0e3338625eb7d30e8ccc5b74050bbf (diff)
Ambient lighting. Defer texture filtering
Diffstat (limited to 'doc/lighting.md')
-rw-r--r--doc/lighting.md64
1 files changed, 64 insertions, 0 deletions
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 @@
1# Lighting
2
3## Forward
4
5```
6for each triangle:
7 for each pixel:
8 for each light:
9 shade(pixel, light)
10```
11
12- Overdraw penalty.
13- Client must specify all lights (for the object) up front.
14
15## Deferred
16
17### Forward Pass
18
19The forward pass generates:
20- Depth
21- Texture ID
22- Texture coordinates
23
24Sampling of textures is deferred to avoid overdraw penalty.
25
26### Pixel-centric Shading
27
28```
29for each pixel:
30 for each light:
31 shade(pixel, light)
32```
33
34- Need a pixel-in-volume test.
35- Inefficient if most pixels are not affected by a light.
36 - Ok: ambient, directional.
37 - Bad: point, area.
38
39### Light-centric Shading
40
41```
42for each light:
43 volume <- project light volume
44 for each pixel in volume:
45 shade(pixel, light)
46```
47
48- Need to project the light volume.
49- Shades only the pixels that are covered by the volume.
50- For ambient and directional, the volume is all space.
51
52## Clustered
53
54### Cluster Generation
55
56```
57for each light:
58 volume <- project light volume to NDC
59 for each cluster:
60 test(cluster, volume)
61```
62
63- Need a volume-AABB test (the cluster is an AABB in NDC space.)
64- Lighting then proceeds as in deferred.