Fixes and extra bloom

This commit is contained in:
Imbris 2021-07-21 05:39:30 -04:00
parent 2d83ef1c0e
commit 74e01f10e3
5 changed files with 18 additions and 10 deletions

View File

@ -5,7 +5,10 @@ uniform texture2D t_src_color;
layout(set = 0, binding = 1)
uniform sampler s_src_color;
layout(set = 0, binding = 2)
uniform vec2 halfpixel;
// TODO: refactor in rust
uniform u_locals {
vec2 halfpixel;
};
layout(location = 0) in vec2 uv;

View File

@ -5,7 +5,9 @@ uniform texture2D t_src_color;
layout(set = 0, binding = 1)
uniform sampler s_src_color;
layout(set = 0, binding = 2)
uniform vec2 halfpixel;
uniform u_locals {
vec2 halfpixel;
};
layout(location = 0) in vec2 uv;

View File

@ -32,7 +32,7 @@ uniform sampler s_src_color;
layout(location = 0) in vec2 uv;
layout (std140, set = 1, binding = 2)
layout (std140, set = 1, binding = 3)
uniform u_locals {
mat4 proj_mat_inv;
mat4 view_mat_inv;
@ -185,7 +185,7 @@ void main() {
vec4 aa_color = aa_apply(t_src_color, s_src_color, uv * screen_res.xy, screen_res.xy);
// Bloom
vec4 bloom = textureLod(sampler2D(t_src_bloom, s_src_color), uv, 0) * 0.05;
vec4 bloom = textureLod(sampler2D(t_src_bloom, s_src_color), uv, 0) * 0.75;
aa_color += bloom;
// Tonemapping

View File

@ -50,7 +50,7 @@ impl PostProcessLayout {
// TODO: make optional
// src bloom
wgpu::BindGroupLayoutEntry {
binding: 0,
binding: 1,
visibility: wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::Texture {
sample_type: wgpu::TextureSampleType::Float { filterable: true },
@ -60,7 +60,7 @@ impl PostProcessLayout {
count: None,
},
wgpu::BindGroupLayoutEntry {
binding: 1,
binding: 2,
visibility: wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::Sampler {
filtering: true,
@ -70,7 +70,7 @@ impl PostProcessLayout {
},
// Locals
wgpu::BindGroupLayoutEntry {
binding: 2,
binding: 3,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::Buffer {
ty: wgpu::BufferBindingType::Uniform,
@ -105,15 +105,15 @@ impl PostProcessLayout {
// TODO: if there is no upscaling we can do the last bloom upsampling in post
// process to save a pass and the need for the final full size bloom render target
wgpu::BindGroupEntry {
binding: 0,
binding: 1,
resource: wgpu::BindingResource::TextureView(src_bloom),
},
wgpu::BindGroupEntry {
binding: 1,
binding: 2,
resource: wgpu::BindingResource::Sampler(sampler),
},
wgpu::BindGroupEntry {
binding: 2,
binding: 3,
resource: locals.buf().as_entire_binding(),
},
],

View File

@ -68,6 +68,9 @@ impl assets::Compound for Shaders {
"lod-terrain-frag",
"clouds-vert",
"clouds-frag",
"duel-downsample-frag",
"duel-upsample-frag",
"clouds-frag",
"postprocess-vert",
"postprocess-frag",
"blit-vert",