Skip to content
Snippets Groups Projects
Commit 070f7238 authored by Artur Wasmut's avatar Artur Wasmut
Browse files

add cheap blur filter and composite bloom compute passes.

parent 1ad25c45
No related branches found
No related tags found
1 merge request!62Resolve "Lens Flares"
Pipeline #25839 passed
Showing
with 101 additions and 50 deletions
projects/bloom/resources/Sponza/sponza_floor_a_diff.png

132 B

projects/bloom/resources/Sponza/sponza_roof_diff.png

132 B

No preview for this file type
projects/bloom/resources/Sponza/vase_dif.png

132 B

projects/bloom/resources/Sponza/vase_hanging.png

132 B

No preview for this file type
projects/bloom/resources/Sponza/vase_round.png

132 B

File deleted
# version 450
layout(local_size_x = 8, local_size_y = 8) in;
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(set=0, binding=0) uniform texture2D inImage;
layout(set=0, binding=1) uniform sampler inImageSampler;
layout(set=0, binding=2, r11f_g11f_b10f) uniform writeonly image2D outImage;
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
layout(set=0, binding=0) uniform texture2D offscreenAttachment;
layout(set=0, binding=1) uniform sampler offscreenSampler;
layout(r11f_g11f_b10f, set=0, binding=2) uniform writeonly image2D blurAttachment;
void main()
{
ivec2 pixel_coords = ivec2(gl_GlobalInvocationID.xy);
vec2 uv = vec2(pixel_coords) / imageSize(blurAttachment);
if(any(greaterThanEqual(gl_GlobalInvocationID.xy, imageSize(outImage)))){
return;
}
const int kernel_size = 10;
const float kernel_weight = (2 * kernel_size + 1) * (2 * kernel_size + 1);
ivec2 pixel_coord = ivec2(gl_GlobalInvocationID.xy);
vec2 pixel_size = vec2(1.0f) / textureSize(sampler2D(inImage, inImageSampler), 0);
vec2 UV = pixel_coord.xy * pixel_size;
// TODO: BLUR
vec4 sampled_color = vec4(0.0f);
for(int i = -kernel_size; i <= kernel_size; i++)
{
for(int j = -kernel_size; j <= kernel_size; j++)
{
vec2 sample_coord = UV + vec2(j, i) * pixel_size + 0.5f * pixel_size * sign(vec2(j, i));
sampled_color.rgb += texture(sampler2D(inImage, inImageSampler), sample_coord).rgb;
}
}
sampled_color /= kernel_weight;
imageStore(blurAttachment, pixel_coords, vec4(1.0, 0.0 ,0.0, 0.0));
imageStore(outImage, pixel_coord, sampled_color);
}
\ No newline at end of file
File deleted
File added
%VULKAN_SDK%\Bin32\glslc.exe shader.vert -o vert.spv
%VULKAN_SDK%\Bin32\glslc.exe shader.frag -o frag.spv
%VULKAN_SDK%\Bin32\glslc.exe shadow.vert -o shadow_vert.spv
%VULKAN_SDK%\Bin32\glslc.exe shadow.frag -o shadow_frag.spv
%VULKAN_SDK%\Bin32\glslc.exe quad.vert -o quad_vert.spv
%VULKAN_SDK%\Bin32\glslc.exe quad.frag -o quad_frag.spv
%VULKAN_SDK%\Bin32\glslc.exe blur.comp -o blur_comp.spv
pause
\ No newline at end of file
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(set=0, binding=0) uniform texture2D blurImage;
layout(set=0, binding=1) uniform sampler linearSampler;
layout(set=0, binding=2, r11f_g11f_b10f) uniform image2D colorBuffer;
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
void main()
{
if(any(greaterThanEqual(gl_GlobalInvocationID.xy, imageSize(colorBuffer)))){
return;
}
ivec2 pixel_coord = ivec2(gl_GlobalInvocationID.xy);
vec2 pixel_size = vec2(1.0f) / textureSize(sampler2D(blurImage, linearSampler), 0);
vec2 UV = pixel_coord.xy * pixel_size;
vec4 composite_color = vec4(0.0f);
vec3 blur_color = texture(sampler2D(blurImage, linearSampler), UV).rgb;
vec3 main_color = imageLoad(colorBuffer, pixel_coord).rgb;
composite_color.rgb = mix(main_color, blur_color, 0.1f);
imageStore(colorBuffer, pixel_coord, composite_color);
}
\ No newline at end of file
File deleted
#version 440
layout(set=0, binding=0, r11f_g11f_b10f) uniform image2D inImage;
layout(set=0, binding=1, rgba8) uniform image2D outImage;
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
void main(){
if(any(greaterThanEqual(gl_GlobalInvocationID.xy, imageSize(inImage)))){
return;
}
ivec2 uv = ivec2(gl_GlobalInvocationID.xy);
vec3 linearColor = imageLoad(inImage, uv).rgb;
// cheap Reinhard tone mapping
linearColor = linearColor/(linearColor + 1.0f);
vec3 gammaCorrected = pow(linearColor, vec3(1.f / 2.2f));
imageStore(outImage, uv, vec4(gammaCorrected, 0.f));
}
\ No newline at end of file
layout(set=1, binding=0) uniform texture2D albedoTexture;
layout(set=1, binding=1) uniform sampler textureSampler;
\ No newline at end of file
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(location = 0) in vec2 inUV;
layout(location = 0) out vec3 outColor;
layout(set=0, binding=0) uniform texture2D renderAttachment;
layout(set=0, binding=1) uniform texture2D blurAttachment;
layout(set=0, binding=2) uniform sampler samp;
void main()
{
outColor = texture(sampler2D(renderAttachment, samp), inUV).rgb;
}
\ No newline at end of file
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(location = 0) in vec3 inPosition;
layout(location = 0) out vec2 outUV;
void main()
{
outUV = inPosition.xy;
gl_Position = vec4(inPosition, 1.0);
}
\ No newline at end of file
File deleted
File deleted
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment