Fitted mesh

This commit is contained in:
Latif Khalifa
2014-01-24 01:11:27 +01:00
parent 655081365f
commit 269deb56e6
11 changed files with 360 additions and 50 deletions

View File

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

View File

@@ -178,6 +178,7 @@ public:
ENVIRONMENT_INTENSITY,
AVATAR_MATRIX,
AVATAR_TRANSLATION,
WATER_SCREENTEX,
WATER_SCREENDEPTH,

View File

@@ -26,26 +26,45 @@
ATTRIBUTE vec4 weight4;
uniform mat4 matrixPalette[32];
uniform mat3 matrixPalette[64];
uniform vec3 translationPalette[64];
mat4 getObjectSkinnedTransform()
{
float w0 = fract(weight4.x);
float w1 = fract(weight4.y);
float w2 = fract(weight4.z);
float w3 = fract(weight4.w);
int i;
int i0 = int(floor(weight4.x));
int i1 = int(floor(weight4.y));
int i2 = int(floor(weight4.z));
int i3 = int(floor(weight4.w));
vec4 w = fract(weight4);
vec4 index = floor(weight4);
//float scale = 1.0/(w.x+w.y+w.z+w.w);
//w *= scale;
mat4 mat = matrixPalette[i0]*w0;
mat += matrixPalette[i1]*w1;
mat += matrixPalette[i2]*w2;
mat += matrixPalette[i3]*w3;
index = min(index, vec4(63.0));
index = max(index, vec4( 0.0));
return mat;
float scale = 1.0/(w.x+w.y+w.z+w.w);
w *= scale;
int i1 = int(index.x);
int i2 = int(index.y);
int i3 = int(index.z);
int i4 = int(index.w);
mat3 mat = matrixPalette[i1]*w.x;
mat += matrixPalette[i2]*w.y;
mat += matrixPalette[i3]*w.z;
mat += matrixPalette[i4]*w.w;
vec3 trans = translationPalette[i1]*w.x;
trans += translationPalette[i2]*w.y;
trans += translationPalette[i3]*w.z;
trans += translationPalette[i4]*w.w;
mat4 ret;
ret[0] = vec4(mat[0], 0);
ret[1] = vec4(mat[1], 0);
ret[2] = vec4(mat[2], 0);
ret[3] = vec4(trans, 1.0);
return ret;
}

View File

@@ -3563,7 +3563,11 @@
<volume_morph
name="BELLY"
scale="0.075 0.04 0.03"
pos="0.07 0 -0.07"/>
pos="0.07 0 -0.02"/>
<volume_morph
name="PELVIS"
scale="0.075 0.04 0.03"
pos="0.07 0 -0.02"/>
</param_morph>
</param>
@@ -3582,7 +3586,16 @@
camera_elevation=".1"
camera_distance="1"
camera_angle="15">
<param_morph />
<param_morph>
<volume_morph
name="LEFT_PEC"
scale="0.0273 0.0273 0.0273"
pos="0.038 0.024 -0.016"/>
<volume_morph
name="RIGHT_PEC"
scale="0.0273 0.0273 0.0273"
pos="0.038 -0.024 -0.016"/>
</param_morph>
</param>
<param
@@ -3599,7 +3612,16 @@
value_max="1"
camera_elevation="0"
camera_distance=".28">
<param_morph />
<param_morph>
<volume_morph
name="LEFT_PEC"
scale="-0.05 0.0 0.0"
pos="-0.01 -0.01 -0.02"/>
<volume_morph
name="RIGHT_PEC"
scale="-0.05 0.0 0.0"
pos="-0.01 -0.01 -0.02"/>
</param_morph>
</param>
<param
@@ -3616,7 +3638,16 @@
value_max="1"
camera_elevation="0"
camera_distance=".28">
<param_morph />
<param_morph>
<volume_morph
name="LEFT_PEC"
scale="-0.051 0.0 0.0"
pos="-0.02 -0.01 -0.03"/>
<volume_morph
name="RIGHT_PEC"
scale="-0.051 0.0 0.0"
pos="-0.02 -0.01 -0.03"/>
</param_morph>
</param>
<param
@@ -3682,6 +3713,10 @@
scale="0.0 -0.01 0.0"
pos="0.0 0.0 0"/>
<volume_morph
name="UPPER_BACK"
scale="-0.01 -0.01 0.0"
pos="0.0 0.0 0"/>
<volume_morph
name="CHEST"
scale="-0.01 -0.01 0.0"
pos="0.01 0.0 0"/>
@@ -3732,6 +3767,10 @@
scale="-0.01 -0.01 0.0"
pos="0.01 0.0 0"/>
<volume_morph
name="UPPER_BACK"
scale="-0.01 -0.01 0.0"
pos="0.0 0.0 0"/>
<volume_morph
name="CHEST"
scale="-0.02 -0.02 0.0"
pos="0.01 0.0 0"/>
@@ -3780,6 +3819,32 @@
scale="0.02 0.03 0.03"
pos="0 0 -0.03"/>
<volume_morph
name="PELVIS"
scale="0.02 0.03 0.03"
pos="0 0 -0.03"/>
<volume_morph
name="UPPER_BACK"
scale="0.01 0.03 0.0"
pos="-0.03 0 0"/>
<volume_morph
name="LOWER_BACK"
scale="0.04 0.06 0.0"
pos="-0.06 0 0"/>
<volume_morph
name="LEFT_HANDLE"
pos="0.0 0.08 0.0"/>
<volume_morph
name="RIGHT_HANDLE"
pos="0.0 -0.08 0.0"/>
<volume_morph
name="LEFT_PEC"
scale="0.0367 0.0367 0.016"
pos="0.00 -0.005 -0.013"/>
<volume_morph
name="RIGHT_PEC"
scale="0.0367 0.0367 0.016"
pos="0.00 0.005 -0.013"/>
<volume_morph
name="BELLY"
scale="0.09 0.08 0.07"
pos="0 0 -0.05"/>
@@ -3832,7 +3897,16 @@
value_max="2"
camera_elevation=".3"
camera_distance=".8">
<param_morph />
<param_morph>
<volume_morph
name="LEFT_PEC"
scale="0.0 0.0 0.0"
pos="0.004 0.0 -0.01"/>
<volume_morph
name="RIGHT_PEC"
scale="0.0 0.0 0.0"
pos="0.004 0.0 -0.01"/>
</param_morph>
</param>
<param
@@ -3882,6 +3956,15 @@
<volume_morph
name="BELLY"
scale="0.0 0.02 0.0"/>
<volume_morph
name="LOWER_BACK"
scale="0.0 0.02 0.0"/>
<volume_morph
name="LEFT_HANDLE"
pos="0.0 0.025 0.0"/>
<volume_morph
name="RIGHT_HANDLE"
pos="0.0 -0.025 0.0"/>
</param_morph>
</param>
@@ -3901,7 +3984,16 @@
value_max="1.3"
camera_elevation=".3"
camera_distance=".8">
<param_morph />
<param_morph>
<volume_morph
name="LEFT_PEC"
scale="0.0 0.0 0.0"
pos="0.0 -0.026 0.0"/>
<volume_morph
name="RIGHT_PEC"
scale="0.0 0.0 0.0"
pos="0.0 0.026 0.0"/>
</param_morph>
</param>
<param
@@ -3916,11 +4008,20 @@
label_min="Big Pectorals"
label_max="Sunken Chest"
value_default="0"
value_min="-.5"
value_min="-1.0"
value_max="1.1"
camera_elevation=".3"
camera_distance="1.2">
<param_morph />
<param_morph>
<volume_morph
name="LEFT_PEC"
scale="0.0 0.0 0.0"
pos="-0.03 -0.024 -0.01"/>
<volume_morph
name="RIGHT_PEC"
scale="0.0 0.0 0.0"
pos="-0.03 0.024 -0.01"/>
</param_morph>
</param>
<!-- ############# #
@@ -3945,6 +4046,14 @@
scale="0.03 0.03 0.0"
pos="-0.03 0 0.02"/>
<volume_morph
name="LEFT_PEC"
scale="0.0 0.0 0.0"
pos="0.008 -0.03 0.01"/>
<volume_morph
name="RIGHT_PEC"
scale="0.0 0.0 0.0"
pos="0.008 0.03 0.01"/>
<volume_morph
name="L_CLAVICLE"
scale="0.02 0.0 0.01"
pos="-0.02 0 0"/>
@@ -4115,7 +4224,16 @@
value_default="0"
value_min="-3"
value_max="3">
<param_morph />
<param_morph>
<volume_morph
name="LEFT_PEC"
scale="0.0 0.0 0.0"
pos="0.0 0.0 -0.01"/>
<volume_morph
name="RIGHT_PEC"
scale="0.0 0.0 0.0"
pos="0.0 0.0 -0.01"/>
</param_morph>
</param>
<param
@@ -4128,7 +4246,16 @@
value_default="0"
value_min="-1.25"
value_max="1.25">
<param_morph />
<param_morph>
<volume_morph
name="LEFT_PEC"
scale="0.0 0.0 0.0"
pos="0.0 -0.026 0.0"/>
<volume_morph
name="RIGHT_PEC"
scale="0.0 0.0 0.0"
pos="0.0 0.026 -0.0"/>
</param_morph>
</param>
<param
@@ -4141,7 +4268,12 @@
value_default="0"
value_min="-1"
value_max="1">
<param_morph />
<param_morph>
<volume_morph
name="BELLY"
scale="0.0 0.0 0.0"
pos="0.0 0.0 0.05"/>
</param_morph>
</param>
<param
@@ -4154,7 +4286,16 @@
value_default="0"
value_min="-2"
value_max="2">
<param_morph />
<param_morph>
<volume_morph
name="LEFT_PEC"
scale="0.0 0.0 0.0"
pos="0.0 0.03 0.0"/>
<volume_morph
name="RIGHT_PEC"
scale="0.0 0.0 0.0"
pos="0.0 0.03 0.0"/>
</param_morph>
</param>
<!--
@@ -4256,6 +4397,10 @@
name="PELVIS"
scale="-0.01 0.0 0.0"
pos="0.01 0 0.0"/>
<volume_morph
name="BUTT"
scale="0.0 0.0886 0.0"
pos="0.03 0 0.0"/>
</param_morph>
</param>
@@ -4687,7 +4832,11 @@
value_default="0"
value_min="-1"
value_max="1">
<param_morph />
<param_morph>
<volume_morph
name="BUTT"
pos="0.0 0.0 0.05"/>
</param_morph>
</param>
<param
@@ -4700,7 +4849,11 @@
value_default="0"
value_min="-1"
value_max="1">
<param_morph />
<param_morph>
<volume_morph
name="BUTT"
pos="0.0 0.05 0.0"/>
</param_morph>
</param>
<!--

View File

@@ -1,11 +1,18 @@
<?xml version="1.0" encoding="US-ASCII" standalone="yes"?>
<linden_skeleton version="1.0" num_bones="46" num_collision_volumes="19">
<linden_skeleton version="1.0" num_bones="53" num_collision_volumes="26">
<bone name="mPelvis" pos="0.000 0.000 1.067" rot="0.000000 0.000000 0.000000" scale="1.000 1.000 1.000" pivot="0.000000 0.000000 1.067015">
<collision_volume name="PELVIS" pos = "-0.01 0 -0.02" rot="0.000000 8.00000 0.000000" scale="0.12 0.16 0.17"/>
<collision_volume name="BUTT" pos = "-0.06 0 -0.1" rot="0.000000 0.00000 0.000000" scale="0.1 0.1 0.1"/>
<bone name="mTorso" pos="0.000 0.000 0.084" rot="0.000000 0.000000 0.000000" scale="1.000 1.000 1.000" pivot="0.000000 0.000000 0.084073">
<collision_volume name="BELLY" pos = "0.028 0 0.04" rot="0.000000 8.00000 0.000000" scale="0.09 0.13 0.15"/>
<collision_volume name="LOWER_BACK" pos = "0.0 0.0 0.023" rot="0.000000 0.00000 0.000000" scale="0.09 0.13 0.15"/>
<collision_volume name="LEFT_HANDLE" pos = "0.0 0.10 0.058" rot="0.000000 0.00000 0.000000" scale="0.05 0.05 0.05"/>
<collision_volume name="RIGHT_HANDLE" pos = "0.0 -0.10 0.058" rot="0.000000 0.00000 0.000000" scale="0.05 0.05 0.05"/>
<bone name="mChest" pos="-0.015 0.000 0.205" rot="0.000000 0.000000 0.000000" scale="1.000 1.000 1.000" pivot="-0.015368 0.000000 0.204877">
<collision_volume name="CHEST" pos = "0.028 0 0.07" rot="0.000000 -10.00000 0.000000" scale="0.11 0.15 0.2"/>
<collision_volume name="UPPER_BACK" pos = "0.0 0.0 0.017" rot="0.000000 0.00000 0.000000" scale="0.09 0.13 0.15"/>
<collision_volume name="LEFT_PEC" pos = "0.119 0.082 0.042" rot="0.000000 4.29000 0.000000" scale="0.05 0.05 0.05"/>
<collision_volume name="RIGHT_PEC" pos = "0.119 -0.082 0.042" rot="0.000000 4.29000 0.000000" scale="0.05 0.05 0.05"/>
<bone name="mNeck" pos="-0.010 0.000 0.251" rot="0.000000 0.000000 0.000000" scale="1.000 1.000 1.000" pivot="-0.009507 0.000000 0.251108">
<collision_volume name="NECK" pos = "0.0 0 0.02" rot="0.000000 0.000000 0.000000" scale="0.05 0.06 0.08"/>
<bone name="mHead" pos="0.000 -0.000 0.076" rot="0.000000 0.000000 0.000000" scale="1.000 1.000 1.000" pivot="0.000000 -0.000000 0.075630">

View File

@@ -1694,11 +1694,11 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow)
{
if (sShaderLevel > 0)
{ //upload matrix palette to shader
static const size_t kMaxJoints = 64;
LLMatrix4 mat[kMaxJoints];
LLMatrix4 mat[64];
U32 maxJoints = llmin(skin->mJointNames.size(), kMaxJoints);
for (U32 i = 0; i < maxJoints; ++i)
U32 count = llmin((U32) skin->mJointNames.size(), (U32) 64);
for (U32 i = 0; i < count; ++i)
{
LLJoint* joint = avatar->getJoint(skin->mJointNames[i]);
if (joint)
@@ -1710,10 +1710,42 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow)
stop_glerror();
LLDrawPoolAvatar::sVertexProgram->uniformMatrix4fv(LLViewerShaderMgr::AVATAR_MATRIX,
maxJoints,
F32 mp[64*9];
F32 transp[64*3];
for (U32 i = 0; i < count; ++i)
{
F32* m = (F32*) mat[i].mMatrix;
U32 idx = i*9;
mp[idx+0] = m[0];
mp[idx+1] = m[1];
mp[idx+2] = m[2];
mp[idx+3] = m[4];
mp[idx+4] = m[5];
mp[idx+5] = m[6];
mp[idx+6] = m[8];
mp[idx+7] = m[9];
mp[idx+8] = m[10];
idx = i*3;
transp[idx+0] = m[12];
transp[idx+1] = m[13];
transp[idx+2] = m[14];
}
LLDrawPoolAvatar::sVertexProgram->uniformMatrix3fv(LLViewerShaderMgr::AVATAR_MATRIX,
count,
FALSE,
(GLfloat*) mat[0].mMatrix);
(GLfloat*) mp);
LLDrawPoolAvatar::sVertexProgram->uniform3fv(LLShaderMgr::AVATAR_TRANSLATION, count, transp);
stop_glerror();
}

View File

@@ -3950,7 +3950,7 @@ public:
{
renderAgentTarget(avatar);
}
if (gDebugGL)
{
for (U32 i = 0; i < (U32)drawable->getNumFaces(); ++i)

View File

@@ -1439,6 +1439,9 @@ void init_debug_rendering_menu(LLMenuGL* menu)
sub_menu->addChild(new LLMenuItemCheckGL("Complexity", &LLPipeline::toggleRenderDebug, NULL,
&LLPipeline::toggleRenderDebugControl,
(void*)LLPipeline::RENDER_DEBUG_RENDER_COMPLEXITY));
sub_menu->addChild(new LLMenuItemCheckGL("Joints", &LLPipeline::toggleRenderDebug, NULL,
&LLPipeline::toggleRenderDebugControl,
(void*)LLPipeline::RENDER_DEBUG_AVATAR_JOINTS));
sub_menu = new LLMenuGL("Render Tests");
sub_menu->setCanTearOff(TRUE);

View File

@@ -1729,10 +1729,12 @@ void LLVOAvatar::getSpatialExtents(LLVector4a& newMin, LLVector4a& newMax)
//-----------------------------------------------------------------------------
void LLVOAvatar::renderCollisionVolumes()
{
std::ostringstream ostr;
LLGLDepthTest gls_depth(GL_FALSE);
for (S32 i = 0; i < mNumCollisionVolumes; i++)
{
mCollisionVolumes[i].renderCollision();
ostr << mCollisionVolumes[i].getName() << ", ";
}
if (mNameText.notNull())
@@ -1741,8 +1743,99 @@ void LLVOAvatar::renderCollisionVolumes()
mNameText->lineSegmentIntersect(unused, unused, unused, TRUE);
}
mDebugText.clear();
addDebugText(ostr.str());
}
void LLVOAvatar::renderJoints()
{
std::ostringstream ostr;
std::ostringstream nullstr;
for (joint_map_t::iterator iter = mJointMap.begin(); iter != mJointMap.end(); ++iter)
{
LLJoint* jointp = iter->second;
if (!jointp)
{
nullstr << iter->first << " is NULL" << std::endl;
continue;
}
ostr << jointp->getName() << ", ";
jointp->updateWorldMatrix();
gGL.pushMatrix();
gGL.multMatrix( &jointp->getXform()->getWorldMatrix().mMatrix[0][0] );
gGL.diffuseColor3f( 1.f, 0.f, 1.f );
gGL.begin(LLRender::LINES);
LLVector3 v[] =
{
LLVector3(1,0,0),
LLVector3(-1,0,0),
LLVector3(0,1,0),
LLVector3(0,-1,0),
LLVector3(0,0,-1),
LLVector3(0,0,1),
};
//sides
gGL.vertex3fv(v[0].mV);
gGL.vertex3fv(v[2].mV);
gGL.vertex3fv(v[0].mV);
gGL.vertex3fv(v[3].mV);
gGL.vertex3fv(v[1].mV);
gGL.vertex3fv(v[2].mV);
gGL.vertex3fv(v[1].mV);
gGL.vertex3fv(v[3].mV);
//top
gGL.vertex3fv(v[0].mV);
gGL.vertex3fv(v[4].mV);
gGL.vertex3fv(v[1].mV);
gGL.vertex3fv(v[4].mV);
gGL.vertex3fv(v[2].mV);
gGL.vertex3fv(v[4].mV);
gGL.vertex3fv(v[3].mV);
gGL.vertex3fv(v[4].mV);
//bottom
gGL.vertex3fv(v[0].mV);
gGL.vertex3fv(v[5].mV);
gGL.vertex3fv(v[1].mV);
gGL.vertex3fv(v[5].mV);
gGL.vertex3fv(v[2].mV);
gGL.vertex3fv(v[5].mV);
gGL.vertex3fv(v[3].mV);
gGL.vertex3fv(v[5].mV);
gGL.end();
gGL.popMatrix();
}
mDebugText.clear();
addDebugText(ostr.str());
addDebugText(nullstr.str());
}
BOOL LLVOAvatar::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end,
S32 face,
BOOL pick_transparent,
@@ -3621,9 +3714,6 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
return FALSE;
}
// clear debug text
mDebugText.clear();
if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage"))
{
S32 central_bake_version = -1;
@@ -4165,6 +4255,7 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
{
setDebugText(mDebugText);
}
mDebugText.clear();
//mesh vertices need to be reskinned
mNeedsSkin = TRUE;

View File

@@ -420,6 +420,7 @@ public:
U32 renderSkinnedAttachments();
U32 renderTransparent(BOOL first_pass);
void renderCollisionVolumes();
void renderJoints();
static void deleteCachedImages(bool clearAll=true);
static void destroyGL();
static void restoreGL();

View File

@@ -536,14 +536,16 @@ public:
RENDER_DEBUG_SHADOW_FRUSTA = 0x00040000,
RENDER_DEBUG_SCULPTED = 0x00080000,
RENDER_DEBUG_AVATAR_VOLUME = 0x00100000,
RENDER_DEBUG_BUILD_QUEUE = 0x00200000,
RENDER_DEBUG_AGENT_TARGET = 0x00400000,
RENDER_DEBUG_UPDATE_TYPE = 0x00800000,
RENDER_DEBUG_PHYSICS_SHAPES = 0x01000000,
RENDER_DEBUG_NORMALS = 0x02000000,
RENDER_DEBUG_LOD_INFO = 0x04000000,
RENDER_DEBUG_RENDER_COMPLEXITY = 0x08000000,
RENDER_DEBUG_ATTACHMENT_BYTES = 0x10000000,
RENDER_DEBUG_AVATAR_JOINTS = 0x00200000,
RENDER_DEBUG_BUILD_QUEUE = 0x00400000,
RENDER_DEBUG_AGENT_TARGET = 0x00800000,
RENDER_DEBUG_UPDATE_TYPE = 0x01000000,
RENDER_DEBUG_PHYSICS_SHAPES = 0x02000000,
RENDER_DEBUG_NORMALS = 0x04000000,
RENDER_DEBUG_LOD_INFO = 0x08000000,
RENDER_DEBUG_RENDER_COMPLEXITY = 0x10000000,
RENDER_DEBUG_ATTACHMENT_BYTES = 0x20000000,
RENDER_DEBUG_TEXEL_DENSITY = 0x40000000
};
public: