ruffle/render/wgpu/shaders/color.wgsl

28 lines
827 B
WebGPU Shading Language

/// Shader used for drawing solid color fills.
// NOTE: The `common.wgsl` source is prepended to this before compilation.
struct VertexInput {
@location(0) position: vec2<f32>,
@location(1) color: vec4<f32>,
};
struct VertexOutput {
@builtin(position) position: vec4<f32>,
@location(0) color: vec4<f32>,
};
@group(1) @binding(0) var<uniform> transforms: common__Transforms;
@vertex
fn main_vertex(in: VertexInput) -> VertexOutput {
let pos = common__globals.view_matrix * transforms.world_matrix * vec4<f32>(in.position.x, in.position.y, 0.0, 1.0);
let color = saturate(in.color * transforms.mult_color + transforms.add_color);
return VertexOutput(pos, vec4<f32>(color.rgb * color.a, color.a));
}
@fragment
fn main_fragment(in: VertexOutput) -> @location(0) vec4<f32> {
return in.color;
}