mach/src/core/examples/sysgpu/deferred-rendering/fragmentWriteGBuffers.wgsl
Stephen Gutekanst 38f296ecce src/core: move mach-core@9a4d09707d9f1cb6ea5602bdf58caeefc46146be package to here
Helps hexops/mach#1165

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-03-05 00:22:22 -07:00

22 lines
578 B
WebGPU Shading Language

struct GBufferOutput {
@location(0) normal : vec4<f32>,
// Textures: diffuse color, specular color, smoothness, emissive etc. could go here
@location(1) albedo : vec4<f32>,
}
@fragment
fn main(
@location(0) fragNormal: vec3<f32>,
@location(1) fragUV : vec2<f32>
) -> GBufferOutput {
// faking some kind of checkerboard texture
let uv = floor(30.0 * fragUV);
let c = 0.2 + 0.5 * ((uv.x + uv.y) - 2.0 * floor((uv.x + uv.y) / 2.0));
var output : GBufferOutput;
output.normal = vec4(fragNormal, 1.0);
output.albedo = vec4(c, c, c, 1.0);
return output;
}