Files
WebGpu-Wasm-Raytracing-And-…/shaders/triangle-list-texture-solid.wgsl
2025-12-25 10:57:33 +01:00

32 lines
735 B
WebGPU Shading Language

@group(0) @binding(0)
var<uniform> viewProjectionMatrix : mat4x4<f32>;
@group(0) @binding(1)
var myTexture : texture_2d<f32>;
@group(0) @binding(2)
var mySampler : sampler;
struct VertexOutput {
@builtin(position) position : vec4<f32>,
@location(0) uv : vec2<f32>,
};
@vertex
fn vertexEntryPoint(
@location(0) position : vec3<f32>,
@location(1) uv : vec2<f32>
) -> VertexOutput {
var output : VertexOutput;
output.position = viewProjectionMatrix * vec4<f32>(position, 1.0);
output.uv = uv;
return output;
}
@fragment
fn fragmentEntryPoint(
@location(0) uv : vec2<f32>
) -> @location(0) vec4<f32> {
let color = textureSample(myTexture, mySampler, uv);
return vec4<f32>(color.rgb, 1.0);
}