#import bevy_sprite::mesh2d_view_bindings struct RainbowOutlineAndTextureMaterial { thickness : f32, frequency : f32, }; @group(1) @binding(0) var material: RainbowOutlineAndTextureMaterial; @group(1) @binding(1) var base_color_texture: texture_2d; @group(1) @binding(2) var base_color_sampler: sampler; @fragment fn fragment( #import bevy_pbr::mesh_vertex_output @builtin(position) coord : vec4 ) -> @location(0) vec4 { var outline : f32 = textureSample(base_color_texture, base_color_sampler,uv + vec2(material.thickness,0.0)).a; outline += textureSample(base_color_texture, base_color_sampler,uv + vec2(-material.thickness,0.0)).a; outline += textureSample(base_color_texture, base_color_sampler,uv + vec2(0.0,material.thickness)).a; outline += textureSample(base_color_texture, base_color_sampler,uv + vec2(0.0,-material.thickness)).a; outline += textureSample(base_color_texture, base_color_sampler,uv + vec2(material.thickness,-material.thickness)).a; outline += textureSample(base_color_texture, base_color_sampler,uv + vec2(-material.thickness,material.thickness)).a; outline += textureSample(base_color_texture, base_color_sampler,uv + vec2(material.thickness,material.thickness)).a; outline += textureSample(base_color_texture, base_color_sampler,uv + vec2(-material.thickness,-material.thickness)).a; outline = min(outline, 1.0); var animated_line_color : vec4 = vec4(sin(globals.time * material.frequency), sin(globals.time * material.frequency + radians(120.0)), sin(globals.time * material.frequency + radians(240.0)), 1.0); var color : vec4 = textureSample(base_color_texture, base_color_sampler,uv); return mix(color, animated_line_color, outline - color.a); }