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 bindings::settings,
4 functions::{
5 get_view_position, raymarch_atmosphere,
6 max_atmosphere_distance, direction_atmosphere_to_world,
7 sky_view_lut_uv_to_zenith_azimuth, zenith_azimuth_to_ray_dir,
8 },
9 }
10};
12import bevy_render::{
13 view::View,
14 maths::HALF_PI,
15};
16import bevy_core_pipeline::fullscreen_vertex_shader::FullscreenVertexOutput;
18@group(0) @binding(13) var sky_view_lut_out: texture_storage_2d<rgba16float, write>;
20@compute
21@workgroup_size(16, 16, 1)
22fn main(@builtin(global_invocation_id) idx: vec3<u32>) {
23 let uv = vec2<f32>(idx.xy) / vec2<f32>(settings.sky_view_lut_size);
25 let cam_pos = get_view_position();
26 let r = length(cam_pos);
27 var zenith_azimuth = sky_view_lut_uv_to_zenith_azimuth(r, uv);
29 let ray_dir_as = zenith_azimuth_to_ray_dir(zenith_azimuth.x, zenith_azimuth.y);
30 let ray_dir_ws = direction_atmosphere_to_world(ray_dir_as);
32 let world_pos = cam_pos;
33 let up = normalize(world_pos);
34 let mu = dot(ray_dir_ws, up);
35 let t_max = max_atmosphere_distance(r, mu);
37 let result = raymarch_atmosphere(world_pos, ray_dir_ws, t_max, settings.sky_view_lut_samples, uv, true);
39 textureStore(sky_view_lut_out, idx.xy, vec4(result.inscattering, 1.0));
Contents