Search across packages, versions, files, declarations, and comments. Use multiple terms to narrow results (AND), and add @vertex, @fragment, or @compute to filter by shader stage.
1import package::{
2 atmosphere::{
3 functions::{direction_world_to_atmosphere, sample_sky_view_lut, get_view_position},
4 },
5 render::utils::sample_cube_dir
6};
8@group(0) @binding(13) var output: texture_storage_2d_array<rgba16float, write>;
10@compute @workgroup_size(8, 8, 1)
11fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
12 let dimensions = textureDimensions(output);
13 let slice_index = global_id.z;
15 if (global_id.x >= dimensions.x || global_id.y >= dimensions.y || slice_index >= 6u) {
16 return;
17 }
19 // Calculate normalized UV coordinates for this pixel
20 let uv = vec2<f32>(
21 (f32(global_id.x) + 0.5) / f32(dimensions.x),
22 (f32(global_id.y) + 0.5) / f32(dimensions.y)
23 );
25 var ray_dir_ws = sample_cube_dir(uv, slice_index);
27 // invert the z direction to account for cubemaps being lefthanded
28 ray_dir_ws.z = -ray_dir_ws.z;
30 let world_pos = get_view_position();
31 let r = length(world_pos);
33 let ray_dir_as = direction_world_to_atmosphere(ray_dir_ws.xyz);
34 let inscattering = sample_sky_view_lut(r, ray_dir_as);
35 let color = vec4<f32>(inscattering, 1.0);
37 textureStore(output, vec2<i32>(global_id.xy), i32(slice_index), color);
Contents