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:
parent
cac1d2e850
commit
ca884587a4
1043 changed files with 1207 additions and 1201 deletions
7
data/shaders/glsl/pipelines/generate-spriv.bat
Normal file
7
data/shaders/glsl/pipelines/generate-spriv.bat
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
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
|
||||
|
||||
27
data/shaders/glsl/pipelines/phong.frag
Normal file
27
data/shaders/glsl/pipelines/phong.frag
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#version 450
|
||||
|
||||
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/glsl/pipelines/phong.frag.spv
Normal file
BIN
data/shaders/glsl/pipelines/phong.frag.spv
Normal file
Binary file not shown.
38
data/shaders/glsl/pipelines/phong.vert
Normal file
38
data/shaders/glsl/pipelines/phong.vert
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#version 450
|
||||
|
||||
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/glsl/pipelines/phong.vert.spv
Normal file
BIN
data/shaders/glsl/pipelines/phong.vert.spv
Normal file
Binary file not shown.
36
data/shaders/glsl/pipelines/toon.frag
Normal file
36
data/shaders/glsl/pipelines/toon.frag
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#version 450
|
||||
|
||||
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/glsl/pipelines/toon.frag.spv
Normal file
BIN
data/shaders/glsl/pipelines/toon.frag.spv
Normal file
Binary file not shown.
38
data/shaders/glsl/pipelines/toon.vert
Normal file
38
data/shaders/glsl/pipelines/toon.vert
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#version 450
|
||||
|
||||
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/glsl/pipelines/toon.vert.spv
Normal file
BIN
data/shaders/glsl/pipelines/toon.vert.spv
Normal file
Binary file not shown.
10
data/shaders/glsl/pipelines/wireframe.frag
Normal file
10
data/shaders/glsl/pipelines/wireframe.frag
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#version 450
|
||||
|
||||
layout (location = 0) in vec3 inColor;
|
||||
|
||||
layout (location = 0) out vec4 outFragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
outFragColor.rgb = inColor * 1.5;
|
||||
}
|
||||
BIN
data/shaders/glsl/pipelines/wireframe.frag.spv
Normal file
BIN
data/shaders/glsl/pipelines/wireframe.frag.spv
Normal file
Binary file not shown.
25
data/shaders/glsl/pipelines/wireframe.vert
Normal file
25
data/shaders/glsl/pipelines/wireframe.vert
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#version 450
|
||||
|
||||
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/glsl/pipelines/wireframe.vert.spv
Normal file
BIN
data/shaders/glsl/pipelines/wireframe.vert.spv
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue