audioshader/assets/shaders/default.wgsl

31 lines
815 B
WebGPU Shading Language
Raw Normal View History

2025-08-31 09:39:39 +00:00
// Simple UV gradient shader (vertex + fragment)
struct VertexInput {
@location(0) position: vec3<f32>,
@location(1) uv: vec2<f32>,
}
struct VertexOutput {
@builtin(position) clip_position: vec4<f32>,
@location(0) uv: vec2<f32>,
}
@vertex
fn vertex(in: VertexInput) -> VertexOutput {
var out: VertexOutput;
// assume incoming positions are in clip-space (vec3 with z, or model-transformed)
out.clip_position = vec4<f32>(in.position, 1.0);
out.uv = in.uv;
return out;
}
@fragment
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
// very simple vertical gradient between two colors
let bottom = vec3<f32>(1.0, 0.8, 0.2); // warm
let top = vec3<f32>(0.2, 0.6, 1.0); // cool
let color = mix(bottom, top, in.uv.y);
return vec4<f32>(color, 1.0);
}