blob: bc111b0c549ba43b8cec018c19607db8b617f11f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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.
|