mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-16 04:11:25 +00:00
Enable the parsing of 'const'. Warn on use of module-scope 'let', and automatically replace with 'const'. Fixed: tint:1580 Change-Id: I214aabca80686dc6b60ae21a7a57fbfb4898ea83 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93786 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
43 lines
1.5 KiB
WebGPU Shading Language
43 lines
1.5 KiB
WebGPU Shading Language
const bloomDir = vec2(0.0, 1.0);
|
|
|
|
var<private> offsets : array<f32, 3> = array<f32, 3>(0.0, 1.384615421, 3.230769157);
|
|
|
|
var<private> weights : array<f32, 3> = array<f32, 3>(0.227027029, 0.31621623, 0.07027027);
|
|
|
|
struct BloomUniforms {
|
|
radius : f32,
|
|
dim : f32,
|
|
}
|
|
|
|
@group(0) @binding(0) var<uniform> bloom : BloomUniforms;
|
|
|
|
@group(0) @binding(1) var bloomTexture : texture_2d<f32>;
|
|
|
|
@group(0) @binding(2) var bloomSampler : sampler;
|
|
|
|
struct FragmentInput {
|
|
@location(0)
|
|
texCoord : vec2<f32>,
|
|
}
|
|
|
|
fn getGaussianBlur(texCoord : vec2<f32>) -> vec4<f32> {
|
|
let texelRadius = (vec2(bloom.radius) / vec2<f32>(textureDimensions(bloomTexture)));
|
|
let step = (bloomDir * texelRadius);
|
|
var sum = vec4(0.0);
|
|
sum = (sum + (textureSample(bloomTexture, bloomSampler, texCoord) * weights[0]));
|
|
sum = (sum + (textureSample(bloomTexture, bloomSampler, (texCoord + (step * 1.0))) * weights[1]));
|
|
sum = (sum + (textureSample(bloomTexture, bloomSampler, (texCoord - (step * 1.0))) * weights[1]));
|
|
sum = (sum + (textureSample(bloomTexture, bloomSampler, (texCoord + (step * 2.0))) * weights[2]));
|
|
sum = (sum + (textureSample(bloomTexture, bloomSampler, (texCoord - (step * 2.0))) * weights[2]));
|
|
return vec4(sum.rgb, 1.0);
|
|
}
|
|
|
|
@group(0) @binding(3) var prevTexture : texture_2d<f32>;
|
|
|
|
@fragment
|
|
fn fragmentMain(input : FragmentInput) -> @location(0) vec4<f32> {
|
|
let blurColor = getGaussianBlur(input.texCoord);
|
|
let dimColor = (textureSample(prevTexture, bloomSampler, input.texCoord) * bloom.dim);
|
|
return (blurColor + dimColor);
|
|
}
|