DeferredShading: Add bloom
This commit is contained in:
60
bin/resources/bloom_final.nzsl
Normal file
60
bin/resources/bloom_final.nzsl
Normal file
@@ -0,0 +1,60 @@
|
||||
[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>
|
||||
}
|
||||
|
||||
external
|
||||
{
|
||||
[binding(0)] colorTexture: sampler2D<f32>,
|
||||
[binding(1)] bloomTexture: sampler2D<f32>,
|
||||
[binding(2)] viewerData: uniform<ViewerData>
|
||||
}
|
||||
|
||||
struct FragIn
|
||||
{
|
||||
[builtin(fragcoord)] fragcoord: vec4<f32>
|
||||
}
|
||||
|
||||
struct FragOut
|
||||
{
|
||||
[location(0)] color: vec4<f32>
|
||||
}
|
||||
|
||||
struct VertIn
|
||||
{
|
||||
[location(0)] pos: vec3<f32>
|
||||
}
|
||||
|
||||
struct VertOut
|
||||
{
|
||||
[builtin(position)] position: vec4<f32>
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
fn main(input: FragIn) -> FragOut
|
||||
{
|
||||
let fragcoord = input.fragcoord.xy * viewerData.invRenderTargetSize;
|
||||
|
||||
let output: FragOut;
|
||||
output.color = colorTexture.Sample(fragcoord) + bloomTexture.Sample(fragcoord);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
[entry(vert)]
|
||||
fn main(input: VertIn) -> VertOut
|
||||
{
|
||||
let output: VertOut;
|
||||
output.position = vec4<f32>(input.pos, 1.0);
|
||||
|
||||
return output;
|
||||
}
|
||||
Reference in New Issue
Block a user