From 5f03e197f4cfb43de93dc42b16b54beafccd376a Mon Sep 17 00:00:00 2001 From: Geenz Date: Fri, 25 Jan 2013 17:54:38 -0500 Subject: Trying to set materials up for rendering! Yay! --- indra/newview/llface.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'indra/newview/llface.cpp') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 605cb81c10..01cbfafe16 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -316,6 +316,48 @@ void LLFace::setTexture(LLViewerTexture* tex) mTexture = tex ; } +void LLFace::setNormalMap(LLViewerTexture* tex) +{ + if(mNormalMap == tex) + { + return ; + } + + if(mNormalMap.notNull()) + { + mNormalMap->removeFace(this) ; + removeAtlas() ; + } + + if(tex) + { + tex->addFace(this) ; + } + + mNormalMap = tex ; +} + +void LLFace::setSpecularMap(LLViewerTexture* tex) +{ + if(mSpecMap == tex) + { + return ; + } + + if(mSpecMap.notNull()) + { + mSpecMap->removeFace(this) ; + removeAtlas() ; + } + + if(tex) + { + tex->addFace(this) ; + } + + mSpecMap = tex ; +} + void LLFace::dirtyTexture() { LLDrawable* drawablep = getDrawable(); -- cgit v1.2.3 From aa1befd689703d9fea50399201911e0f8fca6ac6 Mon Sep 17 00:00:00 2001 From: Geenz Date: Wed, 30 Jan 2013 12:17:04 -0500 Subject: Specular map support. This is the vast majority of the material parameters implemented at this point for opaque geometry. --- indra/newview/llface.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indra/newview/llface.cpp') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 01cbfafe16..cd84815295 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -2077,9 +2077,11 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, LLFastTimer t(FTM_FACE_GEOM_BINORMAL); mVertexBuffer->getBinormalStrider(binorm, mGeomIndex, mGeomCount, map_range); F32* binormals = (F32*) binorm.get(); - + + mVObjp->getVolume()->genBinormals(f); + for (S32 i = 0; i < num_vertices; i++) - { + { LLVector4a binormal; mat_normal.rotate(vf.mBinormals[i], binormal); binormal.normalize3fast(); -- cgit v1.2.3 From 41ca92c67c75d86e8053ae45725d36ca3ac7e742 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 25 Mar 2013 18:27:07 -0500 Subject: NORSPEC-54 Potential fix for crashing on all sorts of random operations. --- indra/newview/llface.cpp | 405 +++++++++-------------------------------------- 1 file changed, 74 insertions(+), 331 deletions(-) (limited to 'indra/newview/llface.cpp') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index db079a1f16..6f0b1ee567 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -51,7 +51,7 @@ #include "llviewerregion.h" #include "llviewerwindow.h" #include "llviewershadermgr.h" - +#include "llviewertexture.h" #define LL_MAX_INDICES_COUNT 1000000 @@ -167,8 +167,12 @@ void LLFace::init(LLDrawable* drawablep, LLViewerObject* objp) //special value to indicate uninitialized position mIndicesIndex = 0xFFFFFFFF; - mIndexInTex = 0; - mTexture = NULL; + for (U32 i = 0; i < LLRender::NUM_TEXTURE_CHANNELS; ++i) + { + mIndexInTex[i] = 0; + mTexture[i] = NULL; + } + mTEOffset = -1; mTextureIndex = 255; @@ -185,8 +189,6 @@ void LLFace::init(LLDrawable* drawablep, LLViewerObject* objp) mImportanceToCamera = 0.f ; mBoundingSphereRadius = 0.0f ; - mAtlasInfop = NULL ; - mUsingAtlas = FALSE ; mHasMedia = FALSE ; } @@ -197,9 +199,12 @@ void LLFace::destroy() gPipeline.checkReferences(this); } - if(mTexture.notNull()) + for (U32 i = 0; i < LLRender::NUM_TEXTURE_CHANNELS; ++i) { - mTexture->removeFace(this) ; + if(mTexture[i].notNull()) + { + mTexture[i]->removeFace(i, this) ; + } } if (isState(LLFace::PARTICLE)) @@ -239,8 +244,7 @@ void LLFace::destroy() } setDrawInfo(NULL); - removeAtlas(); - + mDrawablep = NULL; mVObjp = NULL; } @@ -293,90 +297,76 @@ void LLFace::setPool(LLFacePool* new_pool, LLViewerTexture *texturep) setTexture(texturep) ; } -void LLFace::setTexture(LLViewerTexture* tex) +void LLFace::setTexture(U32 ch, LLViewerTexture* tex) { - if(mTexture == tex) + llassert(ch < LLRender::NUM_TEXTURE_CHANNELS); + + if(mTexture[ch] == tex) { return ; } - if(mTexture.notNull()) + if(mTexture[ch].notNull()) { - mTexture->removeFace(this) ; - removeAtlas() ; + mTexture[ch]->removeFace(ch, this) ; } if(tex) { - tex->addFace(this) ; + tex->addFace(ch, this) ; } - mTexture = tex ; + mTexture[ch] = tex ; +} + +void LLFace::setTexture(LLViewerTexture* tex) +{ + setDiffuseMap(tex); +} + +void LLFace::setDiffuseMap(LLViewerTexture* tex) +{ + setTexture(LLRender::DIFFUSE_MAP, tex); } void LLFace::setNormalMap(LLViewerTexture* tex) { - if(mNormalMap == tex) - { - return ; - } - - if(mNormalMap.notNull()) - { - mNormalMap->removeFace(this) ; - removeAtlas() ; - } - - if(tex) - { - tex->addFace(this) ; - } - - mNormalMap = tex ; + setTexture(LLRender::NORMAL_MAP, tex); } void LLFace::setSpecularMap(LLViewerTexture* tex) { - if(mSpecMap == tex) - { - return ; - } - - if(mSpecMap.notNull()) - { - mSpecMap->removeFace(this) ; - removeAtlas() ; - } - - if(tex) - { - tex->addFace(this) ; - } - - mSpecMap = tex ; + setTexture(LLRender::SPECULAR_MAP, tex); } void LLFace::dirtyTexture() { LLDrawable* drawablep = getDrawable(); - if (mVObjp.notNull() && mVObjp->getVolume() && - mTexture.notNull() && mTexture->getComponents() == 4) - { //dirty texture on an alpha object should be treated as an LoD update - LLVOVolume* vobj = drawablep->getVOVolume(); - if (vobj) + if (mVObjp.notNull() && mVObjp->getVolume()) + { + for (U32 ch = 0; ch < LLRender::NUM_TEXTURE_CHANNELS; ++ch) { - vobj->mLODChanged = TRUE; + if (mTexture[ch].notNull() && mTexture[ch]->getComponents() == 4) + { //dirty texture on an alpha object should be treated as an LoD update + LLVOVolume* vobj = drawablep->getVOVolume(); + if (vobj) + { + vobj->mLODChanged = TRUE; + } + gPipeline.markRebuild(drawablep, LLDrawable::REBUILD_VOLUME, FALSE); + } } - gPipeline.markRebuild(drawablep, LLDrawable::REBUILD_VOLUME, FALSE); - } + } gPipeline.markTextured(drawablep); } -void LLFace::switchTexture(LLViewerTexture* new_texture) +void LLFace::switchTexture(U32 ch, LLViewerTexture* new_texture) { - if(mTexture == new_texture) + llassert(ch < LLRender::NUM_TEXTURE_CHANNELS); + + if(mTexture[ch] == new_texture) { return ; } @@ -386,10 +376,17 @@ void LLFace::switchTexture(LLViewerTexture* new_texture) llerrs << "Can not switch to a null texture." << llendl; return; } - new_texture->addTextureStats(mTexture->getMaxVirtualSize()) ; - getViewerObject()->changeTEImage(mTEOffset, new_texture) ; - setTexture(new_texture) ; + llassert(mTexture[ch].notNull()); + + new_texture->addTextureStats(mTexture[ch]->getMaxVirtualSize()) ; + + if (ch == LLRender::DIFFUSE_MAP) + { + getViewerObject()->changeTEImage(mTEOffset, new_texture) ; + } + + setTexture(ch, new_texture) ; dirtyTexture(); } @@ -1293,27 +1290,6 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, const LLTextureEntry *tep = mVObjp->getTE(f); const U8 bump_code = tep ? tep->getBumpmap() : 0; - F32 tcoord_xoffset = 0.f ; - F32 tcoord_yoffset = 0.f ; - F32 tcoord_xscale = 1.f ; - F32 tcoord_yscale = 1.f ; - BOOL in_atlas = FALSE ; - - if (rebuild_tcoord) - { - in_atlas = isAtlasInUse() ; - if(in_atlas) - { - const LLVector2* tmp = getTexCoordOffset() ; - tcoord_xoffset = tmp->mV[0] ; - tcoord_yoffset = tmp->mV[1] ; - - tmp = getTexCoordScale() ; - tcoord_xscale = tmp->mV[0] ; - tcoord_yscale = tmp->mV[1] ; - } - } - BOOL is_static = mDrawablep->isStatic(); BOOL is_global = is_static; @@ -1598,11 +1574,11 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, break; case BE_BRIGHTNESS: case BE_DARKNESS: - if( mTexture.notNull() && mTexture->hasGLTexture()) + if( mTexture[LLRender::DIFFUSE_MAP].notNull() && mTexture[LLRender::DIFFUSE_MAP]->hasGLTexture()) { // Offset by approximately one texel - S32 cur_discard = mTexture->getDiscardLevel(); - S32 max_size = llmax( mTexture->getWidth(), mTexture->getHeight() ); + S32 cur_discard = mTexture[LLRender::DIFFUSE_MAP]->getDiscardLevel(); + S32 max_size = llmax( mTexture[LLRender::DIFFUSE_MAP]->getWidth(), mTexture[LLRender::DIFFUSE_MAP]->getHeight() ); max_size <<= cur_discard; const F32 ARTIFICIAL_OFFSET = 2.f; offset_multiple = ARTIFICIAL_OFFSET / (F32)max_size; @@ -1675,8 +1651,8 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, bool do_bump = bump_code && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1); bool do_tex_mat = tex_mode && mTextureMatrix; - if (!in_atlas && !do_bump) - { //not in atlas or not bump mapped, might be able to do a cheap update + if (!do_bump) + { //not bump mapped, might be able to do a cheap update mVertexBuffer->getTexCoord0Strider(tex_coords, mGeomIndex, mGeomCount); if (texgen != LLTextureEntry::TEX_GEN_PLANAR) @@ -1728,7 +1704,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, } } else - { //do tex mat, no texgen, no atlas, no bump + { //do tex mat, no texgen, no bump for (S32 i = 0; i < num_vertices; i++) { LLVector2 tc(vf.mTexCoords[i]); @@ -1744,7 +1720,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, } } else - { //no bump, no atlas, tex gen planar + { //no bump, tex gen planar LLFastTimer t(FTM_FACE_TEX_QUICK_PLANAR); if (do_tex_mat) { @@ -1789,7 +1765,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, } } else - { //either bump mapped or in atlas, just do the whole expensive loop + { //bump mapped, just do the whole expensive loop LLFastTimer t(FTM_FACE_TEX_DEFAULT); mVertexBuffer->getTexCoord0Strider(tex_coords, mGeomIndex, mGeomCount, map_range); @@ -1837,93 +1813,6 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, xform(tc, cos_ang, sin_ang, os, ot, ms, mt); } - if(in_atlas) - { - // - //manually calculate tex-coord per vertex for varying address modes. - //should be removed if shader can handle this. - // - - S32 int_part = 0 ; - switch(mTexture->getAddressMode()) - { - case LLTexUnit::TAM_CLAMP: - if(tc.mV[0] < 0.f) - { - tc.mV[0] = 0.f ; - } - else if(tc.mV[0] > 1.f) - { - tc.mV[0] = 1.f; - } - - if(tc.mV[1] < 0.f) - { - tc.mV[1] = 0.f ; - } - else if(tc.mV[1] > 1.f) - { - tc.mV[1] = 1.f; - } - break; - case LLTexUnit::TAM_MIRROR: - if(tc.mV[0] < 0.f) - { - tc.mV[0] = -tc.mV[0] ; - } - int_part = (S32)tc.mV[0] ; - if(int_part & 1) //odd number - { - tc.mV[0] = int_part + 1 - tc.mV[0] ; - } - else //even number - { - tc.mV[0] -= int_part ; - } - - if(tc.mV[1] < 0.f) - { - tc.mV[1] = -tc.mV[1] ; - } - int_part = (S32)tc.mV[1] ; - if(int_part & 1) //odd number - { - tc.mV[1] = int_part + 1 - tc.mV[1] ; - } - else //even number - { - tc.mV[1] -= int_part ; - } - break; - case LLTexUnit::TAM_WRAP: - if(tc.mV[0] > 1.f) - tc.mV[0] -= (S32)(tc.mV[0] - 0.00001f) ; - else if(tc.mV[0] < -1.f) - tc.mV[0] -= (S32)(tc.mV[0] + 0.00001f) ; - - if(tc.mV[1] > 1.f) - tc.mV[1] -= (S32)(tc.mV[1] - 0.00001f) ; - else if(tc.mV[1] < -1.f) - tc.mV[1] -= (S32)(tc.mV[1] + 0.00001f) ; - - if(tc.mV[0] < 0.f) - { - tc.mV[0] = 1.0f + tc.mV[0] ; - } - if(tc.mV[1] < 0.f) - { - tc.mV[1] = 1.0f + tc.mV[1] ; - } - break; - default: - break; - } - - tc.mV[0] = tcoord_xoffset + tcoord_xscale * tc.mV[0] ; - tc.mV[1] = tcoord_yoffset + tcoord_yscale * tc.mV[1] ; - } - - *tex_coords++ = tc; if (do_bump) { @@ -2197,9 +2086,9 @@ BOOL LLFace::hasMedia() const { return TRUE ; } - if(mTexture.notNull()) + if(mTexture[LLRender::DIFFUSE_MAP].notNull()) { - return mTexture->hasParcelMedia() ; //if has a parcel media + return mTexture[LLRender::DIFFUSE_MAP]->hasParcelMedia() ; //if has a parcel media } return FALSE ; //no media. @@ -2251,7 +2140,7 @@ F32 LLFace::getTextureVirtualSize() face_area = LLFace::adjustPixelArea(mImportanceToCamera, face_area) ; if(face_area > LLViewerTexture::sMinLargeImageSize) //if is large image, shrink face_area by considering the partial overlapping. { - if(mImportanceToCamera > LEAST_IMPORTANCE_FOR_LARGE_IMAGE && mTexture.notNull() && mTexture->isLargeImage()) + if(mImportanceToCamera > LEAST_IMPORTANCE_FOR_LARGE_IMAGE && mTexture[LLRender::DIFFUSE_MAP].notNull() && mTexture[LLRender::DIFFUSE_MAP]->isLargeImage()) { face_area *= adjustPartialOverlapPixelArea(cos_angle_to_view_dir, radius ); } @@ -2618,159 +2507,13 @@ LLVector3 LLFace::getPositionAgent() const } } -// -//atlas -// -void LLFace::removeAtlas() -{ - setAtlasInUse(FALSE) ; - mAtlasInfop = NULL ; -} - -const LLTextureAtlas* LLFace::getAtlas()const -{ - if(mAtlasInfop) - { - return mAtlasInfop->getAtlas() ; - } - return NULL ; -} - -const LLVector2* LLFace::getTexCoordOffset()const -{ - if(isAtlasInUse()) - { - return mAtlasInfop->getTexCoordOffset() ; - } - return NULL ; -} -const LLVector2* LLFace::getTexCoordScale() const -{ - if(isAtlasInUse()) - { - return mAtlasInfop->getTexCoordScale() ; - } - return NULL ; -} - -BOOL LLFace::isAtlasInUse()const +LLViewerTexture* LLFace::getTexture(U32 ch) const { - return mUsingAtlas ; -} - -BOOL LLFace::canUseAtlas()const -{ - //no drawable or no spatial group, do not use atlas - if(!mDrawablep || !mDrawablep->getSpatialGroup()) - { - return FALSE ; - } - - //if bump face, do not use atlas - if(getTextureEntry() && getTextureEntry()->getBumpmap()) - { - return FALSE ; - } - - //if animated texture, do not use atlas - if(isState(TEXTURE_ANIM)) - { - return FALSE ; - } + llassert(ch < LLRender::NUM_TEXTURE_CHANNELS); - return TRUE ; + return mTexture[ch] ; } -void LLFace::setAtlasInUse(BOOL flag) -{ - //no valid atlas to use. - if(flag && (!mAtlasInfop || !mAtlasInfop->isValid())) - { - flag = FALSE ; - } - - if(!flag && !mUsingAtlas) - { - return ; - } - - // - //at this stage (flag || mUsingAtlas) is always true. - // - - //rebuild the tex coords - if(mDrawablep) - { - gPipeline.markRebuild(mDrawablep, LLDrawable::REBUILD_TCOORD); - mUsingAtlas = flag ; - } - else - { - mUsingAtlas = FALSE ; - } -} - -LLTextureAtlasSlot* LLFace::getAtlasInfo() -{ - return mAtlasInfop ; -} - -void LLFace::setAtlasInfo(LLTextureAtlasSlot* atlasp) -{ - if(mAtlasInfop != atlasp) - { - if(mAtlasInfop) - { - //llerrs << "Atlas slot changed!" << llendl ; - } - mAtlasInfop = atlasp ; - } -} - -LLViewerTexture* LLFace::getTexture() const -{ - if(isAtlasInUse()) - { - return (LLViewerTexture*)mAtlasInfop->getAtlas() ; - } - - return mTexture ; -} - -//switch to atlas or switch back to gl texture -//return TRUE if using atlas. -BOOL LLFace::switchTexture() -{ - //no valid atlas or texture - if(!mAtlasInfop || !mAtlasInfop->isValid() || !mTexture) - { - return FALSE ; - } - - if(mTexture->getTexelsInAtlas() >= (U32)mVSize || - mTexture->getTexelsInAtlas() >= mTexture->getTexelsInGLTexture()) - { - //switch to use atlas - //atlas resolution is qualified, use it. - if(!mUsingAtlas) - { - setAtlasInUse(TRUE) ; - } - } - else //if atlas not qualified. - { - //switch back to GL texture - if(mUsingAtlas && mTexture->isGLTextureCreated() && - mTexture->getDiscardLevel() < mTexture->getDiscardLevelInAtlas()) - { - setAtlasInUse(FALSE) ; - } - } - - return mUsingAtlas ; -} - - void LLFace::setVertexBuffer(LLVertexBuffer* buffer) { mVertexBuffer = buffer; -- cgit v1.2.3 From fc4869fb7871632b95dd293157b9965fb2edcb73 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 29 Mar 2013 16:13:36 -0500 Subject: NORSPEC-65 Hook up texture offset/scale/rotation for normal and specular maps. --- indra/newview/llface.cpp | 174 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 120 insertions(+), 54 deletions(-) (limited to 'indra/newview/llface.cpp') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 6f0b1ee567..9a8b37bf8b 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -1258,7 +1258,8 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, } LLStrider vert; - LLStrider tex_coords; + LLStrider tex_coords0; + LLStrider tex_coords1; LLStrider tex_coords2; LLStrider norm; LLStrider colors; @@ -1648,12 +1649,21 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, LLVector4a scalea; scalea.load3(scale.mV); + LLMaterial* mat = tep->getMaterialParams().get(); + bool do_bump = bump_code && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1); - bool do_tex_mat = tex_mode && mTextureMatrix; + if (mat && !do_bump) + { + do_bump = mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1) || + mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD2); + } + + bool do_tex_mat = tex_mode && mTextureMatrix; + if (!do_bump) { //not bump mapped, might be able to do a cheap update - mVertexBuffer->getTexCoord0Strider(tex_coords, mGeomIndex, mGeomCount); + mVertexBuffer->getTexCoord0Strider(tex_coords0, mGeomIndex, mGeomCount); if (texgen != LLTextureEntry::TEX_GEN_PLANAR) { @@ -1664,12 +1674,12 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, { LLFastTimer t(FTM_FACE_TEX_QUICK_NO_XFORM); S32 tc_size = (num_vertices*2*sizeof(F32)+0xF) & ~0xF; - LLVector4a::memcpyNonAliased16((F32*) tex_coords.get(), (F32*) vf.mTexCoords, tc_size); + LLVector4a::memcpyNonAliased16((F32*) tex_coords0.get(), (F32*) vf.mTexCoords, tc_size); } else { LLFastTimer t(FTM_FACE_TEX_QUICK_XFORM); - F32* dst = (F32*) tex_coords.get(); + F32* dst = (F32*) tex_coords0.get(); LLVector4a* src = (LLVector4a*) vf.mTexCoords; LLVector4a trans; @@ -1715,7 +1725,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, tmp = tmp * *mTextureMatrix; tc.mV[0] = tmp.mV[0]; tc.mV[1] = tmp.mV[1]; - *tex_coords++ = tc; + *tex_coords0++ = tc; } } } @@ -1738,7 +1748,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, tc.mV[0] = tmp.mV[0]; tc.mV[1] = tmp.mV[1]; - *tex_coords++ = tc; + *tex_coords0++ = tc; } } else @@ -1754,7 +1764,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, xform(tc, cos_ang, sin_ang, os, ot, ms, mt); - *tex_coords++ = tc; + *tex_coords0++ = tc; } } } @@ -1765,58 +1775,114 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, } } else - { //bump mapped, just do the whole expensive loop + { //bump mapped or has material, just do the whole expensive loop LLFastTimer t(FTM_FACE_TEX_DEFAULT); - mVertexBuffer->getTexCoord0Strider(tex_coords, mGeomIndex, mGeomCount, map_range); - + std::vector bump_tc; - - for (S32 i = 0; i < num_vertices; i++) - { - LLVector2 tc(vf.mTexCoords[i]); + + if (mat) + { //writing out normal and specular texture coordinates, not bump offsets + do_bump = false; + } + + LLStrider dst; + + for (U32 ch = 0; ch < 3; ++ch) + { + switch (ch) + { + case 0: + mVertexBuffer->getTexCoord0Strider(dst, mGeomIndex, mGeomCount, map_range); + break; + case 1: + if (mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1)) + { + mVertexBuffer->getTexCoord1Strider(dst, mGeomIndex, mGeomCount, map_range); + if (mat) + { + r = mat->getNormalRotation(); + mat->getNormalOffset(os, ot); + mat->getNormalRepeat(ms, mt); + + cos_ang = cos(r); + sin_ang = sin(r); + + } + } + else + { + continue; + } + break; + case 2: + if (mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD2)) + { + mVertexBuffer->getTexCoord2Strider(dst, mGeomIndex, mGeomCount, map_range); + if (mat) + { + r = mat->getSpecularRotation(); + mat->getSpecularOffset(os, ot); + mat->getSpecularRepeat(ms, mt); + + cos_ang = cos(r); + sin_ang = sin(r); + } + } + else + { + continue; + } + break; + } + + + for (S32 i = 0; i < num_vertices; i++) + { + LLVector2 tc(vf.mTexCoords[i]); - LLVector4a& norm = vf.mNormals[i]; + LLVector4a& norm = vf.mNormals[i]; - LLVector4a& center = *(vf.mCenter); + LLVector4a& center = *(vf.mCenter); - if (texgen != LLTextureEntry::TEX_GEN_DEFAULT) - { - LLVector4a vec = vf.mPositions[i]; + if (texgen != LLTextureEntry::TEX_GEN_DEFAULT) + { + LLVector4a vec = vf.mPositions[i]; - vec.mul(scalea); + vec.mul(scalea); - switch (texgen) - { - case LLTextureEntry::TEX_GEN_PLANAR: - planarProjection(tc, norm, center, vec); - break; - case LLTextureEntry::TEX_GEN_SPHERICAL: - sphericalProjection(tc, norm, center, vec); - break; - case LLTextureEntry::TEX_GEN_CYLINDRICAL: - cylindricalProjection(tc, norm, center, vec); - break; - default: - break; - } - } + switch (texgen) + { + case LLTextureEntry::TEX_GEN_PLANAR: + planarProjection(tc, norm, center, vec); + break; + case LLTextureEntry::TEX_GEN_SPHERICAL: + sphericalProjection(tc, norm, center, vec); + break; + case LLTextureEntry::TEX_GEN_CYLINDRICAL: + cylindricalProjection(tc, norm, center, vec); + break; + default: + break; + } + } - if (tex_mode && mTextureMatrix) - { - LLVector3 tmp(tc.mV[0], tc.mV[1], 0.f); - tmp = tmp * *mTextureMatrix; - tc.mV[0] = tmp.mV[0]; - tc.mV[1] = tmp.mV[1]; - } - else - { - xform(tc, cos_ang, sin_ang, os, ot, ms, mt); - } + if (tex_mode && mTextureMatrix) + { + LLVector3 tmp(tc.mV[0], tc.mV[1], 0.f); + tmp = tmp * *mTextureMatrix; + tc.mV[0] = tmp.mV[0]; + tc.mV[1] = tmp.mV[1]; + } + else + { + xform(tc, cos_ang, sin_ang, os, ot, ms, mt); + } - *tex_coords++ = tc; - if (do_bump) - { - bump_tc.push_back(tc); + *dst++ = tc; + if (do_bump) + { + bump_tc.push_back(tc); + } } } @@ -1825,9 +1891,9 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, mVertexBuffer->flush(); } - if (do_bump) + if (!mat && do_bump) { - mVertexBuffer->getTexCoord1Strider(tex_coords2, mGeomIndex, mGeomCount, map_range); + mVertexBuffer->getTexCoord1Strider(tex_coords1, mGeomIndex, mGeomCount, map_range); for (S32 i = 0; i < num_vertices; i++) { @@ -1854,7 +1920,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, LLVector2 tc = bump_tc[i]; tc += LLVector2( bump_s_primary_light_ray.dot3(tangent).getF32(), bump_t_primary_light_ray.dot3(binormal).getF32() ); - *tex_coords2++ = tc; + *tex_coords1++ = tc; } if (map_range) -- cgit v1.2.3 From 14f02e48b877569539c96ef5f261ac8b3943579f Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 29 Mar 2013 20:12:27 -0500 Subject: NORSPEC-66 Hook up material parameters to rigged attachments. --- indra/newview/llface.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'indra/newview/llface.cpp') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 9a8b37bf8b..3d6acedd02 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -2595,6 +2595,22 @@ void LLFace::clearVertexBuffer() U32 LLFace::getRiggedDataMask(U32 type) { static const U32 rigged_data_mask[] = { + LLDrawPoolAvatar::RIGGED_MATERIAL_MASK, + LLDrawPoolAvatar::RIGGED_MATERIAL_ALPHA_VMASK, + LLDrawPoolAvatar::RIGGED_MATERIAL_ALPHA_MASK_MASK, + LLDrawPoolAvatar::RIGGED_MATERIAL_ALPHA_EMISSIVE_MASK, + LLDrawPoolAvatar::RIGGED_SPECMAP_VMASK, + LLDrawPoolAvatar::RIGGED_SPECMAP_BLEND_MASK, + LLDrawPoolAvatar::RIGGED_SPECMAP_MASK_MASK, + LLDrawPoolAvatar::RIGGED_SPECMAP_EMISSIVE_MASK, + LLDrawPoolAvatar::RIGGED_NORMMAP_VMASK, + LLDrawPoolAvatar::RIGGED_NORMMAP_BLEND_MASK, + LLDrawPoolAvatar::RIGGED_NORMMAP_MASK_MASK, + LLDrawPoolAvatar::RIGGED_NORMMAP_EMISSIVE_MASK, + LLDrawPoolAvatar::RIGGED_NORMSPEC_VMASK, + LLDrawPoolAvatar::RIGGED_NORMSPEC_BLEND_MASK, + LLDrawPoolAvatar::RIGGED_NORMSPEC_MASK_MASK, + LLDrawPoolAvatar::RIGGED_NORMSPEC_EMISSIVE_MASK, LLDrawPoolAvatar::RIGGED_SIMPLE_MASK, LLDrawPoolAvatar::RIGGED_FULLBRIGHT_MASK, LLDrawPoolAvatar::RIGGED_SHINY_MASK, -- cgit v1.2.3 From 78d23e66425265e43584c6c4fd4fce9c675f4771 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 10 Apr 2013 00:27:32 -0500 Subject: NORSPEC-75 Add appropriate draw calls to underwater render passes so objects with material data don't disappear in water. --- indra/newview/llface.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'indra/newview/llface.cpp') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 3d6acedd02..8f8b35c578 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -1311,6 +1311,8 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, { if (tep) { + LLMaterial* mat = tep->getMaterialParams().get(); + GLfloat alpha[4] = { 0.00f, @@ -1319,7 +1321,9 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, 0.75f }; - if (getPoolType() != LLDrawPool::POOL_ALPHA && (LLPipeline::sRenderDeferred || (LLPipeline::sRenderBump && tep->getShiny()))) + if ((!LLPipeline::sRenderDeferred || !mat) && + getPoolType() != LLDrawPool::POOL_ALPHA && + (LLPipeline::sRenderDeferred || (LLPipeline::sRenderBump && tep->getShiny()))) { color.mV[3] = U8 (alpha[tep->getShiny()] * 255); } -- cgit v1.2.3 From 8bf4f1591114f135c64bee5cb9cb5e67bbcf8acd Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 25 Apr 2013 17:15:47 -0500 Subject: NORSPEC-104 Fix for texture animation sometimes not overriding specular and normal map texture coordinates. --- indra/newview/llface.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'indra/newview/llface.cpp') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 8f8b35c578..6474e1b1de 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -1624,11 +1624,18 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, U8 tex_mode = 0; + bool tex_anim = false; + + LLVOVolume* vobj = (LLVOVolume*) (LLViewerObject*) mVObjp; + tex_mode = vobj->mTexAnimMode; + + if (vobj->mTextureAnimp) + { //texture animation is in play, override specular and normal map tex coords with diffuse texcoords + tex_anim = true; + } + if (isState(TEXTURE_ANIM)) { - LLVOVolume* vobj = (LLVOVolume*) (LLViewerObject*) mVObjp; - tex_mode = vobj->mTexAnimMode; - if (!tex_mode) { clearState(TEXTURE_ANIM); @@ -1643,7 +1650,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, do_xform = false; } - + if (getVirtualSize() >= MIN_TEX_ANIM_SIZE) { //don't override texture transform during tc bake tex_mode = 0; @@ -1802,7 +1809,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, if (mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1)) { mVertexBuffer->getTexCoord1Strider(dst, mGeomIndex, mGeomCount, map_range); - if (mat) + if (mat && !tex_anim) { r = mat->getNormalRotation(); mat->getNormalOffset(os, ot); @@ -1822,7 +1829,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, if (mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD2)) { mVertexBuffer->getTexCoord2Strider(dst, mGeomIndex, mGeomCount, map_range); - if (mat) + if (mat && !tex_anim) { r = mat->getSpecularRotation(); mat->getSpecularOffset(os, ot); -- cgit v1.2.3 From 6bb9c2720e42be43741e470fb5b347686e584b6b Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 2 May 2013 12:35:48 -0500 Subject: NORSPEC-149 Fix for objects set to alpha blend sometimes getting tossed into alpha mask pool. --- indra/newview/llface.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indra/newview/llface.cpp') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 6474e1b1de..08a16c9c33 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -1097,6 +1097,12 @@ bool LLFace::canRenderAsMask() { return false; } + + LLMaterial* mat = te->getMaterialParams(); + if (mat && mat->getDiffuseAlphaMode() == LLMaterial::DIFFUSE_ALPHA_MODE_BLEND) + { + return false; + } if ((te->getColor().mV[3] == 1.0f) && // can't treat as mask if we have face alpha (te->getGlow() == 0.f) && // glowing masks are hard to implement - don't mask -- cgit v1.2.3 From 9187a06d0bc70ea7670192a5fe53f75ef6f36259 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Fri, 3 May 2013 09:16:15 -0700 Subject: NORSPEC-151 make disabling bumpyshiny disable adv lighting model as well --- indra/newview/llface.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llface.cpp') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 879dbf8470..999bfc48ef 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -1331,6 +1331,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, getPoolType() != LLDrawPool::POOL_ALPHA && (LLPipeline::sRenderDeferred || (LLPipeline::sRenderBump && tep->getShiny()))) { + llassert(tep->getShiny() <= 3); color.mV[3] = U8 (alpha[tep->getShiny()] * 255); } } -- cgit v1.2.3 From a9ede989158ceaa4914ea48ff6a2027e89fdbda2 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Mon, 6 May 2013 08:56:32 -0700 Subject: NORSPEC-126 Make objects with normal maps applied obey legacy shiny settings --- indra/newview/llface.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/llface.cpp') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 999bfc48ef..201cb54df6 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -1327,7 +1327,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, 0.75f }; - if ((!LLPipeline::sRenderDeferred || !mat) && + if ((!LLPipeline::sRenderDeferred || !mat || mat->getSpecularID().isNull()) && getPoolType() != LLDrawPool::POOL_ALPHA && (LLPipeline::sRenderDeferred || (LLPipeline::sRenderBump && tep->getShiny()))) { @@ -1335,6 +1335,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, color.mV[3] = U8 (alpha[tep->getShiny()] * 255); } } + } // INDICES -- cgit v1.2.3 From e413f4b335a2f4f5a1ca151c8ab67324a72ebaee Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Fri, 10 May 2013 15:13:07 -0700 Subject: Fixup merge diffs --- indra/newview/llface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llface.cpp') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 201cb54df6..007ad1f8d9 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -594,8 +594,8 @@ void LLFace::renderSelected(LLViewerTexture *imagep, const LLColor4& color) /* removed in lieu of raycast uv detection void LLFace::renderSelectedUV() { - LLViewerTexture* red_blue_imagep = LLViewerTextureManager::getFetchedTextureFromFile("uv_test1.j2c", TRUE, LLViewerTexture::BOOST_UI); - LLViewerTexture* green_imagep = LLViewerTextureManager::getFetchedTextureFromFile("uv_test2.tga", TRUE, LLViewerTexture::BOOST_UI); + LLViewerTexture* red_blue_imagep = LLViewerTextureManager::getFetchedTextureFromFile("uv_test1.j2c", TRUE, LLGLTexture::BOOST_UI); + LLViewerTexture* green_imagep = LLViewerTextureManager::getFetchedTextureFromFile("uv_test2.tga", TRUE, LLGLTexture::BOOST_UI); LLGLSUVSelect object_select; -- cgit v1.2.3 From a37bff8bf1add5afe154b25156d7ebe38ff9af31 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Tue, 14 May 2013 15:26:43 -0700 Subject: NORSPEC-103 reflect normal/spec UVs in face edit overlay display --- indra/newview/llface.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview/llface.cpp') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 007ad1f8d9..eb78d42c35 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -582,7 +582,9 @@ void LLFace::renderSelected(LLViewerTexture *imagep, const LLColor4& color) } else { - mVertexBuffer->setBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0); + // cheaters sometimes prosper... + // + mVertexBuffer->setBuffer(mVertexBuffer->getTypeMask()); mVertexBuffer->draw(LLRender::TRIANGLES, mIndicesCount, mIndicesIndex); } -- cgit v1.2.3 From 743d1a777e5c2827d50051c3f5e0942a870a6ff9 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 29 May 2013 18:48:09 -0500 Subject: NORSPEC-198, NORSPEC-176, NORSPEC-106, NORSPEC-202 et al -- Material matrix testing based overhaul WIP Reviewed by Graham --- indra/newview/llface.cpp | 49 +++++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 17 deletions(-) (limited to 'indra/newview/llface.cpp') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index eb78d42c35..63919630fc 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -1316,28 +1316,44 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, LLColor4U color = tep->getColor(); if (rebuild_color) - { - if (tep) + { //decide if shiny goes in alpha channel of color + if (tep && + getPoolType() != LLDrawPool::POOL_ALPHA) // <--- alpha channel MUST contain transparency, not shiny { LLMaterial* mat = tep->getMaterialParams().get(); + + bool shiny_in_alpha = false; + + if (LLPipeline::sRenderDeferred) + { //store shiny in alpha if we don't have a specular map + if (!mat || mat->getSpecularID().isNull()) + { + shiny_in_alpha = true; + } + } + else + { + if (!mat || mat->getDiffuseAlphaMode() != LLMaterial::DIFFUSE_ALPHA_MODE_MASK) + { + shiny_in_alpha = true; + } + } - GLfloat alpha[4] = + if (shiny_in_alpha) { - 0.00f, - 0.25f, - 0.5f, - 0.75f - }; + + GLfloat alpha[4] = + { + 0.00f, + 0.25f, + 0.5f, + 0.75f + }; - if ((!LLPipeline::sRenderDeferred || !mat || mat->getSpecularID().isNull()) && - getPoolType() != LLDrawPool::POOL_ALPHA && - (LLPipeline::sRenderDeferred || (LLPipeline::sRenderBump && tep->getShiny()))) - { llassert(tep->getShiny() <= 3); color.mV[3] = U8 (alpha[tep->getShiny()] * 255); } } - } // INDICES @@ -2117,11 +2133,10 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, LLVector4a src; - U32 glow32 = glow | - (glow << 8) | - (glow << 16) | - (glow << 24); + LLColor4U glow4u = LLColor4U(0,0,0,glow); + U32 glow32 = glow4u.mAll; + U32 vec[4]; vec[0] = vec[1] = vec[2] = vec[3] = glow32; -- cgit v1.2.3 From c3f14b915c38a4978745f12f1f816572cce4b5a0 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 3 Jun 2013 12:50:48 -0500 Subject: NORSPEC-229 Fix for bad binormals on mirrored surfaces (use tangent calculator instead of binormal calculator, convert binormal centric code to tangent centric) --- indra/newview/llface.cpp | 147 ++++++++++++++++++----------------------------- 1 file changed, 55 insertions(+), 92 deletions(-) (limited to 'indra/newview/llface.cpp') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 63919630fc..46d6a1a97f 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -106,41 +106,6 @@ void planarProjection(LLVector2 &tc, const LLVector4a& normal, tc.mV[0] = 1.0f+((binormal.dot3(vec).getF32())*2 - 0.5f); } -void sphericalProjection(LLVector2 &tc, const LLVector4a& normal, - const LLVector4a &mCenter, const LLVector4a& vec) -{ //BROKEN - /*tc.mV[0] = acosf(vd.mNormal * LLVector3(1,0,0))/3.14159f; - - tc.mV[1] = acosf(vd.mNormal * LLVector3(0,0,1))/6.284f; - if (vd.mNormal.mV[1] > 0) - { - tc.mV[1] = 1.0f-tc.mV[1]; - }*/ -} - -void cylindricalProjection(LLVector2 &tc, const LLVector4a& normal, const LLVector4a &mCenter, const LLVector4a& vec) -{ //BROKEN - /*LLVector3 binormal; - float d = vd.mNormal * LLVector3(1,0,0); - if (d >= 0.5f || d <= -0.5f) - { - binormal = LLVector3(0,1,0); - } - else{ - binormal = LLVector3(1,0,0); - } - LLVector3 tangent = binormal % vd.mNormal; - - tc.mV[1] = -((tangent*vec)*2 - 0.5f); - - tc.mV[0] = acosf(vd.mNormal * LLVector3(1,0,0))/6.284f; - - if (vd.mNormal.mV[1] < 0) - { - tc.mV[0] = 1.0f-tc.mV[0]; - }*/ -} - //////////////////// // // LLFace implementation @@ -937,7 +902,7 @@ BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f, // integrated with getGeometryVolume() for its texture coordinate // generation - but i'll leave that to someone more familiar // with the implications. -LLVector2 LLFace::surfaceToTexture(LLVector2 surface_coord, LLVector3 position, LLVector3 normal) +LLVector2 LLFace::surfaceToTexture(LLVector2 surface_coord, const LLVector4a& position, const LLVector4a& normal) { LLVector2 tc = surface_coord; @@ -957,7 +922,9 @@ LLVector2 LLFace::surfaceToTexture(LLVector2 surface_coord, LLVector3 position, LLVector4a& center = *(mDrawablep->getVOVolume()->getVolume()->getVolumeFace(mTEOffset).mCenter); LLVector4a volume_position; - volume_position.load3(mDrawablep->getVOVolume()->agentPositionToVolume(position).mV); + LLVector3 v_position(position.getF32ptr()); + + volume_position.load3(mDrawablep->getVOVolume()->agentPositionToVolume(v_position).mV); if (!mDrawablep->getVOVolume()->isVolumeGlobal()) { @@ -967,23 +934,14 @@ LLVector2 LLFace::surfaceToTexture(LLVector2 surface_coord, LLVector3 position, } LLVector4a volume_normal; - volume_normal.load3(mDrawablep->getVOVolume()->agentDirectionToVolume(normal).mV); + LLVector3 v_normal(normal.getF32ptr()); + volume_normal.load3(mDrawablep->getVOVolume()->agentDirectionToVolume(v_normal).mV); volume_normal.normalize3fast(); - switch (texgen) + if (texgen == LLTextureEntry::TEX_GEN_PLANAR) { - case LLTextureEntry::TEX_GEN_PLANAR: planarProjection(tc, volume_normal, center, volume_position); - break; - case LLTextureEntry::TEX_GEN_SPHERICAL: - sphericalProjection(tc, volume_normal, center, volume_position); - break; - case LLTextureEntry::TEX_GEN_CYLINDRICAL: - cylindricalProjection(tc, volume_normal, center, volume_position); - break; - default: - break; - } + } } if (mTextureMatrix) // if we have a texture matrix, use it @@ -1010,7 +968,12 @@ void LLFace::getPlanarProjectedParams(LLQuaternion* face_rot, LLVector3* face_po const LLMatrix4& vol_mat = getWorldMatrix(); const LLVolumeFace& vf = getViewerObject()->getVolume()->getVolumeFace(mTEOffset); const LLVector4a& normal4a = vf.mNormals[0]; - const LLVector4a& binormal4a = vf.mBinormals[0]; + const LLVector4a& tangent = vf.mTangents[0]; + + LLVector4a binormal4a; + binormal4a.setCross3(normal4a, tangent); + binormal4a.mul(tangent.getF32ptr()[3]); + LLVector2 projected_binormal; planarProjection(projected_binormal, normal4a, *vf.mCenter, binormal4a); projected_binormal -= LLVector2(0.5f, 0.5f); // this normally happens in xform() @@ -1138,7 +1101,7 @@ void LLFace::cacheFaceInVRAM(const LLVolumeFace& vf) { LLFastTimer t(FTM_FACE_GEOM_VOLUME); U32 mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | - LLVertexBuffer::MAP_BINORMAL | LLVertexBuffer::MAP_NORMAL; + LLVertexBuffer::MAP_TANGENT | LLVertexBuffer::MAP_NORMAL; if (vf.mWeights) { @@ -1151,11 +1114,11 @@ void LLFace::cacheFaceInVRAM(const LLVolumeFace& vf) buff->allocateBuffer(vf.mNumVertices, 0, true); LLStrider f_vert; - LLStrider f_binorm; + LLStrider f_tangent; LLStrider f_norm; LLStrider f_tc; - buff->getBinormalStrider(f_binorm); + buff->getTangentStrider(f_tangent); buff->getVertexStrider(f_vert); buff->getNormalStrider(f_norm); buff->getTexCoord0Strider(f_tc); @@ -1163,7 +1126,7 @@ void LLFace::cacheFaceInVRAM(const LLVolumeFace& vf) for (U32 i = 0; i < vf.mNumVertices; ++i) { *f_vert++ = vf.mPositions[i]; - (*f_binorm++).set(vf.mBinormals[i].getF32ptr()); + *f_tangent++ = vf.mTangents[i]; *f_tc++ = vf.mTexCoords[i]; (*f_norm++).set(vf.mNormals[i].getF32ptr()); } @@ -1205,7 +1168,7 @@ static LLFastTimer::DeclareTimer FTM_FACE_GEOM_TEXTURE("Texture"); static LLFastTimer::DeclareTimer FTM_FACE_GEOM_COLOR("Color"); static LLFastTimer::DeclareTimer FTM_FACE_GEOM_EMISSIVE("Emissive"); static LLFastTimer::DeclareTimer FTM_FACE_GEOM_WEIGHTS("Weights"); -static LLFastTimer::DeclareTimer FTM_FACE_GEOM_BINORMAL("Binormal"); +static LLFastTimer::DeclareTimer FTM_FACE_GEOM_TANGENT("Binormal"); static LLFastTimer::DeclareTimer FTM_FACE_GEOM_INDEX("Index"); static LLFastTimer::DeclareTimer FTM_FACE_GEOM_INDEX_TAIL("Tail"); static LLFastTimer::DeclareTimer FTM_FACE_POSITION_STORE("Pos"); @@ -1271,7 +1234,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, LLStrider tex_coords2; LLStrider norm; LLStrider colors; - LLStrider binorm; + LLStrider tangent; LLStrider indicesp; LLStrider wght; @@ -1293,7 +1256,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, bool rebuild_emissive = rebuild_color && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_EMISSIVE); bool rebuild_tcoord = full_rebuild || mDrawablep->isState(LLDrawable::REBUILD_TCOORD); bool rebuild_normal = rebuild_pos && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_NORMAL); - bool rebuild_binormal = rebuild_pos && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_BINORMAL); + bool rebuild_tangent = rebuild_pos && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TANGENT); bool rebuild_weights = rebuild_pos && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_WEIGHT4); const LLTextureEntry *tep = mVObjp->getTE(f); @@ -1441,7 +1404,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, if (vf.mVertexBuffer.isNull() || buff->getNumVerts() != vf.mNumVertices) { - mVObjp->getVolume()->genBinormals(f); + mVObjp->getVolume()->genTangents(f); LLFace::cacheFaceInVRAM(vf); buff = (LLVertexBuffer*) vf.mVertexBuffer.get(); } @@ -1526,15 +1489,15 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, glEndTransformFeedback(); } - if (rebuild_binormal) + if (rebuild_tangent) { - LLFastTimer t(FTM_FACE_GEOM_BINORMAL); - gTransformBinormalProgram.bind(); + LLFastTimer t(FTM_FACE_GEOM_TANGENT); + gTransformTangentProgram.bind(); - mVertexBuffer->bindForFeedback(0, LLVertexBuffer::TYPE_BINORMAL, mGeomIndex, mGeomCount); + mVertexBuffer->bindForFeedback(0, LLVertexBuffer::TYPE_TANGENT, mGeomIndex, mGeomCount); glBeginTransformFeedback(GL_POINTS); - buff->setBuffer(LLVertexBuffer::MAP_BINORMAL); + buff->setBuffer(LLVertexBuffer::MAP_TANGENT); push_for_transform(buff, vf.mNumVertices, mGeomCount); glEndTransformFeedback(); } @@ -1596,7 +1559,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, if (bump_code) { - mVObjp->getVolume()->genBinormals(f); + mVObjp->getVolume()->genTangents(f); F32 offset_multiple; switch( bump_code ) { @@ -1645,7 +1608,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, U8 texgen = getTextureEntry()->getTexGen(); if (rebuild_tcoord && texgen != LLTextureEntry::TEX_GEN_DEFAULT) { //planar texgen needs binormals - mVObjp->getVolume()->genBinormals(f); + mVObjp->getVolume()->genTangents(f); } U8 tex_mode = 0; @@ -1887,20 +1850,10 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, vec.mul(scalea); - switch (texgen) + if (texgen == LLTextureEntry::TEX_GEN_PLANAR) { - case LLTextureEntry::TEX_GEN_PLANAR: - planarProjection(tc, norm, center, vec); - break; - case LLTextureEntry::TEX_GEN_SPHERICAL: - sphericalProjection(tc, norm, center, vec); - break; - case LLTextureEntry::TEX_GEN_CYLINDRICAL: - cylindricalProjection(tc, norm, center, vec); - break; - default: - break; - } + planarProjection(tc, norm, center, vec); + } } if (tex_mode && mTextureMatrix) @@ -1934,11 +1887,14 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, for (S32 i = 0; i < num_vertices; i++) { - LLVector4a tangent; - tangent.setCross3(vf.mBinormals[i], vf.mNormals[i]); + LLVector4a tangent = vf.mTangents[i]; + LLVector4a binorm; + binorm.setCross3(vf.mNormals[i], tangent); + binorm.mul(tangent.getF32ptr()[3]); + LLMatrix4a tangent_to_object; - tangent_to_object.setRows(tangent, vf.mBinormals[i], vf.mNormals[i]); + tangent_to_object.setRows(tangent, binorm, vf.mNormals[i]); LLVector4a t; tangent_to_object.rotate(binormal_dir, t); LLVector4a binormal; @@ -2056,21 +2012,28 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, } } - if (rebuild_binormal) + if (rebuild_tangent) { - LLFastTimer t(FTM_FACE_GEOM_BINORMAL); - mVertexBuffer->getBinormalStrider(binorm, mGeomIndex, mGeomCount, map_range); - F32* binormals = (F32*) binorm.get(); + LLFastTimer t(FTM_FACE_GEOM_TANGENT); + mVertexBuffer->getTangentStrider(tangent, mGeomIndex, mGeomCount, map_range); + F32* tangents = (F32*) tangent.get(); - mVObjp->getVolume()->genBinormals(f); + mVObjp->getVolume()->genTangents(f); + LLVector4Logical mask; + mask.clear(); + mask.setElement<3>(); + for (S32 i = 0; i < num_vertices; i++) { - LLVector4a binormal; - mat_normal.rotate(vf.mBinormals[i], binormal); - binormal.normalize3fast(); - binormal.store4a(binormals); - binormals += 4; + LLVector4a tangent_out; + mat_normal.rotate(vf.mTangents[i], tangent_out); + tangent_out.normalize3fast(); + + tangent_out.setSelectWithMask(mask, vf.mTangents[i], tangent_out); + tangent_out.store4a(tangents); + + tangents += 4; } if (map_range) -- cgit v1.2.3 From eba7eb2d062c43cd83cb6972e4e05dc54d409582 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Sat, 8 Jun 2013 06:28:48 -0700 Subject: NORSPEC-233 fix default value and material apply logic errors --- indra/newview/llface.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/llface.cpp') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 46d6a1a97f..3e503cb750 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -1655,8 +1655,8 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, if (mat && !do_bump) { - do_bump = mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1) || - mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD2); + do_bump = mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1) + || mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD2); } bool do_tex_mat = tex_mode && mTextureMatrix; @@ -1780,7 +1780,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, std::vector bump_tc; - if (mat) + if (mat && !mat->getNormalID().isNull()) { //writing out normal and specular texture coordinates, not bump offsets do_bump = false; } -- cgit v1.2.3 From d2b253f1f6072beead770519849ad3b18a1a4359 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Wed, 12 Jun 2013 09:16:19 -0700 Subject: Changes to protect against use of normalize3fast on degenerate vectors --- indra/newview/llface.cpp | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'indra/newview/llface.cpp') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 3e503cb750..b34370fa87 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -817,6 +817,12 @@ BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f, size.mul(scale); } + // Catch potential badness from normalization before it happens + // + llassert(mat_normal.mMatrix[0].isFinite3() && (mat_normal.mMatrix[0].dot3(mat_normal.mMatrix[0]).getF32() > F_APPROXIMATELY_ZERO)); + llassert(mat_normal.mMatrix[1].isFinite3() && (mat_normal.mMatrix[1].dot3(mat_normal.mMatrix[1]).getF32() > F_APPROXIMATELY_ZERO)); + llassert(mat_normal.mMatrix[2].isFinite3() && (mat_normal.mMatrix[2].dot3(mat_normal.mMatrix[2]).getF32() > F_APPROXIMATELY_ZERO)); + mat_normal.mMatrix[0].normalize3fast(); mat_normal.mMatrix[1].normalize3fast(); mat_normal.mMatrix[2].normalize3fast(); @@ -936,7 +942,9 @@ LLVector2 LLFace::surfaceToTexture(LLVector2 surface_coord, const LLVector4a& po LLVector4a volume_normal; LLVector3 v_normal(normal.getF32ptr()); volume_normal.load3(mDrawablep->getVOVolume()->agentDirectionToVolume(v_normal).mV); - volume_normal.normalize3fast(); + LLVector4a default_norm; + default_norm.set(0,1,0,1); + volume_normal.normalize3fast_checked(&default_norm); if (texgen == LLTextureEntry::TEX_GEN_PLANAR) { @@ -1909,7 +1917,10 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, binormal.load3(t.mV); } - binormal.normalize3fast(); + LLVector4a default_binorm; + default_binorm.set(1,0,0,1); + binormal.normalize3fast_checked(&default_binorm); + LLVector2 tc = bump_tc[i]; tc += LLVector2( bump_s_primary_light_ray.dot3(tangent).getF32(), bump_t_primary_light_ray.dot3(binormal).getF32() ); @@ -1996,12 +2007,13 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, LLFastTimer t(FTM_FACE_GEOM_NORMAL); mVertexBuffer->getNormalStrider(norm, mGeomIndex, mGeomCount, map_range); F32* normals = (F32*) norm.get(); - + LLVector4a default_norm; + default_norm.set(0,1,0,1); for (S32 i = 0; i < num_vertices; i++) { LLVector4a normal; mat_normal.rotate(vf.mNormals[i], normal); - normal.normalize3fast(); + normal.normalize3fast_checked(&default_norm); normal.store4a(normals); normals += 4; } @@ -2024,12 +2036,14 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, mask.clear(); mask.setElement<3>(); + LLVector4a default_tangent; + default_tangent.set(0,0,1,1); + for (S32 i = 0; i < num_vertices; i++) { LLVector4a tangent_out; mat_normal.rotate(vf.mTangents[i], tangent_out); - tangent_out.normalize3fast(); - + tangent_out.normalize3fast_checked(&default_tangent); tangent_out.setSelectWithMask(mask, vf.mTangents[i], tangent_out); tangent_out.store4a(tangents); @@ -2244,7 +2258,10 @@ BOOL LLFace::calcPixelArea(F32& cos_angle_to_view_dir, F32& radius) dist *= 16.f; } - lookAt.normalize3fast() ; + LLVector4a default_lookat; + default_lookat.set(0,0,1,1); + + lookAt.normalize3fast_checked(&default_lookat); //get area of circle around node F32 app_angle = atanf((F32) sqrt(size_squared) / dist); -- cgit v1.2.3 From 88553c9eb1aee59d092cbd73c64da82497fd095f Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Wed, 12 Jun 2013 12:19:48 -0700 Subject: Cleanup rollback and try point MIPs experiment to see if that's what is hosing the Mac on 10.6.8 --- indra/newview/llface.cpp | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'indra/newview/llface.cpp') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index b34370fa87..f021f4ed0f 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -942,9 +942,7 @@ LLVector2 LLFace::surfaceToTexture(LLVector2 surface_coord, const LLVector4a& po LLVector4a volume_normal; LLVector3 v_normal(normal.getF32ptr()); volume_normal.load3(mDrawablep->getVOVolume()->agentDirectionToVolume(v_normal).mV); - LLVector4a default_norm; - default_norm.set(0,1,0,1); - volume_normal.normalize3fast_checked(&default_norm); + volume_normal.normalize3fast(); if (texgen == LLTextureEntry::TEX_GEN_PLANAR) { @@ -1917,9 +1915,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, binormal.load3(t.mV); } - LLVector4a default_binorm; - default_binorm.set(1,0,0,1); - binormal.normalize3fast_checked(&default_binorm); + binormal.normalize3fast(); LLVector2 tc = bump_tc[i]; tc += LLVector2( bump_s_primary_light_ray.dot3(tangent).getF32(), bump_t_primary_light_ray.dot3(binormal).getF32() ); @@ -2007,13 +2003,11 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, LLFastTimer t(FTM_FACE_GEOM_NORMAL); mVertexBuffer->getNormalStrider(norm, mGeomIndex, mGeomCount, map_range); F32* normals = (F32*) norm.get(); - LLVector4a default_norm; - default_norm.set(0,1,0,1); for (S32 i = 0; i < num_vertices; i++) { LLVector4a normal; mat_normal.rotate(vf.mNormals[i], normal); - normal.normalize3fast_checked(&default_norm); + normal.normalize3fast(); normal.store4a(normals); normals += 4; } @@ -2036,14 +2030,11 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, mask.clear(); mask.setElement<3>(); - LLVector4a default_tangent; - default_tangent.set(0,0,1,1); - for (S32 i = 0; i < num_vertices; i++) { LLVector4a tangent_out; mat_normal.rotate(vf.mTangents[i], tangent_out); - tangent_out.normalize3fast_checked(&default_tangent); + tangent_out.normalize3fast(); tangent_out.setSelectWithMask(mask, vf.mTangents[i], tangent_out); tangent_out.store4a(tangents); @@ -2258,10 +2249,7 @@ BOOL LLFace::calcPixelArea(F32& cos_angle_to_view_dir, F32& radius) dist *= 16.f; } - LLVector4a default_lookat; - default_lookat.set(0,0,1,1); - - lookAt.normalize3fast_checked(&default_lookat); + lookAt.normalize3fast(); //get area of circle around node F32 app_angle = atanf((F32) sqrt(size_squared) / dist); -- cgit v1.2.3