diff options
Diffstat (limited to 'doc/lighting.md')
| -rw-r--r-- | doc/lighting.md | 64 |
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 | ``` | ||
| 6 | for 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 | |||
| 19 | The forward pass generates: | ||
| 20 | - Depth | ||
| 21 | - Texture ID | ||
| 22 | - Texture coordinates | ||
| 23 | |||
| 24 | Sampling of textures is deferred to avoid overdraw penalty. | ||
| 25 | |||
| 26 | ### Pixel-centric Shading | ||
| 27 | |||
| 28 | ``` | ||
| 29 | for 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 | ``` | ||
| 42 | for 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 | ``` | ||
| 57 | for 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. | ||
