summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/lighting.md64
-rw-r--r--doc/pipeline.txt15
-rw-r--r--doc/triangle-pipeline.txt27
3 files changed, 106 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.
diff --git a/doc/pipeline.txt b/doc/pipeline.txt
new file mode 100644
index 0000000..75bd69e
--- /dev/null
+++ b/doc/pipeline.txt
@@ -0,0 +1,15 @@
1@startuml
2:G-buffer;
3fork
4 :Depth;
5fork again
6 :Normal;
7fork again
8 :Tex coords;
9fork again
10 :Tex ID;
11end fork
12:Lighting;
13:Tone map;
14:Gamma correct;
15@enduml
diff --git a/doc/triangle-pipeline.txt b/doc/triangle-pipeline.txt
new file mode 100644
index 0000000..064cf5d
--- /dev/null
+++ b/doc/triangle-pipeline.txt
@@ -0,0 +1,27 @@
1@startuml
2:Triangles;
3:Vertices;
4if (Vertex cache?) then (hit)
5 :Load vertex;
6else (miss)
7 :Transform & Store vertex;
8endif
9:Transformed triangle (clip space);
10:Clip;
11:2D triangles;
12:Backface cull;
13:Rasterize;
14:Pixels;
15if (Depth test?) then (pass)
16 if (Alpha mask?) then (opaque)
17 :Write pixel;
18 else (transparent)
19 :Discard;
20 stop
21 endif
22else (fail)
23 :Discard;
24 stop
25endif
26stop
27@enduml