Added Vulkan examples sources!
This commit is contained in:
parent
367fda186b
commit
c91341813c
868 changed files with 514080 additions and 5584 deletions
29
data/shaders/displacement/base.frag
Normal file
29
data/shaders/displacement/base.frag
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (binding = 3) uniform sampler2D colorMap;
|
||||
|
||||
layout (location = 0) in vec3 inNormal;
|
||||
layout (location = 1) in vec2 inUV;
|
||||
layout (location = 2) in vec3 inEyePos;
|
||||
layout (location = 3) in vec3 inLightVec;
|
||||
|
||||
layout (location = 0) out vec4 outFragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 N = normalize(inNormal);
|
||||
vec3 L = normalize(vec3(1.0));
|
||||
|
||||
outFragColor.rgb = texture(colorMap, inUV).rgb;
|
||||
|
||||
vec3 Eye = normalize(-inEyePos);
|
||||
vec3 Reflected = normalize(reflect(-inLightVec, inNormal));
|
||||
|
||||
vec4 IAmbient = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
vec4 IDiffuse = vec4(1.0) * max(dot(inNormal, inLightVec), 0.0);
|
||||
|
||||
outFragColor = vec4((IAmbient + IDiffuse) * texture(colorMap, inUV));
|
||||
}
|
||||
BIN
data/shaders/displacement/base.frag.spv
Normal file
BIN
data/shaders/displacement/base.frag.spv
Normal file
Binary file not shown.
18
data/shaders/displacement/base.vert
Normal file
18
data/shaders/displacement/base.vert
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#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 = 0) out vec3 outNormal;
|
||||
layout (location = 1) out vec2 outUV;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = vec4(inPos.xyz, 1.0);
|
||||
outUV = inUV * 3.0;
|
||||
outNormal = inNormal;
|
||||
}
|
||||
BIN
data/shaders/displacement/base.vert.spv
Normal file
BIN
data/shaders/displacement/base.vert.spv
Normal file
Binary file not shown.
32
data/shaders/displacement/displacement.tesc
Normal file
32
data/shaders/displacement/displacement.tesc
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (binding = 0) uniform UBO
|
||||
{
|
||||
float tessLevel;
|
||||
} ubo;
|
||||
|
||||
layout (vertices = 3) out;
|
||||
|
||||
layout (location = 0) in vec3 inNormal[];
|
||||
layout (location = 1) in vec2 inUV[];
|
||||
|
||||
layout (location = 0) out vec3 outNormal[3];
|
||||
layout (location = 1) out vec2 outUV[3];
|
||||
|
||||
void main()
|
||||
{
|
||||
if (gl_InvocationID == 0)
|
||||
{
|
||||
gl_TessLevelInner[0] = ubo.tessLevel;
|
||||
gl_TessLevelOuter[0] = ubo.tessLevel;
|
||||
gl_TessLevelOuter[1] = ubo.tessLevel;
|
||||
gl_TessLevelOuter[2] = ubo.tessLevel;
|
||||
}
|
||||
|
||||
gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
|
||||
outNormal[gl_InvocationID] = inNormal[gl_InvocationID];
|
||||
outUV[gl_InvocationID] = inUV[gl_InvocationID];
|
||||
}
|
||||
BIN
data/shaders/displacement/displacement.tesc.spv
Normal file
BIN
data/shaders/displacement/displacement.tesc.spv
Normal file
Binary file not shown.
40
data/shaders/displacement/displacement.tese
Normal file
40
data/shaders/displacement/displacement.tese
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (binding = 1) uniform UBO
|
||||
{
|
||||
mat4 projection;
|
||||
mat4 model;
|
||||
vec4 lightPos;
|
||||
float tessAlpha;
|
||||
float tessStrength;
|
||||
} ubo;
|
||||
|
||||
layout (binding = 2) uniform sampler2D displacementMap;
|
||||
|
||||
layout(triangles, equal_spacing, ccw) in;
|
||||
|
||||
layout (location = 0) in vec3 inNormal[];
|
||||
layout (location = 1) in vec2 inUV[];
|
||||
|
||||
layout (location = 0) out vec3 outNormal;
|
||||
layout (location = 1) out vec2 outUV;
|
||||
layout (location = 2) out vec3 outEyesPos;
|
||||
layout (location = 3) out vec3 outLightVec;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
gl_Position = (gl_TessCoord.x * gl_in[0].gl_Position) + (gl_TessCoord.y * gl_in[1].gl_Position) + (gl_TessCoord.z * gl_in[2].gl_Position);
|
||||
outUV = gl_TessCoord.x * inUV[0] + gl_TessCoord.y * inUV[1] + gl_TessCoord.z * inUV[2];
|
||||
outNormal = gl_TessCoord.x * inNormal[0] + gl_TessCoord.y * inNormal[1] + gl_TessCoord.z * inNormal[2];
|
||||
|
||||
gl_Position.xyz += normalize(outNormal) * (max(texture(displacementMap, outUV.st).r, 0.45) * ubo.tessStrength);
|
||||
|
||||
outEyesPos = (gl_Position).xyz;
|
||||
outLightVec = normalize(ubo.lightPos.xyz - outEyesPos);
|
||||
|
||||
gl_Position = ubo.projection * ubo.model * gl_Position;
|
||||
}
|
||||
BIN
data/shaders/displacement/displacement.tese.spv
Normal file
BIN
data/shaders/displacement/displacement.tese.spv
Normal file
Binary file not shown.
7
data/shaders/displacement/generate-spirv.bat
Normal file
7
data/shaders/displacement/generate-spirv.bat
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
glslangvalidator -V base.vert -o base.vert.spv
|
||||
glslangvalidator -V base.frag -o base.frag.spv
|
||||
glslangvalidator -V passthrough.tesc -o passthrough.tesc.spv
|
||||
glslangvalidator -V passthrough.tese -o passthrough.tese.spv
|
||||
glslangvalidator -V displacement.tesc -o displacement.tesc.spv
|
||||
glslangvalidator -V displacement.tese -o displacement.tese.spv
|
||||
|
||||
26
data/shaders/displacement/passthrough.tesc
Normal file
26
data/shaders/displacement/passthrough.tesc
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (vertices = 3) out;
|
||||
|
||||
layout (location = 0) in vec3 inNormal[];
|
||||
layout (location = 1) in vec2 inTexCoord[];
|
||||
layout (location = 0) out vec3 outNormal[3];
|
||||
layout (location = 3) out vec2 oTexCoord[3];
|
||||
|
||||
void main(void)
|
||||
{
|
||||
if (gl_InvocationID == 0)
|
||||
{
|
||||
gl_TessLevelInner[0] = 1.0;
|
||||
gl_TessLevelOuter[0] = 1.0;
|
||||
gl_TessLevelOuter[1] = 1.0;
|
||||
gl_TessLevelOuter[2] = 1.0;
|
||||
}
|
||||
|
||||
gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
|
||||
outNormal[gl_InvocationID] = inNormal[gl_InvocationID];
|
||||
oTexCoord[gl_InvocationID] = inTexCoord[gl_InvocationID];
|
||||
}
|
||||
BIN
data/shaders/displacement/passthrough.tesc.spv
Normal file
BIN
data/shaders/displacement/passthrough.tesc.spv
Normal file
Binary file not shown.
34
data/shaders/displacement/passthrough.tese
Normal file
34
data/shaders/displacement/passthrough.tese
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (triangles) in;
|
||||
|
||||
layout (binding = 1) uniform UBO
|
||||
{
|
||||
mat4 projection;
|
||||
mat4 model;
|
||||
vec3 lightPos;
|
||||
float tessAlpha;
|
||||
float tessStrength;
|
||||
} ubo;
|
||||
|
||||
layout (location = 0) in vec3 inNormal[];
|
||||
layout (location = 3) in vec2 inTexCoord[];
|
||||
layout (location = 0) out vec3 outNormal;
|
||||
layout (location = 1) out vec2 outTexCoord;
|
||||
layout (location = 2) out vec3 outEyesPos;
|
||||
layout (location = 3) out vec3 outLightVec;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = (gl_TessCoord.x * gl_in[0].gl_Position) + (gl_TessCoord.y * gl_in[1].gl_Position) + (gl_TessCoord.z * gl_in[2].gl_Position);
|
||||
outNormal = gl_TessCoord.x * inNormal[0] + gl_TessCoord.y * inNormal[1] + gl_TessCoord.z * inNormal[2];
|
||||
outTexCoord = gl_TessCoord.x * inTexCoord[0] + gl_TessCoord.y * inTexCoord[1] + gl_TessCoord.z * inTexCoord[2];
|
||||
gl_Position.xyz += normalize(outNormal);
|
||||
outEyesPos = (gl_Position).xyz;
|
||||
outLightVec = normalize(ubo.lightPos - outEyesPos);
|
||||
gl_Position = ubo.projection * ubo.model * gl_Position;
|
||||
|
||||
}
|
||||
BIN
data/shaders/displacement/passthrough.tese.spv
Normal file
BIN
data/shaders/displacement/passthrough.tese.spv
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue