vsh: Support generated weights in skinning

This commit is contained in:
Jannik Vogel 2019-02-18 22:58:27 +01:00 committed by mborgerson
parent f3b7fefde4
commit c331854c55
1 changed files with 17 additions and 11 deletions
hw/xbox/nv2a

View File

@ -246,18 +246,24 @@ static void append_skinning_code(QString* str, bool mix,
} else {
qstring_append_fmt(str, "%s %s = %s(0.0);\n", type, output, type);
if (mix) {
/* Tweening */
if (count == 2) {
qstring_append_fmt(str,
"%s += mix((%s * %s1).%s,\n"
" (%s * %s0).%s, weight.x);\n",
output,
input, matrix, swizzle,
input, matrix, swizzle);
} else {
/* FIXME: Not sure how blend weights are calculated */
assert(false);
/* Generated final weight (like GL_WEIGHT_SUM_UNITY_ARB) */
qstring_append(str, "{\n"
" float weight_i;\n"
" float weight_n = 1.0;\n");
int i;
for (i = 0; i < count; i++) {
if (i < (count - 1)) {
char c = "xyzw"[i];
qstring_append_fmt(str, " weight_i = weight.%c;\n"
" weight_n -= weight_i;\n",
c);
} else {
qstring_append(str, " weight_i = weight_n;\n");
}
qstring_append_fmt(str, " %s += (%s * %s%d).%s * weight_i;\n",
output, input, matrix, i, swizzle);
}
qstring_append(str, "}\n");
} else {
/* Individual matrices */
int i;