1
Fork 0
mirror of https://github.com/redstrate/Novus.git synced 2025-04-21 19:57:44 +00:00
novus/renderer/shaders/mesh.vert
Joshua Goins 9688c091af Add bone editing to mdlviewer
This is big, as it shows we are now correctly parsing the havok XML
sidecard data and you can edit the scale of the bones in the viewport.

This also pulls in a new libxiv version, which is required to fill out
the used bones list on a Model. Right now the bone editing is incredibly
basic, and the viewport suffers from a lack of depth testing still.
2022-04-28 17:50:05 -04:00

34 lines
1,013 B
GLSL

#version 450
layout(location = 0) in vec3 inPosition;
layout(location = 1) in vec3 inNormal;
layout(location = 2) in vec4 inBoneWeights;
layout(location = 3) in uvec4 inBoneIds;
layout(location = 0) out vec3 outNormal;
layout(location = 1) out vec3 outFragPos;
layout(push_constant) uniform PushConstant {
mat4 vp, model;
int boneOffset;
};
layout(std430, binding = 2) buffer readonly BoneInformation {
mat4 bones[128];
};
void main() {
mat4 BoneTransform = bones[boneOffset + inBoneIds[0]] * inBoneWeights[0];
BoneTransform += bones[boneOffset + inBoneIds[1]] * inBoneWeights[1];
BoneTransform += bones[boneOffset + inBoneIds[2]] * inBoneWeights[2];
BoneTransform += bones[boneOffset + inBoneIds[3]] * inBoneWeights[3];
BoneTransform = model * BoneTransform;
vec4 bPos = BoneTransform * vec4(inPosition, 1.0);
vec4 bNor = BoneTransform * vec4(inNormal, 0.0);
gl_Position = vp * bPos;
outNormal = bNor.xyz;
outFragPos = vec3(model * vec4(inPosition, 1.0));
}