@@ -31,11 +31,11 @@ fn spatial_denoise(@builtin(global_invocation_id) global_id: vec3<u32>) {
31
31
let visibility2 = textureGather (0 , ambient_occlusion_noisy , point_clamp_sampler , uv , vec2 <i32 >(0i , 2i ));
32
32
let visibility3 = textureGather (0 , ambient_occlusion_noisy , point_clamp_sampler , uv , vec2 <i32 >(2i , 2i ));
33
33
34
- let left_edges = unpack4x8unorm (edges0 . x);
35
- let right_edges = unpack4x8unorm (edges1 . x);
36
- let top_edges = unpack4x8unorm (edges0 . z);
37
- let bottom_edges = unpack4x8unorm (edges2 . w);
38
- var center_edges = unpack4x8unorm (edges0 . y);
34
+ let left_edges = myunpack4x8unorm (edges0 . x);
35
+ let right_edges = myunpack4x8unorm (edges1 . x);
36
+ let top_edges = myunpack4x8unorm (edges0 . z);
37
+ let bottom_edges = myunpack4x8unorm (edges2 . w);
38
+ var center_edges = myunpack4x8unorm (edges0 . y);
39
39
center_edges *= vec4 <f32 >(left_edges . y, right_edges . x, top_edges . w, bottom_edges . z);
40
40
41
41
let center_weight = 1.2 ;
@@ -82,3 +82,11 @@ fn spatial_denoise(@builtin(global_invocation_id) global_id: vec3<u32>) {
82
82
83
83
textureStore (ambient_occlusion , pixel_coordinates , vec4 <f32 >(denoised_visibility , 0.0 , 0.0 , 0.0 ));
84
84
}
85
+
86
+ // TODO: Remove this once https://github.com/gfx-rs/naga/pull/2353 lands in Bevy
87
+ fn myunpack4x8unorm (e : u32 ) -> vec4 <f32 > {
88
+ return vec4 <f32 >(clamp (f32 (e & 0xFFu ) / 255.0 , 0.0 , 1.0 ),
89
+ clamp (f32 ((e >> 8u ) & 0xFFu ) / 255.0 , 0.0 , 1.0 ),
90
+ clamp (f32 ((e >> 16u ) & 0xFFu ) / 255.0 , 0.0 , 1.0 ),
91
+ clamp (f32 ((e >> 24u ) & 0xFFu ) / 255.0 , 0.0 , 1.0 ));
92
+ }
0 commit comments