Skinned mesh stuff moved to class, added resources
This commit is contained in:
parent
26b02736d5
commit
7087d7d14e
19 changed files with 2637 additions and 14775 deletions
|
|
@ -1,2 +1,4 @@
|
|||
glslangvalidator -V mesh.vert -o mesh.vert.spv
|
||||
glslangvalidator -V mesh.frag -o mesh.frag.spv
|
||||
glslangvalidator -V mesh.frag -o mesh.frag.spv
|
||||
glslangvalidator -V texture.vert -o texture.vert.spv
|
||||
glslangvalidator -V texture.frag -o texture.frag.spv
|
||||
|
|
@ -8,27 +8,20 @@ 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 inEyePos;
|
||||
layout (location = 3) in vec3 inViewVec;
|
||||
layout (location = 4) in vec3 inLightVec;
|
||||
|
||||
layout (location = 0) out vec4 outFragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 N = normalize(inNormal);
|
||||
vec3 L = normalize(vec3(1.0));
|
||||
|
||||
vec3 Eye = normalize(-inEyePos);
|
||||
vec3 Reflected = normalize(reflect(-inLightVec, inNormal));
|
||||
|
||||
vec4 IAmbient = vec4(vec3(0.25), 1.0);
|
||||
vec4 IDiffuse = vec4(1.0) * max(dot(inNormal, inLightVec), 0.0);
|
||||
|
||||
float specular = 0.75 * 0.0;
|
||||
vec4 ISpecular = vec4(0.5, 0.5, 0.5, 1.0) * pow(max(dot(Reflected, Eye), 0.0), 4.0) * specular;
|
||||
|
||||
vec4 color = texture(samplerColorMap, inUV) * vec4(inColor, 1.0);
|
||||
|
||||
outFragColor = vec4((IAmbient + IDiffuse) * color + (ISpecular * IDiffuse));
|
||||
|
||||
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) * vec3(1.0);// * inColor;
|
||||
vec3 specular = pow(max(dot(R, V), 0.0), 32.0) * vec3(0.5);
|
||||
outFragColor = vec4(diffuse * color.rgb + specular, 1.0);
|
||||
}
|
||||
Binary file not shown.
|
|
@ -10,7 +10,7 @@ layout (location = 3) in vec3 inColor;
|
|||
layout (location = 4) in vec4 inBoneWeights;
|
||||
layout (location = 5) in ivec4 inBoneIDs;
|
||||
|
||||
#define MAX_BONES 128
|
||||
#define MAX_BONES 64
|
||||
|
||||
layout (binding = 0) uniform UBO
|
||||
{
|
||||
|
|
@ -18,12 +18,13 @@ layout (binding = 0) uniform UBO
|
|||
mat4 model;
|
||||
mat4 bones[MAX_BONES];
|
||||
vec4 lightPos;
|
||||
vec4 viewPos;
|
||||
} ubo;
|
||||
|
||||
layout (location = 0) out vec3 outNormal;
|
||||
layout (location = 1) out vec3 outColor;
|
||||
layout (location = 2) out vec2 outUV;
|
||||
layout (location = 3) out vec3 outEyePos;
|
||||
layout (location = 3) out vec3 outViewVec;
|
||||
layout (location = 4) out vec3 outLightVec;
|
||||
|
||||
void main()
|
||||
|
|
@ -32,15 +33,15 @@ void main()
|
|||
boneTransform += ubo.bones[inBoneIDs[1]] * inBoneWeights[1];
|
||||
boneTransform += ubo.bones[inBoneIDs[2]] * inBoneWeights[2];
|
||||
boneTransform += ubo.bones[inBoneIDs[3]] * inBoneWeights[3];
|
||||
|
||||
|
||||
outNormal = inNormal;
|
||||
outColor = inColor;
|
||||
outUV = inUV;
|
||||
|
||||
gl_Position = ubo.projection * ubo.model * boneTransform * vec4(inPos.xyz, 1.0);
|
||||
|
||||
outEyePos = (gl_Position).xyz;
|
||||
|
||||
vec4 lightPos = ubo.lightPos;
|
||||
outLightVec = normalize(lightPos.xyz - outEyePos);
|
||||
vec4 pos = ubo.model * vec4(inPos, 1.0);
|
||||
outNormal = mat3(inverse(transpose(ubo.model))) * inNormal;
|
||||
outLightVec = ubo.lightPos.xyz - pos.xyz;
|
||||
outViewVec = ubo.viewPos.xyz - pos.xyz;
|
||||
}
|
||||
Binary file not shown.
32
data/shaders/skeletalanimation/texture.frag
Normal file
32
data/shaders/skeletalanimation/texture.frag
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#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 vec2 inUV;
|
||||
layout (location = 1) in vec3 inNormal;
|
||||
layout (location = 2) in vec3 inViewVec;
|
||||
layout (location = 3) in vec3 inLightVec;
|
||||
|
||||
layout (location = 0) out vec4 outFragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 color = texture(samplerColorMap, inUV);
|
||||
|
||||
float distSqr = dot(inLightVec, inLightVec);
|
||||
vec3 lVec = inLightVec * inversesqrt(distSqr);
|
||||
|
||||
float invRadius = 1.0/4500.0;
|
||||
|
||||
float atten = max(clamp(1.0 - invRadius * sqrt(distSqr), 0.0, 1.0), 0.0);
|
||||
|
||||
// Fake drop shadow
|
||||
invRadius = 1.0/2500.0;
|
||||
float dropshadow = max(clamp(1.0 - invRadius * sqrt(distSqr), 0.0, 1.0), 0.0);
|
||||
|
||||
outFragColor = vec4(color.g * (1.0 - dropshadow));
|
||||
outFragColor.rgb *= atten;
|
||||
}
|
||||
BIN
data/shaders/skeletalanimation/texture.frag.spv
Normal file
BIN
data/shaders/skeletalanimation/texture.frag.spv
Normal file
Binary file not shown.
33
data/shaders/skeletalanimation/texture.vert
Normal file
33
data/shaders/skeletalanimation/texture.vert
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#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 (binding = 0) uniform UBO
|
||||
{
|
||||
mat4 projection;
|
||||
mat4 model;
|
||||
vec4 lightPos;
|
||||
vec4 viewPos;
|
||||
vec2 uvOffset;
|
||||
} ubo;
|
||||
|
||||
layout (location = 0) out vec2 outUV;
|
||||
layout (location = 1) out vec3 outNormal;
|
||||
layout (location = 2) out vec3 outViewVec;
|
||||
layout (location = 3) out vec3 outLightVec;
|
||||
|
||||
void main()
|
||||
{
|
||||
outUV = inUV * 2.0 + ubo.uvOffset;
|
||||
vec4 pos = vec4(inPos, 1.0);
|
||||
gl_Position = ubo.projection * ubo.model * vec4(pos);
|
||||
|
||||
outNormal = mat3(ubo.model) * inNormal;
|
||||
outLightVec = ubo.lightPos.xyz - pos.xyz;
|
||||
outViewVec = ubo.viewPos.xyz - pos.xyz;
|
||||
}
|
||||
BIN
data/shaders/skeletalanimation/texture.vert.spv
Normal file
BIN
data/shaders/skeletalanimation/texture.vert.spv
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue