Added SSAO example (wip)
This commit is contained in:
parent
ad26540e4f
commit
9212a9e3cb
16 changed files with 1558 additions and 0 deletions
51
data/shaders/ssao/composition.frag
Normal file
51
data/shaders/ssao/composition.frag
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (binding = 0) uniform sampler2D samplerposition;
|
||||
layout (binding = 1) uniform sampler2D samplerNormal;
|
||||
layout (binding = 2) uniform sampler2D samplerAlbedo;
|
||||
layout (binding = 3) uniform sampler2D samplerSSAO;
|
||||
layout (binding = 4) uniform sampler2D samplerSSAOBlur;
|
||||
layout (binding = 5) uniform UBO
|
||||
{
|
||||
mat4 _dummy;
|
||||
uint ssao;
|
||||
uint ssaoOnly;
|
||||
uint ssaoBlur;
|
||||
} uboParams;
|
||||
|
||||
layout (location = 0) in vec2 inUV;
|
||||
|
||||
layout (location = 0) out vec4 outFragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 fragPos = texture(samplerposition, inUV).rgb;
|
||||
vec3 normal = texture(samplerNormal, inUV).rgb;
|
||||
vec4 albedo = texture(samplerAlbedo, inUV);
|
||||
|
||||
float ssao = (uboParams.ssaoBlur == 1) ? texture(samplerSSAOBlur, inUV).r : texture(samplerSSAO, inUV).r;
|
||||
|
||||
outFragColor = vec4(vec3(0.0), 1.0);
|
||||
|
||||
if (uboParams.ssaoOnly == 1)
|
||||
{
|
||||
outFragColor.rgb = ssao.rrr;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (uboParams.ssao == 1)
|
||||
{
|
||||
outFragColor.rgb = ssao.rrr;
|
||||
|
||||
if (uboParams.ssaoOnly != 1)
|
||||
outFragColor.rgb *= albedo.rgb;
|
||||
}
|
||||
else
|
||||
{
|
||||
outFragColor.rgb = albedo.rgb;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue