Updated bloom example shaders
This commit is contained in:
parent
bfd0a2e0b4
commit
927660680d
10 changed files with 19 additions and 23 deletions
|
|
@ -10,8 +10,8 @@ layout (location = 2) in vec3 inColor;
|
|||
layout (binding = 0) uniform UBO
|
||||
{
|
||||
mat4 projection;
|
||||
mat4 view;
|
||||
mat4 model;
|
||||
vec4 glowColor;
|
||||
} ubo;
|
||||
|
||||
layout (location = 0) out vec3 outColor;
|
||||
|
|
@ -26,5 +26,5 @@ void main()
|
|||
{
|
||||
outUV = inUV;
|
||||
outColor = inColor;
|
||||
gl_Position = ubo.projection * ubo.model * inPos;
|
||||
gl_Position = ubo.projection * ubo.view * ubo.model * inPos;
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -5,13 +5,14 @@
|
|||
|
||||
layout (binding = 1) uniform sampler2D samplerColor;
|
||||
|
||||
layout (binding = 2) uniform UBO
|
||||
layout (binding = 0) uniform UBO
|
||||
{
|
||||
float blurScale;
|
||||
float blurStrength;
|
||||
int horizontal;
|
||||
} ubo;
|
||||
|
||||
layout (constant_id = 0) const int blurdirection = 0;
|
||||
|
||||
layout (location = 0) in vec2 inUV;
|
||||
|
||||
layout (location = 0) out vec4 outFragColor;
|
||||
|
|
@ -29,13 +30,15 @@ void main()
|
|||
vec3 result = texture(samplerColor, inUV).rgb * weight[0]; // current fragment's contribution
|
||||
for(int i = 1; i < 5; ++i)
|
||||
{
|
||||
if (ubo.horizontal == 1)
|
||||
if (blurdirection == 1)
|
||||
{
|
||||
// H
|
||||
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
|
||||
{
|
||||
// V
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -3,15 +3,6 @@
|
|||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (location = 0) in vec3 inPos;
|
||||
layout (location = 1) in vec2 inUV;
|
||||
|
||||
layout (binding = 0) uniform UBO
|
||||
{
|
||||
mat4 projection;
|
||||
mat4 model;
|
||||
} ubo;
|
||||
|
||||
layout (location = 0) out vec2 outUV;
|
||||
|
||||
out gl_PerVertex
|
||||
|
|
@ -21,6 +12,6 @@ out gl_PerVertex
|
|||
|
||||
void main()
|
||||
{
|
||||
outUV = inUV;
|
||||
gl_Position = ubo.projection * ubo.model * vec4(inPos.xyz, 1.0);
|
||||
outUV = vec2((gl_VertexIndex << 1) & 2, gl_VertexIndex & 2);
|
||||
gl_Position = vec4(outUV * 2.0f - 1.0f, 0.0f, 1.0f);
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -11,7 +11,8 @@ layout (location = 3) in vec3 inNormal;
|
|||
layout (binding = 0) uniform UBO
|
||||
{
|
||||
mat4 projection;
|
||||
mat4 modelview;
|
||||
mat4 view;
|
||||
mat4 model;
|
||||
} ubo;
|
||||
|
||||
layout (location = 0) out vec3 outNormal;
|
||||
|
|
@ -30,11 +31,11 @@ void main()
|
|||
outNormal = inNormal;
|
||||
outColor = inColor;
|
||||
outUV = inUV;
|
||||
gl_Position = ubo.projection * ubo.modelview * inPos;
|
||||
gl_Position = ubo.projection * ubo.view * ubo.model * inPos;
|
||||
|
||||
vec3 lightPos = vec3(-5.0, -5.0, 0.0);
|
||||
vec4 pos = ubo.modelview * inPos;
|
||||
outNormal = mat3(ubo.modelview) * inNormal;
|
||||
outLightVec = lightPos - pos.xyz;
|
||||
outViewVec = -pos.xyz;
|
||||
vec4 pos = ubo.view * ubo.model * inPos;
|
||||
outNormal = mat3(ubo.view * ubo.model) * inNormal;
|
||||
outLightVec = lightPos - pos.xyz;
|
||||
outViewVec = -pos.xyz;
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -8,6 +8,7 @@ layout (location = 0) in vec3 inPos;
|
|||
layout (binding = 0) uniform UBO
|
||||
{
|
||||
mat4 projection;
|
||||
mat4 view;
|
||||
mat4 model;
|
||||
} ubo;
|
||||
|
||||
|
|
@ -22,5 +23,5 @@ out gl_PerVertex
|
|||
void main()
|
||||
{
|
||||
outUVW = inPos;
|
||||
gl_Position = ubo.projection * ubo.model * vec4(inPos.xyz, 1.0);
|
||||
gl_Position = ubo.projection * ubo.view * ubo.model * vec4(inPos.xyz, 1.0);
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue