-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPASSES.txt
152 lines (121 loc) · 5.58 KB
/
PASSES.txt
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
===============================================================================
Geometry Pass
-------------
All 3D geometry is rendered -> DEPTH
-> Diffuse g-buffer
-> Normals g-buffer
-> Material g-buffer
===============================================================================
Ambient Shading
---------------
Ambient level of shading is applied
DEPTH -> -> Shading
Diffuse g-buffer ->
Normals g-buffer ->
Material g-buffer ->
===============================================================================
Lighting
--------
For each light:
Subpass: Geometry
-----------------
Geometry is rendered, depth only, from perspective of the light
-> ShadowBuffer
Subpass: Shading
----------------
Shading is applied for all fragments that are illuminated
ShadowBuffer -> -> Shading
Diffuse g-buffer ->
Normals g-buffer ->
Material g-buffer ->
===============================================================================
Transparent & Far Plane
-----------------------
Transparent and far-plane graphics are rendered, and each is responsible for
its own shading.
DEPTH -> -> Shading
Diffuse g-buffer ->
Normals g-buffer ->
Material g-buffer ->
===============================================================================
Luminance Computation (outside of a renderpass)
---------------------
Luminance of each pixel is calculated to a target with auto mipmap generation
(vulkan has no auto-mipmap - use compute shader on 8x8 input blocks, do 3 levels at once)
Also look at 18.5 - image copies with scaling "vkCmdBlitImage()"
Shading -> -> Luminance Target
* Potentially we sample from a 2nd mip level of Shading, to a 1/4 size luminance
target. The first mip level will be arithmetic mean of color (not quite luminance)
but an error level we can live with.
===============================================================================
Blur-H
------
Pixels are filtered from shading, if hot enough (for bloom), and blured horizontally
(luminance value is needed here)
Shading -> -> Blur Target
* Potentially Shading can have auto-mipmap generation for 1 level only, and the
the blur target can be only 1/4 size. This saves time and space, and is doubly
used as we will want the mipmap for luminance.
===============================================================================
Blur-V
------
Pixels are sampled from Blur Target, blurred vertically and blended back
Blur Target -> -> Shading
===============================================================================
Post
----
Shading is post-processed with exposure adjustment and tonemapping
(luminance value is needed here)
Shading -> -> Swapchain Image
===============================================================================
UI
--
UI is composited/blended into swapchain image (alpha blending)
UI -> -> Swapchain Image
===============================================================================
=== GENERAL ARCHITECTURES ===============================
Forward Renderer:
-----------------
* Historic standard
* PASS1: Opaque -- render all opaque objects from front to back, including shading.
* PASS2: Transparent -- render all transparent objects from back to front.
* Draws and shades at it goes. Shading is per-object.
* May shade same pixel multiple times.
* With many dynamic lights and many fragment-reshades, a lot of draw calls and
CPU usage was required.
Deferred Renderer:
------------------
* Modern standard
* PASS1: Draw geometry data into G-Buffers
* Need diffuse, specular, and normals (normalmap and geom normals can be
packed into one RGBA8). Position can be reconstructed from z-buffer,
gl_FragCoord, and screen resolution.
(at full HD 1080p, requires 8.29 MB for each 32-bit g-buffer texture).
* PASS2: Shading as a post-process pass.
* Never shades a pixel more than once.
* Much fewer draw calls, especially with many lights, as it never shades a
pixel more than once.
* Can incorporate shadows at same time.
* Requires a lot of graphics memory and memory bandwidth for the g-buffers.
* Has difficulties with transparency and sub-surface scattering.
* MSAA is not usable (although hacks like FXAA can suffice)
* Limited to one lighting model (for whole scene)
Early-Z Testing (Forward Renderer):
-----------------------------------
* PASS1: Early-Z -- render all objects, depth buffer only
* PASS2: Opaque -- render all opaque objects from front to back, including shading.
Do not write to depth-buffer, only read it. Enable "early fragment testing".
* PASS3: Transparent -- render all transparent objects from back to front, including
shading. DO WRITE TO DEPTH BUFFER, so we can cross over transparent objects.
* Never shades a pixel more than once.
* Much less memory requirements than the deferred render.
* Lighting can still be done in a single-pass per fragment.
* Shaders are per-object, not one for the whole scene
* Must draw geometry twice: more CPU requirements.
* No issues with transparency, MSAA, etc.
Forward+ (tiled forward shading):
---------------------------------
* Early pass computes on a tile basis how many lights affect that tile.
* Then forward rendering is used, the lights computed for each fragment
are only the ones mentioned in the tile ("light culling").
* Can handle 5,000-6,000 dynamic lights.