@@ -36,8 +36,10 @@ pub mod graph {
36
36
37
37
pub struct SolariLightingNode {
38
38
bind_group_layout : BindGroupLayout ,
39
- initial_and_temporal_pipeline : CachedComputePipelineId ,
40
- spatial_and_shade_pipeline : CachedComputePipelineId ,
39
+ di_initial_and_temporal_pipeline : CachedComputePipelineId ,
40
+ di_spatial_and_shade_pipeline : CachedComputePipelineId ,
41
+ gi_initial_and_temporal_pipeline : CachedComputePipelineId ,
42
+ gi_spatial_and_shade_pipeline : CachedComputePipelineId ,
41
43
}
42
44
43
45
impl ViewNode for SolariLightingNode {
@@ -72,8 +74,10 @@ impl ViewNode for SolariLightingNode {
72
74
let previous_view_uniforms = world. resource :: < PreviousViewUniforms > ( ) ;
73
75
let frame_count = world. resource :: < FrameCount > ( ) ;
74
76
let (
75
- Some ( initial_and_temporal_pipeline) ,
76
- Some ( spatial_and_shade_pipeline) ,
77
+ Some ( di_initial_and_temporal_pipeline) ,
78
+ Some ( di_spatial_and_shade_pipeline) ,
79
+ Some ( gi_initial_and_temporal_pipeline) ,
80
+ Some ( gi_spatial_and_shade_pipeline) ,
77
81
Some ( scene_bindings) ,
78
82
Some ( viewport) ,
79
83
Some ( gbuffer) ,
@@ -82,8 +86,10 @@ impl ViewNode for SolariLightingNode {
82
86
Some ( view_uniforms) ,
83
87
Some ( previous_view_uniforms) ,
84
88
) = (
85
- pipeline_cache. get_compute_pipeline ( self . initial_and_temporal_pipeline ) ,
86
- pipeline_cache. get_compute_pipeline ( self . spatial_and_shade_pipeline ) ,
89
+ pipeline_cache. get_compute_pipeline ( self . di_initial_and_temporal_pipeline ) ,
90
+ pipeline_cache. get_compute_pipeline ( self . di_spatial_and_shade_pipeline ) ,
91
+ pipeline_cache. get_compute_pipeline ( self . gi_initial_and_temporal_pipeline ) ,
92
+ pipeline_cache. get_compute_pipeline ( self . gi_spatial_and_shade_pipeline ) ,
87
93
& scene_bindings. bind_group ,
88
94
camera. physical_viewport_size ,
89
95
view_prepass_textures. deferred_view ( ) ,
@@ -101,8 +107,18 @@ impl ViewNode for SolariLightingNode {
101
107
& self . bind_group_layout ,
102
108
& BindGroupEntries :: sequential ( (
103
109
view_target. get_unsampled_color_attachment ( ) . view ,
104
- solari_lighting_resources. reservoirs_a . as_entire_binding ( ) ,
105
- solari_lighting_resources. reservoirs_b . as_entire_binding ( ) ,
110
+ solari_lighting_resources
111
+ . di_reservoirs_a
112
+ . as_entire_binding ( ) ,
113
+ solari_lighting_resources
114
+ . di_reservoirs_b
115
+ . as_entire_binding ( ) ,
116
+ solari_lighting_resources
117
+ . gi_reservoirs_a
118
+ . as_entire_binding ( ) ,
119
+ solari_lighting_resources
120
+ . gi_reservoirs_b
121
+ . as_entire_binding ( ) ,
106
122
gbuffer,
107
123
depth_buffer,
108
124
motion_vectors,
@@ -135,14 +151,20 @@ impl ViewNode for SolariLightingNode {
135
151
] ,
136
152
) ;
137
153
138
- pass. set_pipeline ( initial_and_temporal_pipeline ) ;
154
+ pass. set_pipeline ( di_initial_and_temporal_pipeline ) ;
139
155
pass. set_push_constants (
140
156
0 ,
141
157
bytemuck:: cast_slice ( & [ frame_index, solari_lighting. reset as u32 ] ) ,
142
158
) ;
143
159
pass. dispatch_workgroups ( viewport. x . div_ceil ( 8 ) , viewport. y . div_ceil ( 8 ) , 1 ) ;
144
160
145
- pass. set_pipeline ( spatial_and_shade_pipeline) ;
161
+ pass. set_pipeline ( di_spatial_and_shade_pipeline) ;
162
+ pass. dispatch_workgroups ( viewport. x . div_ceil ( 8 ) , viewport. y . div_ceil ( 8 ) , 1 ) ;
163
+
164
+ pass. set_pipeline ( gi_initial_and_temporal_pipeline) ;
165
+ pass. dispatch_workgroups ( viewport. x . div_ceil ( 8 ) , viewport. y . div_ceil ( 8 ) , 1 ) ;
166
+
167
+ pass. set_pipeline ( gi_spatial_and_shade_pipeline) ;
146
168
pass. dispatch_workgroups ( viewport. x . div_ceil ( 8 ) , viewport. y . div_ceil ( 8 ) , 1 ) ;
147
169
148
170
pass_span. end ( & mut pass) ;
@@ -189,10 +211,12 @@ impl FromWorld for SolariLightingNode {
189
211
(
190
212
texture_storage_2d (
191
213
ViewTarget :: TEXTURE_FORMAT_HDR ,
192
- StorageTextureAccess :: WriteOnly ,
214
+ StorageTextureAccess :: ReadWrite ,
193
215
) ,
194
216
storage_buffer_sized ( false , None ) ,
195
217
storage_buffer_sized ( false , None ) ,
218
+ storage_buffer_sized ( false , None ) ,
219
+ storage_buffer_sized ( false , None ) ,
196
220
texture_2d ( TextureSampleType :: Uint ) ,
197
221
texture_depth_2d ( ) ,
198
222
texture_2d ( TextureSampleType :: Float { filterable : true } ) ,
@@ -204,9 +228,9 @@ impl FromWorld for SolariLightingNode {
204
228
) ,
205
229
) ;
206
230
207
- let initial_and_temporal_pipeline =
231
+ let di_initial_and_temporal_pipeline =
208
232
pipeline_cache. queue_compute_pipeline ( ComputePipelineDescriptor {
209
- label : Some ( "solari_lighting_initial_and_temporal_pipeline " . into ( ) ) ,
233
+ label : Some ( "solari_lighting_di_initial_and_temporal_pipeline " . into ( ) ) ,
210
234
layout : vec ! [
211
235
scene_bindings. bind_group_layout. clone( ) ,
212
236
bind_group_layout. clone( ) ,
@@ -220,9 +244,9 @@ impl FromWorld for SolariLightingNode {
220
244
..default ( )
221
245
} ) ;
222
246
223
- let spatial_and_shade_pipeline =
247
+ let di_spatial_and_shade_pipeline =
224
248
pipeline_cache. queue_compute_pipeline ( ComputePipelineDescriptor {
225
- label : Some ( "solari_lighting_spatial_and_shade_pipeline " . into ( ) ) ,
249
+ label : Some ( "solari_lighting_di_spatial_and_shade_pipeline " . into ( ) ) ,
226
250
layout : vec ! [
227
251
scene_bindings. bind_group_layout. clone( ) ,
228
252
bind_group_layout. clone( ) ,
@@ -236,10 +260,46 @@ impl FromWorld for SolariLightingNode {
236
260
..default ( )
237
261
} ) ;
238
262
263
+ let gi_initial_and_temporal_pipeline =
264
+ pipeline_cache. queue_compute_pipeline ( ComputePipelineDescriptor {
265
+ label : Some ( "solari_lighting_gi_initial_and_temporal_pipeline" . into ( ) ) ,
266
+ layout : vec ! [
267
+ scene_bindings. bind_group_layout. clone( ) ,
268
+ bind_group_layout. clone( ) ,
269
+ ] ,
270
+ push_constant_ranges : vec ! [ PushConstantRange {
271
+ stages: ShaderStages :: COMPUTE ,
272
+ range: 0 ..8 ,
273
+ } ] ,
274
+ shader : load_embedded_asset ! ( world, "restir_gi.wgsl" ) ,
275
+ shader_defs : vec ! [ ] ,
276
+ entry_point : Some ( "initial_and_temporal" . into ( ) ) ,
277
+ zero_initialize_workgroup_memory : false ,
278
+ } ) ;
279
+
280
+ let gi_spatial_and_shade_pipeline =
281
+ pipeline_cache. queue_compute_pipeline ( ComputePipelineDescriptor {
282
+ label : Some ( "solari_lighting_gi_spatial_and_shade_pipeline" . into ( ) ) ,
283
+ layout : vec ! [
284
+ scene_bindings. bind_group_layout. clone( ) ,
285
+ bind_group_layout. clone( ) ,
286
+ ] ,
287
+ push_constant_ranges : vec ! [ PushConstantRange {
288
+ stages: ShaderStages :: COMPUTE ,
289
+ range: 0 ..8 ,
290
+ } ] ,
291
+ shader : load_embedded_asset ! ( world, "restir_gi.wgsl" ) ,
292
+ shader_defs : vec ! [ ] ,
293
+ entry_point : Some ( "spatial_and_shade" . into ( ) ) ,
294
+ zero_initialize_workgroup_memory : false ,
295
+ } ) ;
296
+
239
297
Self {
240
298
bind_group_layout,
241
- initial_and_temporal_pipeline,
242
- spatial_and_shade_pipeline,
299
+ di_initial_and_temporal_pipeline,
300
+ di_spatial_and_shade_pipeline,
301
+ gi_initial_and_temporal_pipeline,
302
+ gi_spatial_and_shade_pipeline,
243
303
}
244
304
}
245
305
}
0 commit comments