1#define_import_path bevy_pbr::utils 3#import bevy_pbr::rgb9e5 14fn rand_u(state: ptr<function, u32>) -> u32 { 15 *state = *state * 747796405u + 2891336453u; 16 let word = ((*state >> ((*state >> 28u) + 4u)) ^ *state) * 277803737u; 17 return (word >> 22u) ^ word; 21fn rand_f(state: ptr<function, u32>) -> f32 { 22 *state = *state * 747796405u + 2891336453u; 23 let word = ((*state >> ((*state >> 28u) + 4u)) ^ *state) * 277803737u; 24 return f32((word >> 22u) ^ word) * bitcast<f32>(0x2f800004u); 28fn rand_vec2f(state: ptr<function, u32>) -> vec2<f32> { 29 return vec2(rand_f(state), rand_f(state)); 33fn rand_range_u(n: u32, state: ptr<function, u32>) -> u32 { 34 return rand_u(state) % n; 41fn coords_to_viewport_uv(position: vec2<f32>, viewport: vec4<f32>) -> vec2<f32> { 42 return (position - viewport.xy) / viewport.zw; 48fn octahedral_encode(v: vec3<f32>) -> vec2<f32> { 49 var n = v / (abs(v.x) + abs(v.y) + abs(v.z)); 50 let octahedral_wrap = (1.0 - abs(n.yx)) * select(vec2(-1.0), vec2(1.0), n.xy > vec2f(0.0)); 51 let n_xy = select(octahedral_wrap, n.xy, n.z >= 0.0); 52 return n_xy * 0.5 + 0.5; 56fn octahedral_decode(v: vec2<f32>) -> vec3<f32> { 57 let f = v * 2.0 - 1.0; 58 var n = octahedral_decode_signed(f); 63fn octahedral_decode_signed(v: vec2<f32>) -> vec3<f32> { 64 var n = vec3(v.xy, 1.0 - abs(v.x) - abs(v.y)); 65 let t = saturate(-n.z); 66 let w = select(vec2(t), vec2(-t), n.xy >= vec2(0.0)); 67 n = vec3(n.xy + w, n.z); 72fn interleaved_gradient_noise(pixel_coordinates: vec2<f32>, frame: u32) -> f32 { 73 let xy = pixel_coordinates + 5.588238 * f32(frame % 64u); 74 return fract(52.9829189 * fract(0.06711056 * xy.x + 0.00583715 * xy.y)); 81const SPIRAL_OFFSET_0_ = vec2<f32>(-0.7071, 0.7071); 82const SPIRAL_OFFSET_1_ = vec2<f32>(-0.0000, -0.8750); 83const SPIRAL_OFFSET_2_ = vec2<f32>( 0.5303, 0.5303); 84const SPIRAL_OFFSET_3_ = vec2<f32>(-0.6250, -0.0000); 85const SPIRAL_OFFSET_4_ = vec2<f32>( 0.3536, -0.3536); 86const SPIRAL_OFFSET_5_ = vec2<f32>(-0.0000, 0.3750); 87const SPIRAL_OFFSET_6_ = vec2<f32>(-0.1768, -0.1768); 88const SPIRAL_OFFSET_7_ = vec2<f32>( 0.1250, 0.0000);