1#import noisy_bevy::fbm_simplex_2d_seeded 2#import bevy_sprite::mesh2d_functions::{ 4 mesh2d_position_local_to_clip, 7struct AsteroidMaterial { 11@group(2) @binding(0) var<uniform> material: AsteroidMaterial; 14 @builtin(instance_index) instance_index: u32, 15 @location(0) position: vec3<f32>, 16 @location(1) blend_color: vec4<f32>, 20 @builtin(position) clip_position: vec4<f32>, 21 @location(0) object_position: vec2<f32>, 25fn vertex(vertex: Vertex) -> VertexOutput { 26 var out: VertexOutput; 28 let model = get_world_from_local(vertex.instance_index); 29 out.clip_position = mesh2d_position_local_to_clip(model, vec4<f32>(vertex.position, 1.0)); 30 out.object_position = vertex.position.xy; 36 vertex_output: VertexOutput, 37) -> @location(0) vec4<f32> { 38 var p = vertex_output.object_position; 39 let params = material.params; 40 let freq_scale = params.x; 41 let amp_scale = params.y; 42 let radius = params.z; 45 let r = sqrt(p.x * p.x + p.y * p.y); 52 let n = fbm_simplex_2d_seeded(p * freq_scale, 7, 2.0, 0.5, seed) * amp_scale; 55 v = pow(-v * 0.1 + 0.3, 2.1); 57 return vec4(v, v, v, 1.);