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::noise::vnoise
3#import bevy_water::noise::random::{
4 random2di, cubic_hermite_curve_2d,
5}
7fn vnoise2d(v: vec2<f32>) -> f32 {
8 let i = floor(v);
9 let f = fract(v);
11 // corners.
12 let a = random2di(i);
13 let b = random2di(i + vec2<f32>(1.0, 0.0));
14 let c = random2di(i + vec2<f32>(0.0, 1.0));
15 let d = random2di(i + vec2<f32>(1.0, 1.0));
17 // Smooth
18 let u = cubic_hermite_curve_2d(f);
20 // Mix
21 return mix(a, b, u.x) +
22 (c - a) * u.y * (1.0 - u.x) +
23 (d - b) * u.x * u.y;
Contents