Added post processing pass
This commit is contained in:
parent
9dbf252e27
commit
9ace87aca3
15 changed files with 510 additions and 43 deletions
13
data/shaders/debugmarker/colorpass.frag
Normal file
13
data/shaders/debugmarker/colorpass.frag
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (location = 0) in vec3 inColor;
|
||||
|
||||
layout (location = 0) out vec4 outFragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
outFragColor.rgb = inColor;
|
||||
}
|
||||
BIN
data/shaders/debugmarker/colorpass.frag.spv
Normal file
BIN
data/shaders/debugmarker/colorpass.frag.spv
Normal file
Binary file not shown.
28
data/shaders/debugmarker/colorpass.vert
Normal file
28
data/shaders/debugmarker/colorpass.vert
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (location = 0) in vec4 inPos;
|
||||
layout (location = 3) in vec3 inColor;
|
||||
|
||||
layout (binding = 0) uniform UBO
|
||||
{
|
||||
mat4 projection;
|
||||
mat4 model;
|
||||
} ubo;
|
||||
|
||||
layout (location = 0) out vec3 outColor;
|
||||
|
||||
out gl_PerVertex
|
||||
{
|
||||
vec4 gl_Position;
|
||||
};
|
||||
|
||||
void main()
|
||||
{
|
||||
{
|
||||
outColor = inColor;
|
||||
}
|
||||
gl_Position = ubo.projection * ubo.model * inPos;
|
||||
}
|
||||
BIN
data/shaders/debugmarker/colorpass.vert.spv
Normal file
BIN
data/shaders/debugmarker/colorpass.vert.spv
Normal file
Binary file not shown.
|
|
@ -1,2 +1,6 @@
|
|||
glslangvalidator -V mesh.vert -o mesh.vert.spv
|
||||
glslangvalidator -V mesh.frag -o mesh.frag.spv
|
||||
glslangvalidator -V phongpass.vert -o phongpass.vert.spv
|
||||
glslangvalidator -V phongpass.frag -o phongpass.frag.spv
|
||||
glslangvalidator -V colorpass.vert -o colorpass.vert.spv
|
||||
glslangvalidator -V colorpass.frag -o colorpass.frag.spv
|
||||
glslangvalidator -V postprocess.vert -o postprocess.vert.spv
|
||||
glslangvalidator -V postprocess.frag -o postprocess.frag.spv
|
||||
Binary file not shown.
|
|
@ -15,11 +15,16 @@ layout (location = 0) out vec4 outFragColor;
|
|||
|
||||
void main()
|
||||
{
|
||||
// Desaturate color
|
||||
vec3 color = vec3(mix(inColor, vec3(dot(vec3(0.2126,0.7152,0.0722), inColor)), 0.65));
|
||||
|
||||
// High ambient colors because mesh materials are pretty dark
|
||||
vec3 ambient = color * vec3(1.0);
|
||||
vec3 N = normalize(inNormal);
|
||||
vec3 L = normalize(inLightVec);
|
||||
vec3 V = normalize(inViewVec);
|
||||
vec3 R = reflect(-L, N);
|
||||
vec3 diffuse = max(dot(N, L), 0.25) * inColor;
|
||||
vec3 diffuse = max(dot(N, L), 0.0) * color;
|
||||
vec3 specular = pow(max(dot(R, V), 0.0), 16.0) * vec3(0.75);
|
||||
outFragColor = vec4(diffuse * 1.75 + specular, 1.0);
|
||||
outFragColor = vec4(ambient + diffuse * 1.75 + specular, 1.0);
|
||||
}
|
||||
BIN
data/shaders/debugmarker/phongpass.frag.spv
Normal file
BIN
data/shaders/debugmarker/phongpass.frag.spv
Normal file
Binary file not shown.
42
data/shaders/debugmarker/postprocess.frag
Normal file
42
data/shaders/debugmarker/postprocess.frag
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (binding = 1) uniform sampler2D samplerColor;
|
||||
|
||||
layout (location = 0) in vec2 inUV;
|
||||
|
||||
layout (location = 0) out vec4 outFragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Single pass gauss blur
|
||||
|
||||
const vec2 texOffset = vec2(0.01, 0.01);
|
||||
|
||||
vec2 tc0 = inUV + vec2(-texOffset.s, -texOffset.t);
|
||||
vec2 tc1 = inUV + vec2( 0.0, -texOffset.t);
|
||||
vec2 tc2 = inUV + vec2(+texOffset.s, -texOffset.t);
|
||||
vec2 tc3 = inUV + vec2(-texOffset.s, 0.0);
|
||||
vec2 tc4 = inUV + vec2( 0.0, 0.0);
|
||||
vec2 tc5 = inUV + vec2(+texOffset.s, 0.0);
|
||||
vec2 tc6 = inUV + vec2(-texOffset.s, +texOffset.t);
|
||||
vec2 tc7 = inUV + vec2( 0.0, +texOffset.t);
|
||||
vec2 tc8 = inUV + vec2(+texOffset.s, +texOffset.t);
|
||||
|
||||
vec4 col0 = texture(samplerColor, tc0);
|
||||
vec4 col1 = texture(samplerColor, tc1);
|
||||
vec4 col2 = texture(samplerColor, tc2);
|
||||
vec4 col3 = texture(samplerColor, tc3);
|
||||
vec4 col4 = texture(samplerColor, tc4);
|
||||
vec4 col5 = texture(samplerColor, tc5);
|
||||
vec4 col6 = texture(samplerColor, tc6);
|
||||
vec4 col7 = texture(samplerColor, tc7);
|
||||
vec4 col8 = texture(samplerColor, tc8);
|
||||
|
||||
vec4 sum = (1.0 * col0 + 2.0 * col1 + 1.0 * col2 +
|
||||
2.0 * col3 + 4.0 * col4 + 2.0 * col5 +
|
||||
1.0 * col6 + 2.0 * col7 + 1.0 * col8) / 16.0;
|
||||
outFragColor = vec4(sum.rgb, 1.0);
|
||||
}
|
||||
BIN
data/shaders/debugmarker/postprocess.frag.spv
Normal file
BIN
data/shaders/debugmarker/postprocess.frag.spv
Normal file
Binary file not shown.
17
data/shaders/debugmarker/postprocess.vert
Normal file
17
data/shaders/debugmarker/postprocess.vert
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (location = 0) out vec2 outUV;
|
||||
|
||||
out gl_PerVertex
|
||||
{
|
||||
vec4 gl_Position;
|
||||
};
|
||||
|
||||
void main()
|
||||
{
|
||||
outUV = vec2((gl_VertexIndex << 1) & 2, gl_VertexIndex & 2);
|
||||
gl_Position = vec4(outUV * vec2(2.0f, 2.0f) + vec2(-1.0f, -1.0f), 0.0f, 1.0f);
|
||||
}
|
||||
BIN
data/shaders/debugmarker/postprocess.vert.spv
Normal file
BIN
data/shaders/debugmarker/postprocess.vert.spv
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue