Updated pipelines demo with new scene, shaders and pipeline derivatives
This commit is contained in:
parent
6ad7e5e9ba
commit
aa9f2405dd
26 changed files with 261 additions and 187 deletions
|
|
@ -1,28 +0,0 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (location = 0) in vec3 inPos;
|
||||
layout (location = 1) in vec3 inColor;
|
||||
layout (location = 2) in vec2 inUV;
|
||||
layout (location = 3) in vec3 inNormal;
|
||||
|
||||
layout (binding = 0) uniform UBO
|
||||
{
|
||||
mat4 projectionMatrix;
|
||||
mat4 modelMatrix;
|
||||
mat4 viewMatrix;
|
||||
} ubo;
|
||||
|
||||
layout (location = 0) out vec3 outColor;
|
||||
layout (location = 1) out vec2 outUV;
|
||||
layout (location = 2) out vec3 outNormal;
|
||||
|
||||
void main()
|
||||
{
|
||||
outColor = inColor;
|
||||
outUV = inUV;
|
||||
outNormal = inNormal;
|
||||
gl_Position = ubo.projectionMatrix * ubo.viewMatrix * ubo.modelMatrix * vec4(inPos.xyz, 1.0);
|
||||
}
|
||||
Binary file not shown.
|
|
@ -1,10 +0,0 @@
|
|||
#version 450
|
||||
|
||||
layout (location = 0 ) in vec3 inColor;
|
||||
|
||||
layout (location = 0) out vec4 outFragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
outFragColor = vec4(inColor, 1.0);
|
||||
}
|
||||
Binary file not shown.
|
|
@ -1,6 +1,7 @@
|
|||
glslangvalidator -V base.vert -o base.vert.spv
|
||||
glslangvalidator -V base.frag -o base.frag.spv
|
||||
glslangvalidator -V color.frag -o color.frag.spv
|
||||
glslangvalidator -V texture.frag -o texture.frag.spv
|
||||
glslangvalidator -V phong.vert -o phong.vert.spv
|
||||
glslangvalidator -V phong.frag -o phong.frag.spv
|
||||
glslangvalidator -V wireframe.vert -o wireframe.vert.spv
|
||||
glslangvalidator -V wireframe.frag -o wireframe.frag.spv
|
||||
glslangvalidator -V toon.vert -o toon.vert.spv
|
||||
glslangvalidator -V toon.frag -o toon.frag.spv
|
||||
|
||||
|
|
|
|||
30
data/shaders/pipelines/phong.frag
Normal file
30
data/shaders/pipelines/phong.frag
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (binding = 1) uniform sampler2D samplerColorMap;
|
||||
|
||||
layout (location = 0) in vec3 inNormal;
|
||||
layout (location = 1) in vec3 inColor;
|
||||
layout (location = 2) in vec2 inUV;
|
||||
layout (location = 3) in vec3 inViewVec;
|
||||
layout (location = 4) in vec3 inLightVec;
|
||||
|
||||
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.0) * color;
|
||||
vec3 specular = pow(max(dot(R, V), 0.0), 32.0) * vec3(0.35);
|
||||
outFragColor = vec4(ambient + diffuse * 1.75 + specular, 1.0);
|
||||
}
|
||||
BIN
data/shaders/pipelines/phong.frag.spv
Normal file
BIN
data/shaders/pipelines/phong.frag.spv
Normal file
Binary file not shown.
41
data/shaders/pipelines/phong.vert
Normal file
41
data/shaders/pipelines/phong.vert
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (location = 0) in vec3 inPos;
|
||||
layout (location = 1) in vec3 inNormal;
|
||||
layout (location = 2) in vec2 inUV;
|
||||
layout (location = 3) in vec3 inColor;
|
||||
|
||||
layout (binding = 0) uniform UBO
|
||||
{
|
||||
mat4 projection;
|
||||
mat4 model;
|
||||
vec4 lightPos;
|
||||
} ubo;
|
||||
|
||||
layout (location = 0) out vec3 outNormal;
|
||||
layout (location = 1) out vec3 outColor;
|
||||
layout (location = 2) out vec2 outUV;
|
||||
layout (location = 3) out vec3 outViewVec;
|
||||
layout (location = 4) out vec3 outLightVec;
|
||||
|
||||
out gl_PerVertex
|
||||
{
|
||||
vec4 gl_Position;
|
||||
};
|
||||
|
||||
void main()
|
||||
{
|
||||
outNormal = inNormal;
|
||||
outColor = inColor;
|
||||
outUV = inUV;
|
||||
gl_Position = ubo.projection * ubo.model * vec4(inPos.xyz, 1.0);
|
||||
|
||||
vec4 pos = ubo.model * vec4(inPos, 1.0);
|
||||
outNormal = mat3(ubo.model) * inNormal;
|
||||
vec3 lPos = mat3(ubo.model) * ubo.lightPos.xyz;
|
||||
outLightVec = lPos - pos.xyz;
|
||||
outViewVec = -pos.xyz;
|
||||
}
|
||||
BIN
data/shaders/pipelines/phong.vert.spv
Normal file
BIN
data/shaders/pipelines/phong.vert.spv
Normal file
Binary file not shown.
|
|
@ -1,21 +0,0 @@
|
|||
#version 450
|
||||
|
||||
layout (binding = 1) uniform sampler2D colorMap;
|
||||
|
||||
layout (location = 1) in vec2 inUV;
|
||||
layout (location = 2) in vec3 inNormal;
|
||||
|
||||
layout (location = 0) out vec4 outFragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
outFragColor = texture(colorMap, inUV);
|
||||
outFragColor.rgb = inNormal;
|
||||
|
||||
vec3 N = normalize(inNormal);
|
||||
vec3 L = normalize(vec3(2.0, 2.0, 2.0));
|
||||
|
||||
vec3 color = texture(colorMap, inUV).rgb;
|
||||
outFragColor.rgb = vec3(clamp(max(dot(N,L), 0.0), 0.15, 1.0)) * color;
|
||||
}
|
||||
|
||||
Binary file not shown.
39
data/shaders/pipelines/toon.frag
Normal file
39
data/shaders/pipelines/toon.frag
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (binding = 1) uniform sampler2D samplerColorMap;
|
||||
|
||||
layout (location = 0) in vec3 inNormal;
|
||||
layout (location = 1) in vec3 inColor;
|
||||
layout (location = 2) in vec2 inUV;
|
||||
layout (location = 3) in vec3 inViewVec;
|
||||
layout (location = 4) in vec3 inLightVec;
|
||||
|
||||
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.0) * color;
|
||||
vec3 specular = pow(max(dot(R, V), 0.0), 16.0) * vec3(0.75);
|
||||
outFragColor = vec4(ambient + diffuse * 1.75 + specular, 1.0);
|
||||
|
||||
float intensity = dot(N,L);
|
||||
float shade = 1.0;
|
||||
shade = intensity < 0.5 ? 0.75 : shade;
|
||||
shade = intensity < 0.35 ? 0.6 : shade;
|
||||
shade = intensity < 0.25 ? 0.5 : shade;
|
||||
shade = intensity < 0.1 ? 0.25 : shade;
|
||||
|
||||
outFragColor.rgb = inColor * 3.0 * shade;
|
||||
}
|
||||
BIN
data/shaders/pipelines/toon.frag.spv
Normal file
BIN
data/shaders/pipelines/toon.frag.spv
Normal file
Binary file not shown.
41
data/shaders/pipelines/toon.vert
Normal file
41
data/shaders/pipelines/toon.vert
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (location = 0) in vec3 inPos;
|
||||
layout (location = 1) in vec3 inNormal;
|
||||
layout (location = 2) in vec2 inUV;
|
||||
layout (location = 3) in vec3 inColor;
|
||||
|
||||
layout (binding = 0) uniform UBO
|
||||
{
|
||||
mat4 projection;
|
||||
mat4 model;
|
||||
vec4 lightPos;
|
||||
} ubo;
|
||||
|
||||
layout (location = 0) out vec3 outNormal;
|
||||
layout (location = 1) out vec3 outColor;
|
||||
layout (location = 2) out vec2 outUV;
|
||||
layout (location = 3) out vec3 outViewVec;
|
||||
layout (location = 4) out vec3 outLightVec;
|
||||
|
||||
out gl_PerVertex
|
||||
{
|
||||
vec4 gl_Position;
|
||||
};
|
||||
|
||||
void main()
|
||||
{
|
||||
outNormal = inNormal;
|
||||
outColor = inColor;
|
||||
outUV = inUV;
|
||||
gl_Position = ubo.projection * ubo.model * vec4(inPos.xyz, 1.0);
|
||||
|
||||
vec4 pos = ubo.model * vec4(inPos, 1.0);
|
||||
outNormal = mat3(ubo.model) * inNormal;
|
||||
vec3 lPos = mat3(ubo.model) * ubo.lightPos.xyz;
|
||||
outLightVec = lPos - pos.xyz;
|
||||
outViewVec = -pos.xyz;
|
||||
}
|
||||
BIN
data/shaders/pipelines/toon.vert.spv
Normal file
BIN
data/shaders/pipelines/toon.vert.spv
Normal file
Binary file not shown.
|
|
@ -1,10 +1,13 @@
|
|||
#version 450
|
||||
|
||||
layout (location = 0 ) in vec3 inColor;
|
||||
#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 = vec4(1.0);
|
||||
outFragColor.rgb = inColor * 1.5;
|
||||
}
|
||||
Binary file not shown.
28
data/shaders/pipelines/wireframe.vert
Normal file
28
data/shaders/pipelines/wireframe.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/pipelines/wireframe.vert.spv
Normal file
BIN
data/shaders/pipelines/wireframe.vert.spv
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue