Pong/resources/shaders/SolidColorAnimated.vert

38 lines
887 B
GLSL
Raw Normal View History

2024-07-01 19:55:24 -07:00
#version 450
#extension GL_EXT_scalar_block_layout : enable
#define MAX_WEIGHTS 3
#define MAX_BONES 50
layout(binding = 0) uniform Transform
{
mat4 viewProj;
mat4 model;
mat4 bones[MAX_BONES];
} transform;
layout(location = 0) in vec3 vNorm;
layout(location = 1) in vec3 vPos;
layout(location = 2) in uvec3 vBoneIndices;
layout(location = 3) in vec3 vWeights;
layout(location = 0) out vec3 fNorm;
layout(location = 1) out vec4 fWorldPos;
void main()
{
vec4 totalLocalPos = vec4(0.0f);
vec4 totalNormal = vec4(0.0f);
for (int i = 0; i < MAX_WEIGHTS; ++i)
{
totalLocalPos += transform.bones[vBoneIndices[i]] * vec4(vPos, 1.0f) * vWeights[i];
totalNormal += transform.bones[vBoneIndices[i]] * vec4(vNorm, 0.0f) * vWeights[i];
}
fNorm = (transform.model * totalNormal).xyz;
fWorldPos = transform.model * totalLocalPos;
gl_Position = transform.viewProj * fWorldPos;
}