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.
1#define_import_path bevy_water::water_functions
3#ifdef PREPASS_PIPELINE
4#import bevy_render::globals::Globals
5@group(0) @binding(1) var<uniform> globals: Globals;
6#else
7#import bevy_pbr::mesh_view_bindings::globals
8#endif
10#import bevy_water::water_bindings::material
11#import bevy_water::noise;
13fn wave(p: vec2<f32>) -> f32 {
14 let time = globals.time * .5 + 23.0;
16 let time_x = time / 1.0;
17 let time_y = time / 0.5;
18 let wave_len_x = 5.0;
19 let wave_len_y = 2.0;
20 let wave_x = cos(p.x / wave_len_x + time_x);
21 let wave_y = smoothstep(1.0, 0.0, abs(sin(p.y / wave_len_y + wave_x + time_y)));
22#if QUALITY < 3
23 let n = noise::fbm::fbm_half(p) / 2.0 - 1.0;
24#else
25 let n = noise::fbm::fbm(p) / 2.0 - 1.0;
26#endif
27 return wave_y + n;
30fn get_wave_height(p: vec2<f32>) -> f32 {
31 let time = globals.time / 2.0;
32 var d = wave((p - time) * 0.3) * 0.3;
33#if QUALITY >= 2
34 d = d + wave((p + time) * 0.4) * 0.3;
35#endif
36#if QUALITY >= 3
37 d = d + wave((p + time) * 0.5) * 0.2;
38#endif
39#if QUALITY >= 4
40 d = d + wave((p - time) * 0.6) * 0.2;
41#endif
42 return material.amplitude * d;
45fn uv_to_coord(uv: vec2<f32>) -> vec2<f32> {
46 return material.coord_offset + (uv * material.coord_scale);
Contents