77 lines
1.7 KiB
Plaintext
77 lines
1.7 KiB
Plaintext
[layout(std140)]
|
|
struct ViewerData
|
|
{
|
|
projectionMatrix: mat4<f32>,
|
|
invProjectionMatrix: mat4<f32>,
|
|
viewMatrix: mat4<f32>,
|
|
invViewMatrix: mat4<f32>,
|
|
viewProjMatrix: mat4<f32>,
|
|
invViewProjMatrix: mat4<f32>,
|
|
renderTargetSize: vec2<f32>,
|
|
invRenderTargetSize: vec2<f32>,
|
|
eyePosition: vec3<f32>
|
|
}
|
|
|
|
[layout(std140)]
|
|
struct BlurData
|
|
{
|
|
direction: vec2<f32>,
|
|
sizeFactor: f32
|
|
}
|
|
|
|
external
|
|
{
|
|
[set(0), binding(0)] viewerData: uniform<ViewerData>,
|
|
[set(0), binding(1)] colorTexture: sampler2D<f32>,
|
|
[set(0), binding(2)] blurData: uniform<BlurData>
|
|
}
|
|
|
|
struct FragIn
|
|
{
|
|
[builtin(fragcoord)] fragcoord: vec4<f32>
|
|
}
|
|
|
|
struct FragOut
|
|
{
|
|
[location(0)] color: vec4<f32>
|
|
}
|
|
|
|
struct VertIn
|
|
{
|
|
[location(0)] pos: vec2<f32>
|
|
}
|
|
|
|
struct VertOut
|
|
{
|
|
[builtin(position)] position: vec4<f32>
|
|
}
|
|
|
|
[entry(frag)]
|
|
fn main(input: FragIn) -> FragOut
|
|
{
|
|
let invTargetSize = viewerData.invRenderTargetSize * blurData.sizeFactor;
|
|
let fragcoord = input.fragcoord.xy * invTargetSize;
|
|
|
|
let color = colorTexture.Sample(fragcoord).rgb * 0.2270270270;
|
|
|
|
color += colorTexture.Sample(fragcoord + blurData.direction * 1.3846153846 * invTargetSize).rgb * 0.3162162162;
|
|
color += colorTexture.Sample(fragcoord - blurData.direction * 1.3846153846 * invTargetSize).rgb * 0.3162162162;
|
|
|
|
color += colorTexture.Sample(fragcoord + blurData.direction * 3.2307692308 * invTargetSize).rgb * 0.0702702703;
|
|
color += colorTexture.Sample(fragcoord - blurData.direction * 3.2307692308 * invTargetSize).rgb * 0.0702702703;
|
|
|
|
let output: FragOut;
|
|
output.color = vec4<f32>(color, 1.0);
|
|
|
|
return output;
|
|
}
|
|
|
|
[entry(vert)]
|
|
fn main(input: VertIn) -> VertOut
|
|
{
|
|
let output: VertOut;
|
|
output.position = vec4<f32>(input.pos, 0.0, 1.0);
|
|
|
|
return output;
|
|
}
|