mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-23 16:01:04 +01:00
38 lines
836 B
WebGPU Shading Language
38 lines
836 B
WebGPU Shading Language
struct VertexOutput {
|
|
[[location(0)]] tex_coord: vec2<f32>;
|
|
[[builtin(position)]] position: vec4<f32>;
|
|
};
|
|
|
|
[[block]]
|
|
struct Locals {
|
|
transform: mat4x4<f32>;
|
|
};
|
|
[[group(0), binding(0)]]
|
|
var r_locals: Locals;
|
|
|
|
[[stage(vertex)]]
|
|
fn vs_main(
|
|
[[location(0)]] position: vec4<f32>,
|
|
[[location(1)]] tex_coord: vec2<f32>,
|
|
) -> VertexOutput {
|
|
var out: VertexOutput;
|
|
out.tex_coord = tex_coord;
|
|
out.position = r_locals.transform * position;
|
|
return out;
|
|
}
|
|
|
|
[[group(0), binding(1)]]
|
|
var r_color: texture_2d<f32>;
|
|
[[group(0), binding(2)]]
|
|
var r_sampler: sampler;
|
|
|
|
[[stage(fragment)]]
|
|
fn fs_main(in: VertexOutput) -> [[location(0)]] vec4<f32> {
|
|
return textureSample(r_color, r_sampler, in.tex_coord);
|
|
}
|
|
|
|
[[stage(fragment)]]
|
|
fn fs_wire() -> [[location(0)]] vec4<f32> {
|
|
return vec4<f32>(0.0, 0.5, 0.0, 0.5);
|
|
}
|