2023-03-16 07:22:01 +00:00
|
|
|
#version 460
|
|
|
|
#extension GL_GOOGLE_include_directive : require
|
|
|
|
|
|
|
|
#include "lovr.glsl"
|
|
|
|
|
|
|
|
layout(local_size_x = 32, local_size_x_id = 0) in;
|
|
|
|
|
|
|
|
layout(push_constant) uniform PushConstants {
|
|
|
|
uint baseVertex;
|
|
|
|
uint vertexCount;
|
|
|
|
uint blendShapeCount;
|
2023-03-17 03:31:15 +00:00
|
|
|
uint baseBlendVertex;
|
2023-06-21 04:42:44 +00:00
|
|
|
bool first;
|
2023-03-16 07:22:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ModelVertex {
|
|
|
|
float px, py, pz;
|
|
|
|
float nx, ny, nz;
|
|
|
|
float u, v;
|
|
|
|
uint color;
|
2023-11-10 00:50:52 +00:00
|
|
|
float tx, ty, tz, tw;
|
2023-03-16 07:22:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct BlendVertex {
|
|
|
|
float px, py, pz;
|
|
|
|
float nx, ny, nz;
|
|
|
|
float tx, ty, tz;
|
|
|
|
};
|
|
|
|
|
2023-09-25 06:51:42 +00:00
|
|
|
layout(set = 0, binding = 0) buffer restrict readonly RawVertices { ModelVertex rawVertices[]; };
|
2023-06-17 02:18:48 +00:00
|
|
|
layout(set = 0, binding = 1) buffer restrict Vertices { ModelVertex vertices[]; };
|
|
|
|
layout(set = 0, binding = 2) buffer restrict readonly BlendVertices { BlendVertex blendVertex[]; };
|
|
|
|
layout(set = 0, binding = 3) uniform Weights { vec4 weights[16]; };
|
2023-03-16 07:22:01 +00:00
|
|
|
|
|
|
|
void lovrmain() {
|
2023-03-17 03:31:15 +00:00
|
|
|
if (GlobalThreadID.x >= vertexCount) return;
|
|
|
|
uint vertexIndex = baseVertex + GlobalThreadID.x;
|
|
|
|
uint blendVertexIndex = baseBlendVertex + GlobalThreadID.x;
|
|
|
|
|
2023-06-21 04:42:44 +00:00
|
|
|
ModelVertex vertex = first ? rawVertices[vertexIndex] : vertices[vertexIndex];
|
2023-04-06 04:48:06 +00:00
|
|
|
|
2023-03-17 03:31:15 +00:00
|
|
|
for (uint i = 0; i < blendShapeCount; i++, blendVertexIndex += vertexCount) {
|
|
|
|
float weight = weights[i / 4][i % 4];
|
|
|
|
|
|
|
|
if (weight == 0.) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2023-04-06 04:48:06 +00:00
|
|
|
BlendVertex blendShape = blendVertex[blendVertexIndex];
|
|
|
|
|
|
|
|
vertex.px += blendShape.px * weight;
|
|
|
|
vertex.py += blendShape.py * weight;
|
|
|
|
vertex.pz += blendShape.pz * weight;
|
2023-03-17 03:31:15 +00:00
|
|
|
|
2023-04-06 04:48:06 +00:00
|
|
|
vertex.nx += blendShape.nx * weight;
|
|
|
|
vertex.ny += blendShape.ny * weight;
|
|
|
|
vertex.nz += blendShape.nz * weight;
|
2023-03-17 03:31:15 +00:00
|
|
|
|
2023-04-06 04:48:06 +00:00
|
|
|
vertex.tx += blendShape.tx * weight;
|
|
|
|
vertex.ty += blendShape.ty * weight;
|
|
|
|
vertex.tz += blendShape.tz * weight;
|
2023-03-17 03:31:15 +00:00
|
|
|
}
|
2023-04-06 04:48:06 +00:00
|
|
|
|
|
|
|
vertices[vertexIndex] = vertex;
|
2023-03-16 07:22:01 +00:00
|
|
|
}
|