Move shaders into glsl and hlsl directories

Move `data/shaders` to `data/shaders/glsl`
Move `data/hlsl` to `data/shaders/hlsl`

Fix up shader paths in the cpp files to point to the new glsl location.

`data/shaders/hlsl/compile.py` still overwrites the glsl .spv files (for
now).

Issue: #723
This commit is contained in:
Ben Clayton 2020-05-29 16:08:53 +01:00
parent cac1d2e850
commit ca884587a4
1043 changed files with 1207 additions and 1201 deletions

View file

@ -0,0 +1,26 @@
#version 450
layout (binding = 2) 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) * vec4(texture(colorMap, inUV).rgb, 1.0));
}

Binary file not shown.

View file

@ -0,0 +1,15 @@
#version 450
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;
}

Binary file not shown.

View file

@ -0,0 +1,29 @@
#version 450
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];
}

Binary file not shown.

View file

@ -0,0 +1,36 @@
#version 450
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(textureLod(displacementMap, outUV.st, 0.0).a, 0.0) * ubo.tessStrength);
outEyesPos = (gl_Position).xyz;
outLightVec = normalize(ubo.lightPos.xyz - outEyesPos);
gl_Position = ubo.projection * ubo.model * gl_Position;
}

Binary file not shown.

View file

@ -0,0 +1,5 @@
glslangvalidator -V base.vert -o base.vert.spv
glslangvalidator -V base.frag -o base.frag.spv
glslangvalidator -V displacement.tesc -o displacement.tesc.spv
glslangvalidator -V displacement.tese -o displacement.tese.spv