Commit e59503c
authored
Render point and spot light shadow maps only once, regardless of the number of cameras. (#23713)
The intention has long been to render shadow maps for point and spot
lights only once, regardless of the number of views. This is reflected
in the fact that `RetainedViewEntity::auxiliary_entity` is
`Entity::PLACEHOLDER` for them. Unfortunately, this is currently
inconsistently implemented, and a separate `ExtractedView` is presently
spawned and rendered to for every point and spot light shadow map. The
behavior of these views is inconsistent because they violate the
invariant that there must only be one render-world view per
`RetainedViewEntity`.
This patch changes Bevy's behavior to spawn only one `ExtractedView` for
point and spot lights. This required some significant rearchitecting of
the render schedule because the render schedule is currently driven off
cameras. Driving the rendering off cameras is incorrect for point and
spot light shadow maps, which aren't associated with any camera.
This PR fixes the regression on the `render_layers` test in `testbed_3d`
in PR #23481, in that it renders the way it rendered before that PR.
Note, however, that the rendering isn't what may have been intended: the
shadows don't match the visible objects. That's because the shadows come
from point lights, which aren't associated with cameras, and therefore
shadows are rendered using the default set of `RenderLayers`. A future
patch may want to add flags to cameras that specify that they should
have their own point light and spot light shadow maps that inherit the
render layer (and HLOD) behavior of their associated cameras. As this
patch is fairly large, though, and because my immediate goal is to fix
the regression in #23481, I think those flags are best implemented in a
follow-up.
<img width="2564" height="1500" alt="Screenshot 2026-04-07 215221"
src="https://github.com/user-attachments/assets/2b37f35c-84e7-4473-9962-968a8cbd7619"
/>1 parent 4d9302b commit e59503c
10 files changed
Lines changed: 874 additions & 728 deletions
File tree
- crates
- bevy_core_pipeline/src
- bevy_pbr/src
- meshlet
- prepass
- render
- bevy_render/src
- batching
- texture
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
16 | | - | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
| 21 | + | |
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
| |||
108 | 111 | | |
109 | 112 | | |
110 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
111 | 124 | | |
112 | 125 | | |
113 | 126 | | |
| |||
117 | 130 | | |
118 | 131 | | |
119 | 132 | | |
120 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
121 | 136 | | |
122 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
123 | 145 | | |
124 | 146 | | |
125 | 147 | | |
126 | 148 | | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
135 | 181 | | |
136 | | - | |
137 | | - | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
138 | 186 | | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
| 187 | + | |
| 188 | + | |
151 | 189 | | |
152 | 190 | | |
153 | 191 | | |
154 | 192 | | |
155 | | - | |
| 193 | + | |
156 | 194 | | |
157 | 195 | | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
| 196 | + | |
| 197 | + | |
163 | 198 | | |
164 | 199 | | |
165 | 200 | | |
| |||
169 | 204 | | |
170 | 205 | | |
171 | 206 | | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
172 | 227 | | |
173 | 228 | | |
174 | 229 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
423 | 423 | | |
424 | 424 | | |
425 | 425 | | |
426 | | - | |
| 426 | + | |
427 | 427 | | |
428 | 428 | | |
429 | | - | |
430 | | - | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
431 | 439 | | |
432 | 440 | | |
433 | 441 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
995 | 995 | | |
996 | 996 | | |
997 | 997 | | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
998 | 1002 | | |
999 | 1003 | | |
1000 | 1004 | | |
1001 | | - | |
1002 | | - | |
1003 | | - | |
1004 | 1005 | | |
1005 | 1006 | | |
1006 | 1007 | | |
| |||
1009 | 1010 | | |
1010 | 1011 | | |
1011 | 1012 | | |
1012 | | - | |
1013 | | - | |
1014 | | - | |
1015 | 1013 | | |
1016 | 1014 | | |
1017 | 1015 | | |
| |||
1021 | 1019 | | |
1022 | 1020 | | |
1023 | 1021 | | |
1024 | | - | |
1025 | | - | |
1026 | | - | |
1027 | 1022 | | |
1028 | 1023 | | |
1029 | 1024 | | |
| |||
1188 | 1183 | | |
1189 | 1184 | | |
1190 | 1185 | | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
1191 | 1190 | | |
1192 | 1191 | | |
1193 | | - | |
1194 | | - | |
1195 | | - | |
1196 | 1192 | | |
1197 | 1193 | | |
1198 | 1194 | | |
1199 | 1195 | | |
1200 | 1196 | | |
1201 | 1197 | | |
1202 | 1198 | | |
1203 | | - | |
1204 | | - | |
1205 | | - | |
1206 | 1199 | | |
1207 | 1200 | | |
1208 | 1201 | | |
1209 | 1202 | | |
1210 | 1203 | | |
1211 | 1204 | | |
1212 | | - | |
1213 | | - | |
1214 | | - | |
1215 | 1205 | | |
1216 | 1206 | | |
1217 | 1207 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
201 | | - | |
| 201 | + | |
| 202 | + | |
202 | 203 | | |
203 | | - | |
| 204 | + | |
204 | 205 | | |
205 | 206 | | |
206 | 207 | | |
| |||
Lines changed: 10 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
| |||
47 | 46 | | |
48 | 47 | | |
49 | 48 | | |
50 | | - | |
51 | 49 | | |
52 | 50 | | |
53 | 51 | | |
| |||
194 | 192 | | |
195 | 193 | | |
196 | 194 | | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
210 | 204 | | |
211 | 205 | | |
212 | 206 | | |
| |||
0 commit comments