mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-17 17:31:28 +00:00
The bones aren't animated yet (and I realized I made the mistake of thinking the bone buffer was per-model when it's really per-instance (I think this mistake is in the rest of QF, too)), skin rendering is a mess, need to default vertex attributes that aren't in the model... Still, it's quite satisfying seeing Mr Fixit on screen again :) I wound up moving the pipeline spec in with the rest of the pipelines as the system isn't really ready for separating them.
58 lines
1.5 KiB
GLSL
58 lines
1.5 KiB
GLSL
#version 450
|
|
|
|
layout (constant_id = 0) const bool IQMDepthOnly = false;
|
|
|
|
layout (set = 0, binding = 0) uniform Matrices {
|
|
mat4 Projection3d;
|
|
mat4 View;
|
|
mat4 Sky;
|
|
mat4 Projection2d;
|
|
};
|
|
|
|
layout (set = 2, binding = 0) buffer Bones {
|
|
// NOTE these are transposed, so v * m
|
|
mat3x4 bones[];
|
|
};
|
|
|
|
layout (push_constant) uniform PushConstants {
|
|
mat4 Model;
|
|
float blend;
|
|
};
|
|
|
|
layout (location = 0) in vec3 vposition;
|
|
layout (location = 1) in uvec4 vbones;
|
|
layout (location = 2) in vec4 vweights;
|
|
layout (location = 3) in vec2 vtexcoord;
|
|
layout (location = 4) in vec3 vnormal;
|
|
layout (location = 5) in vec4 vtangent;
|
|
layout (location = 6) in vec4 vcolor;
|
|
|
|
layout (location = 0) out vec2 texcoord;
|
|
layout (location = 1) out vec4 position;
|
|
layout (location = 2) out vec3 normal;
|
|
layout (location = 3) out vec3 tangent;
|
|
layout (location = 4) out vec3 bitangent;
|
|
layout (location = 5) out vec4 color;
|
|
|
|
void
|
|
main (void)
|
|
{
|
|
mat3x4 m = bones[vbones.x] * vweights.x;
|
|
m += bones[vbones.y] * vweights.y;
|
|
m += bones[vbones.z] * vweights.z;
|
|
m += bones[vbones.w] * vweights.w;
|
|
vec4 pos = vec4 (Model * vec4(vposition, 1) * m, 1);
|
|
gl_Position = Projection3d * (View * pos);
|
|
|
|
if (!IQMDepthOnly) {
|
|
position = pos;
|
|
mat3 adjTrans = mat3 (cross(m[1].xyz, m[2].xyz),
|
|
cross(m[2].xyz, m[0].xyz),
|
|
cross(m[0].xyz, m[1].xyz));
|
|
normal = mat3 (Model) * vnormal * adjTrans;
|
|
tangent = mat3 (Model) * vtangent.xyz * adjTrans;
|
|
bitangent = cross (normal, tangent) * vtangent.w;
|
|
texcoord = vtexcoord;
|
|
color = vcolor;
|
|
}
|
|
}
|