v146 · Web APIs · Texture Lets Demo
Texture Lets Demo
Renders a procedural checkerboard texture using a WGSL shader that uses the new texture let variable pattern introduced in Chrome 146 — the texture is aliased into a local let and passed to a helper function.
The WGSL shader here uses
let t = myTex; let s = mySampler; and passes them as parameters to a helper function. This pattern requires Chrome 146+. Earlier Chrome versions would reject the shader at compile time.
output
Click Render to start
WebGPUChecking…
WGSL texture letChecking…
render time—
WGSL shader using texture let
@group(0) @binding(0) var myTex: texture_2d<f32>;
@group(0) @binding(1) var mySampler: sampler;
// Helper function accepts texture and sampler as parameters
fn sampleTexture(
tex: texture_2d<f32>,
smp: sampler,
uv: vec2f
) -> vec4f {
return textureSample(tex, smp, uv);
}
@fragment fn fs(@location(0) uv: vec2f) -> @location(0) vec4f {
// Local let aliases (new in Chrome 146)
let t = myTex;
let s = mySampler;
// Pass to helper
return sampleTexture(t, s, uv);
}