outfly/assets/shaders/testshader.wgsl

23 lines
730 B
WebGPU Shading Language
Raw Normal View History

2024-03-31 22:47:03 +00:00
#import bevy_pbr::{
mesh_view_bindings::globals,
forward_io::VertexOutput,
}
@fragment
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
let speed = 3.0;
let t_1 = sin(globals.time * speed) * 0.5 + 0.5;
let t_2 = cos(globals.time * speed);
let distance_to_center = distance(in.uv, vec2<f32>(0.5)) * 1.4;
let red = vec3<f32>(0.627955, 0.224863, 0.125846);
let green = vec3<f32>(0.86644, -0.233887, 0.179498);
let blue = vec3<f32>(0.701674, 0.274566, -0.169156);
let white = vec3<f32>(1.0, 0.0, 0.0);
let pos = vec3<f32>(in.position[0], in.position[1], in.position[2]);
let mixed = mix(pos, mix(green, white, t_2), distance_to_center);
return vec4<f32>(mixed, 1.0);
}