Skeletal animation example shaders, code cleanup, etc.
This commit is contained in:
parent
54ddca7c08
commit
1359058d24
11 changed files with 65 additions and 121 deletions
|
|
@ -40,14 +40,13 @@ void main()
|
|||
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.view * ubo.model * boneTransform * vec4(inPos.xyz, 1.0);
|
||||
|
||||
vec4 pos = ubo.model * vec4(inPos, 1.0);
|
||||
outNormal = mat3(inverse(transpose(ubo.model))) * inNormal;
|
||||
outNormal = mat3(inverse(transpose(ubo.model * boneTransform))) * inNormal;
|
||||
outLightVec = ubo.lightPos.xyz - pos.xyz;
|
||||
outViewVec = ubo.viewPos.xyz - pos.xyz;
|
||||
}
|
||||
Binary file not shown.
|
|
@ -19,14 +19,13 @@ void main()
|
|||
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);
|
||||
const float attInvRadius = 1.0/5000.0;
|
||||
float atten = max(clamp(1.0 - attInvRadius * 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);
|
||||
const float shadowInvRadius = 1.0/2500.0;
|
||||
float dropshadow = max(clamp(1.0 - shadowInvRadius * sqrt(distSqr), 0.0, 1.0), 0.0);
|
||||
|
||||
outFragColor = vec4(color.g * (1.0 - dropshadow));
|
||||
outFragColor = vec4(color.rgba * (1.0 - dropshadow));
|
||||
outFragColor.rgb *= atten;
|
||||
}
|
||||
Binary file not shown.
|
|
@ -29,7 +29,7 @@ out gl_PerVertex
|
|||
|
||||
void main()
|
||||
{
|
||||
outUV = inUV * 2.0 + ubo.uvOffset;
|
||||
outUV = inUV + ubo.uvOffset;
|
||||
vec4 pos = vec4(inPos, 1.0);
|
||||
gl_Position = ubo.projection * ubo.view * ubo.model * vec4(pos);
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue