Added Vulkan examples sources!
This commit is contained in:
parent
367fda186b
commit
c91341813c
868 changed files with 514080 additions and 5584 deletions
47
data/shaders/bloom/gaussblur.frag
Normal file
47
data/shaders/bloom/gaussblur.frag
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (binding = 1) uniform sampler2D samplerColor;
|
||||
|
||||
layout (binding = 2) uniform UBO
|
||||
{
|
||||
int texWidth;
|
||||
int texHeight;
|
||||
float blurScale;
|
||||
float blurStrength;
|
||||
int horizontal;
|
||||
} ubo;
|
||||
|
||||
layout (location = 0) in vec2 inUV;
|
||||
|
||||
layout (location = 0) out vec4 outFragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
float weight[5];
|
||||
weight[0] = 0.227027;
|
||||
weight[1] = 0.1945946;
|
||||
weight[2] = 0.1216216;
|
||||
weight[3] = 0.054054;
|
||||
weight[4] = 0.016216;
|
||||
|
||||
vec2 tex_offset = 1.0 / textureSize(samplerColor, 0) * ubo.blurScale; // gets size of single texel
|
||||
vec3 result = texture(samplerColor, inUV).rgb * weight[0]; // current fragment's contribution
|
||||
for(int i = 1; i < 5; ++i)
|
||||
{
|
||||
if (ubo.horizontal == 1)
|
||||
{
|
||||
result += texture(samplerColor, inUV + vec2(tex_offset.x * i, 0.0)).rgb * weight[i] * ubo.blurStrength;
|
||||
result += texture(samplerColor, inUV - vec2(tex_offset.x * i, 0.0)).rgb * weight[i] * ubo.blurStrength;
|
||||
}
|
||||
else
|
||||
{
|
||||
result += texture(samplerColor, inUV + vec2(0.0, tex_offset.y * i)).rgb * weight[i] * ubo.blurStrength;
|
||||
result += texture(samplerColor, inUV - vec2(0.0, tex_offset.y * i)).rgb * weight[i] * ubo.blurStrength;
|
||||
}
|
||||
}
|
||||
|
||||
outFragColor = vec4(result, 1.0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue