Be super sure not to let rigged vert weights extend beyond actual joint count.

This commit is contained in:
Shyotl
2014-02-10 20:18:39 -06:00
parent 9d7d7590a7
commit f7fdeeea9b
4 changed files with 6 additions and 3 deletions

View File

@@ -1225,6 +1225,7 @@ void LLShaderMgr::initAttribsAndUniforms()
mReservedUniforms.push_back("matrixPalette");
mReservedUniforms.push_back("translationPalette");
mReservedUniforms.push_back("maxWeight");
mReservedUniforms.push_back("screenTex");
mReservedUniforms.push_back("screenDepth");

View File

@@ -179,6 +179,7 @@ public:
AVATAR_MATRIX,
AVATAR_TRANSLATION,
AVATAR_MAX_WEIGHT,
WATER_SCREENTEX,
WATER_SCREENDEPTH,

View File

@@ -26,6 +26,7 @@ ATTRIBUTE vec4 weight4;
uniform mat3 matrixPalette[52];
uniform vec3 translationPalette[52];
uniform float maxWeight;
mat4 getObjectSkinnedTransform()
{
@@ -34,7 +35,7 @@ mat4 getObjectSkinnedTransform()
vec4 w = fract(weight4);
vec4 index = floor(weight4);
index = min(index, vec4(51.0));
index = min(index, vec4(maxWeight));
index = max(index, vec4( 0.0));
float scale = 1.0/(w.x+w.y+w.z+w.w);

View File

@@ -1599,7 +1599,7 @@ void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(LLVOAvatar* avatar, LLFace*
{
F32 w = weight[j][k];
idx[k] = llclamp((S32) floorf(w), 0, 63);
idx[k] = llclamp((S32) floorf(w), 0, S32(count-1));
wght[k] = w - floorf(w);
scale += wght[k];
}
@@ -1747,7 +1747,7 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow)
(GLfloat*) mp);
LLDrawPoolAvatar::sVertexProgram->uniform3fv(LLShaderMgr::AVATAR_TRANSLATION, count, transp);
LLDrawPoolAvatar::sVertexProgram->uniform1f(LLShaderMgr::AVATAR_MAX_WEIGHT, F32(count-1));
stop_glerror();
}