Trying to set materials up for rendering! Yay!
parent
cc7ae8fbd1
commit
5f03e197f4
|
|
@ -60,7 +60,7 @@ public:
|
|||
F32 getSpecularRotation() const { return mSpecularRotation; }
|
||||
void setSpecularRotation(F32 rot) { mSpecularRotation = rot; }
|
||||
|
||||
const LLColor4U& getSpecularLightColor() const { return mSpecularLightColor; }
|
||||
const LLColor4U getSpecularLightColor() const { return mSpecularLightColor; }
|
||||
void setSpecularLightColor(const LLColor4U& color) { mSpecularLightColor = color; }
|
||||
U8 getSpecularLightExponent() const { return mSpecularLightExponent; }
|
||||
void setSpecularLightExponent(U8 exponent) { mSpecularLightExponent = exponent; }
|
||||
|
|
|
|||
|
|
@ -271,7 +271,6 @@ S32 LLPrimitive::setTEScale(const U8 index, const F32 s, const F32 t)
|
|||
return mTextureList.setScale(index, s, t);
|
||||
}
|
||||
|
||||
|
||||
// BUG: slow - done this way because texture entries have some
|
||||
// voodoo related to texture coords
|
||||
S32 LLPrimitive::setTEScaleS(const U8 index, const F32 s)
|
||||
|
|
@ -372,6 +371,10 @@ S32 LLPrimitive::setTEMaterialID(const U8 index, const LLMaterialID& pMaterialID
|
|||
return mTextureList.setMaterialID(index, pMaterialID);
|
||||
}
|
||||
|
||||
S32 LLPrimitive::setTEMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams)
|
||||
{
|
||||
return mTextureList.setMaterialParams(index, pMaterialParams);
|
||||
}
|
||||
|
||||
LLPCode LLPrimitive::legacyToPCode(const U8 legacy)
|
||||
{
|
||||
|
|
@ -1349,6 +1352,7 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_nam
|
|||
retval |= setTEMediaTexGen(i, media_flags[i]);
|
||||
retval |= setTEGlow(i, (F32)glow[i] / (F32)0xFF);
|
||||
retval |= setTEMaterialID(i, material_ids[i]);
|
||||
|
||||
coloru = LLColor4U(colors + 4*i);
|
||||
|
||||
// Note: This is an optimization to send common colors (1.f, 1.f, 1.f, 1.f)
|
||||
|
|
|
|||
|
|
@ -355,6 +355,7 @@ public:
|
|||
virtual S32 setTEMediaFlags(const U8 te, const U8 flags);
|
||||
virtual S32 setTEGlow(const U8 te, const F32 glow);
|
||||
virtual S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID);
|
||||
virtual S32 setTEMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams);
|
||||
virtual BOOL setMaterial(const U8 material); // returns TRUE if material changed
|
||||
|
||||
void copyTEs(const LLPrimitive *primitive);
|
||||
|
|
|
|||
|
|
@ -369,6 +369,15 @@ S32 LLPrimTextureList::setMaterialID(const U8 index, const LLMaterialID& pMateri
|
|||
return TEM_CHANGE_NONE;
|
||||
}
|
||||
|
||||
S32 LLPrimTextureList::setMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams)
|
||||
{
|
||||
if (index < mEntryList.size())
|
||||
{
|
||||
return mEntryList[index]->setMaterialParams(pMaterialParams);
|
||||
}
|
||||
return TEM_CHANGE_NONE;
|
||||
}
|
||||
|
||||
S32 LLPrimTextureList::size() const
|
||||
{
|
||||
return mEntryList.size();
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include "lluuid.h"
|
||||
#include "v3color.h"
|
||||
#include "v4color.h"
|
||||
#include "llmaterial.h"
|
||||
|
||||
|
||||
class LLTextureEntry;
|
||||
|
|
@ -104,6 +105,7 @@ public:
|
|||
S32 setMediaFlags(const U8 index, const U8 media_flags);
|
||||
S32 setGlow(const U8 index, const F32 glow);
|
||||
S32 setMaterialID(const U8 index, const LLMaterialID& pMaterialID);
|
||||
S32 setMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams);
|
||||
|
||||
S32 size() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -540,6 +540,16 @@ S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID)
|
|||
return TEM_CHANGE_NONE;
|
||||
}
|
||||
|
||||
S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams)
|
||||
{
|
||||
if (mMaterial != pMaterialParams)
|
||||
{
|
||||
mMaterial = pMaterialParams;
|
||||
return TEM_CHANGE_TEXTURE;
|
||||
}
|
||||
return TEM_CHANGE_NONE;
|
||||
}
|
||||
|
||||
void LLTextureEntry::setMediaData(const LLMediaEntry &media_entry)
|
||||
{
|
||||
mMediaFlags |= MF_HAS_MEDIA;
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@ public:
|
|||
S32 setMediaTexGen(U8 media);
|
||||
S32 setGlow(F32 glow);
|
||||
S32 setMaterialID(const LLMaterialID& pMaterialID);
|
||||
S32 setMaterialParams(const LLMaterialPtr pMaterialParams);
|
||||
|
||||
virtual const LLUUID &getID() const { return mID; }
|
||||
const LLColor4 &getColor() const { return mColor; }
|
||||
|
|
@ -143,6 +144,7 @@ public:
|
|||
U8 getMediaTexGen() const { return mMediaFlags; }
|
||||
F32 getGlow() const { return mGlow; }
|
||||
const LLMaterialID& getMaterialID() const { return mMaterialID; };
|
||||
const LLMaterialPtr getMaterialParams() const { return mMaterial; };
|
||||
|
||||
// *NOTE: it is possible for hasMedia() to return true, but getMediaData() to return NULL.
|
||||
// CONVERSELY, it is also possible for hasMedia() to return false, but getMediaData()
|
||||
|
|
|
|||
|
|
@ -1124,6 +1124,8 @@ void LLShaderMgr::initAttribsAndUniforms()
|
|||
|
||||
mReservedUniforms.push_back("global_gamma");
|
||||
mReservedUniforms.push_back("texture_gamma");
|
||||
|
||||
mReservedUniforms.push_back("specular_color");
|
||||
|
||||
llassert(mReservedUniforms.size() == END_RESERVED_UNIFORMS);
|
||||
|
||||
|
|
|
|||
|
|
@ -168,6 +168,8 @@ public:
|
|||
GLOBAL_GAMMA,
|
||||
TEXTURE_GAMMA,
|
||||
|
||||
SPECULAR_COLOR,
|
||||
|
||||
END_RESERVED_UNIFORMS
|
||||
} eGLSLReservedUniforms;
|
||||
|
||||
|
|
|
|||
|
|
@ -300,6 +300,53 @@ LLFace* LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep)
|
|||
|
||||
}
|
||||
|
||||
LLFace* LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep, LLViewerTexture *normalp)
|
||||
{
|
||||
LLMemType mt(LLMemType::MTYPE_DRAWABLE);
|
||||
|
||||
LLFace *face;
|
||||
face = new LLFace(this, mVObjp);
|
||||
|
||||
face->setTEOffset(mFaces.size());
|
||||
face->setTexture(texturep);
|
||||
face->setNormalMap(normalp);
|
||||
face->setPoolType(gPipeline.getPoolTypeFromTE(te, texturep));
|
||||
|
||||
mFaces.push_back(face);
|
||||
|
||||
if (isState(UNLIT))
|
||||
{
|
||||
face->setState(LLFace::FULLBRIGHT);
|
||||
}
|
||||
|
||||
return face;
|
||||
|
||||
}
|
||||
|
||||
LLFace* LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep, LLViewerTexture *normalp, LLViewerTexture *specularp)
|
||||
{
|
||||
LLMemType mt(LLMemType::MTYPE_DRAWABLE);
|
||||
|
||||
LLFace *face;
|
||||
face = new LLFace(this, mVObjp);
|
||||
|
||||
face->setTEOffset(mFaces.size());
|
||||
face->setTexture(texturep);
|
||||
face->setNormalMap(normalp);
|
||||
face->setSpecularMap(specularp);
|
||||
face->setPoolType(gPipeline.getPoolTypeFromTE(te, texturep));
|
||||
|
||||
mFaces.push_back(face);
|
||||
|
||||
if (isState(UNLIT))
|
||||
{
|
||||
face->setState(LLFace::FULLBRIGHT);
|
||||
}
|
||||
|
||||
return face;
|
||||
|
||||
}
|
||||
|
||||
void LLDrawable::setNumFaces(const S32 newFaces, LLFacePool *poolp, LLViewerTexture *texturep)
|
||||
{
|
||||
if (newFaces == (S32)mFaces.size())
|
||||
|
|
|
|||
|
|
@ -147,6 +147,8 @@ public:
|
|||
//void removeFace(const S32 i); // SJB: Avoid using this, it's slow
|
||||
LLFace* addFace(LLFacePool *poolp, LLViewerTexture *texturep);
|
||||
LLFace* addFace(const LLTextureEntry *te, LLViewerTexture *texturep);
|
||||
LLFace* addFace(const LLTextureEntry *te, LLViewerTexture *texturep, LLViewerTexture *normalp);
|
||||
LLFace* addFace(const LLTextureEntry *te, LLViewerTexture *texturep, LLViewerTexture *normalp, LLViewerTexture *specularp);
|
||||
void deleteFaces(S32 offset, S32 count);
|
||||
void setNumFaces(const S32 numFaces, LLFacePool *poolp, LLViewerTexture *texturep);
|
||||
void setNumFacesFast(const S32 numFaces, LLFacePool *poolp, LLViewerTexture *texturep);
|
||||
|
|
|
|||
|
|
@ -632,6 +632,11 @@ void LLDrawPoolBump::renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL
|
|||
BOOL LLDrawPoolBump::bindBumpMap(LLDrawInfo& params, S32 channel)
|
||||
{
|
||||
U8 bump_code = params.mBump;
|
||||
if (params.mNormalMap.notNull())
|
||||
{
|
||||
bump_code = BE_CUSTOM;
|
||||
return bindBumpMap(bump_code, params.mNormalMap, params.mVSize, channel);
|
||||
}
|
||||
|
||||
return bindBumpMap(bump_code, params.mTexture, params.mVSize, channel);
|
||||
}
|
||||
|
|
@ -670,7 +675,9 @@ BOOL LLDrawPoolBump::bindBumpMap(U8 bump_code, LLViewerTexture* texture, F32 vsi
|
|||
case BE_DARKNESS:
|
||||
bump = gBumpImageList.getBrightnessDarknessImage( tex, bump_code );
|
||||
break;
|
||||
|
||||
case BE_CUSTOM:
|
||||
bump = tex;
|
||||
break;
|
||||
default:
|
||||
if( bump_code < LLStandardBumpmap::sStandardBumpmapCount )
|
||||
{
|
||||
|
|
@ -855,7 +862,9 @@ void LLDrawPoolBump::renderDeferred(S32 pass)
|
|||
for (LLCullResult::drawinfo_iterator i = begin; i != end; ++i)
|
||||
{
|
||||
LLDrawInfo& params = **i;
|
||||
|
||||
|
||||
gDeferredBumpProgram.uniform4fv(LLShaderMgr::SPECULAR_COLOR, 4, (GLfloat*)params.mSpecColor.mV);
|
||||
|
||||
LLDrawPoolBump::bindBumpMap(params, bump_channel);
|
||||
pushBatch(params, mask, TRUE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,8 +100,9 @@ enum EBumpEffect
|
|||
BE_NO_BUMP = 0,
|
||||
BE_BRIGHTNESS = 1,
|
||||
BE_DARKNESS = 2,
|
||||
BE_STANDARD_0 = 3, // Standard must always be the last one
|
||||
BE_COUNT = 4
|
||||
BE_CUSTOM = 3,
|
||||
BE_STANDARD_0 = 4, // Standard must always be the last one
|
||||
BE_COUNT = 5
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -111,6 +111,8 @@ public:
|
|||
void setTextureIndex(U8 index);
|
||||
U8 getTextureIndex() const { return mTextureIndex; }
|
||||
void setTexture(LLViewerTexture* tex) ;
|
||||
void setNormalMap(LLViewerTexture* tex);
|
||||
void setSpecularMap(LLViewerTexture* tex);
|
||||
void switchTexture(LLViewerTexture* new_texture);
|
||||
void dirtyTexture();
|
||||
LLXformMatrix* getXform() const { return mXform; }
|
||||
|
|
@ -266,6 +268,8 @@ public:
|
|||
F32 mLastSkinTime;
|
||||
F32 mLastMoveTime;
|
||||
LLMatrix4* mTextureMatrix;
|
||||
LLMatrix4* mSpecMapMatrix;
|
||||
LLMatrix4* mNormalMapMatrix;
|
||||
LLDrawInfo* mDrawInfo;
|
||||
|
||||
private:
|
||||
|
|
@ -285,6 +289,8 @@ private:
|
|||
|
||||
LLXformMatrix* mXform;
|
||||
LLPointer<LLViewerTexture> mTexture;
|
||||
LLPointer<LLViewerTexture> mSpecMap;
|
||||
LLPointer<LLViewerTexture> mNormalMap;
|
||||
LLPointer<LLDrawable> mDrawablep;
|
||||
LLPointer<LLViewerObject> mVObjp;
|
||||
S32 mTEOffset;
|
||||
|
|
|
|||
|
|
@ -1927,7 +1927,7 @@ void LLSelectMgr::selectionSetMedia(U8 media_type, const LLSD &media_data)
|
|||
llassert(mMediaData.isMap());
|
||||
const LLTextureEntry *texture_entry = object->getTE(te);
|
||||
if (!mMediaData.isMap() ||
|
||||
(NULL != texture_entry) && !texture_entry->hasMedia() && !mMediaData.has(LLMediaEntry::HOME_URL_KEY))
|
||||
((NULL != texture_entry) && !texture_entry->hasMedia() && !mMediaData.has(LLMediaEntry::HOME_URL_KEY)))
|
||||
{
|
||||
// skip adding/updating media
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,6 +119,17 @@ public:
|
|||
LL_ALIGN_16(LLFace* mFace); //associated face
|
||||
F32 mDistance;
|
||||
U32 mDrawMode;
|
||||
|
||||
LLMaterialID *mMaterialID; // If this is false, the following parameters are unused.
|
||||
LLPointer<LLViewerTexture> mSpecularMap;
|
||||
const LLMatrix4* mSpecularMapMatrix;
|
||||
LLPointer<LLViewerTexture> mNormalMap;
|
||||
const LLMatrix4* mNormalMapMatrix;
|
||||
LLVector4 mSpecColor; // XYZ = Specular RGB, W = Specular Exponent
|
||||
F32 mEnvIntensity;
|
||||
F32 mAlphaMaskCutoff;
|
||||
U8 mDiffuseAlphaMode;
|
||||
|
||||
|
||||
struct CompareTexture
|
||||
{
|
||||
|
|
@ -169,7 +180,7 @@ public:
|
|||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct CompareBump
|
||||
{
|
||||
bool operator()(const LLPointer<LLDrawInfo>& lhs, const LLPointer<LLDrawInfo>& rhs)
|
||||
|
|
|
|||
|
|
@ -202,6 +202,8 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe
|
|||
mTotalCRC(0),
|
||||
mListIndex(-1),
|
||||
mTEImages(NULL),
|
||||
mTENormalMaps(NULL),
|
||||
mTESpecularMaps(NULL),
|
||||
mGLName(0),
|
||||
mbCanSelect(TRUE),
|
||||
mFlags(0),
|
||||
|
|
@ -322,6 +324,18 @@ void LLViewerObject::deleteTEImages()
|
|||
{
|
||||
delete[] mTEImages;
|
||||
mTEImages = NULL;
|
||||
|
||||
if (mTENormalMaps != NULL)
|
||||
{
|
||||
delete[] mTENormalMaps;
|
||||
mTENormalMaps = NULL;
|
||||
}
|
||||
|
||||
if (mTESpecularMaps != NULL)
|
||||
{
|
||||
delete[] mTESpecularMaps;
|
||||
mTESpecularMaps = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void LLViewerObject::markDead()
|
||||
|
|
@ -3935,25 +3949,39 @@ void LLViewerObject::setNumTEs(const U8 num_tes)
|
|||
{
|
||||
LLPointer<LLViewerTexture> *new_images;
|
||||
new_images = new LLPointer<LLViewerTexture>[num_tes];
|
||||
|
||||
LLPointer<LLViewerTexture> *new_normmaps;
|
||||
new_normmaps = new LLPointer<LLViewerTexture>[num_tes];
|
||||
|
||||
LLPointer<LLViewerTexture> *new_specmaps;
|
||||
new_specmaps = new LLPointer<LLViewerTexture>[num_tes];
|
||||
for (i = 0; i < num_tes; i++)
|
||||
{
|
||||
if (i < getNumTEs())
|
||||
{
|
||||
new_images[i] = mTEImages[i];
|
||||
new_normmaps[i] = mTENormalMaps[i];
|
||||
new_specmaps[i] = mTESpecularMaps[i];
|
||||
}
|
||||
else if (getNumTEs())
|
||||
{
|
||||
new_images[i] = mTEImages[getNumTEs()-1];
|
||||
new_normmaps[i] = mTENormalMaps[i];
|
||||
new_specmaps[i] = mTESpecularMaps[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
new_images[i] = NULL;
|
||||
new_normmaps[i] = NULL;
|
||||
new_specmaps[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
deleteTEImages();
|
||||
|
||||
mTEImages = new_images;
|
||||
mTENormalMaps = new_normmaps;
|
||||
mTESpecularMaps = new_specmaps;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -4032,12 +4060,18 @@ void LLViewerObject::sendTEUpdate() const
|
|||
void LLViewerObject::setTE(const U8 te, const LLTextureEntry &texture_entry)
|
||||
{
|
||||
LLPrimitive::setTE(te, texture_entry);
|
||||
// This doesn't work, don't get any textures.
|
||||
// if (mDrawable.notNull() && mDrawable->isVisible())
|
||||
// {
|
||||
const LLUUID& image_id = getTE(te)->getID();
|
||||
mTEImages[te] = LLViewerTextureManager::getFetchedTexture(image_id, TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);
|
||||
// }
|
||||
|
||||
const LLUUID& image_id = getTE(te)->getID();
|
||||
mTEImages[te] = LLViewerTextureManager::getFetchedTexture(image_id, TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);
|
||||
|
||||
if (getTE(te)->getMaterialParams() != NULL)
|
||||
{
|
||||
const LLUUID& norm_id = getTE(te)->getMaterialParams()->getNormalID();
|
||||
mTENormalMaps[te] = LLViewerTextureManager::getFetchedTexture(norm_id, TRUE, LLViewerTexture::BOOST_BUMP, LLViewerTexture::LOD_TEXTURE);
|
||||
|
||||
const LLUUID& spec_id = getTE(te)->getMaterialParams()->getSpecularID();
|
||||
mTESpecularMaps[te] = LLViewerTextureManager::getFetchedTexture(spec_id, TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);
|
||||
}
|
||||
}
|
||||
|
||||
void LLViewerObject::setTEImage(const U8 te, LLViewerTexture *imagep)
|
||||
|
|
@ -4072,6 +4106,46 @@ S32 LLViewerObject::setTETextureCore(const U8 te, const LLUUID& uuid, LLHost hos
|
|||
return retval;
|
||||
}
|
||||
|
||||
S32 LLViewerObject::setTENormalMapCore(const U8 te, const LLUUID& uuid, LLHost host)
|
||||
{
|
||||
LL_INFOS("Materials") << "Maybe normal maps! " << uuid << LL_ENDL;
|
||||
S32 retval = 0;
|
||||
if (uuid != getTE(te)->getMaterialParams()->getNormalID() ||
|
||||
uuid == LLUUID::null)
|
||||
{
|
||||
LL_INFOS("Materials") << "Normal maps! " << uuid << LL_ENDL;
|
||||
retval = TEM_CHANGE_TEXTURE;
|
||||
getTE(te)->getMaterialParams()->setNormalID(uuid);
|
||||
mTENormalMaps[te] = LLViewerTextureManager::getFetchedTexture(uuid, TRUE, LLViewerTexture::BOOST_BUMP, LLViewerTexture::LOD_TEXTURE, 0, 0, host);
|
||||
setChanged(TEXTURE);
|
||||
if (mDrawable.notNull())
|
||||
{
|
||||
gPipeline.markTextured(mDrawable);
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
S32 LLViewerObject::setTESpecularMapCore(const U8 te, const LLUUID& uuid, LLHost host)
|
||||
{
|
||||
LL_INFOS("Materials") << "Maybe specular maps! " << uuid << LL_ENDL;
|
||||
S32 retval = 0;
|
||||
if (uuid != getTE(te)->getMaterialParams()->getSpecularID() ||
|
||||
uuid == LLUUID::null)
|
||||
{
|
||||
LL_INFOS("Materials") << "Specular maps! " << uuid << LL_ENDL;
|
||||
retval = TEM_CHANGE_TEXTURE;
|
||||
getTE(te)->getMaterialParams()->setSpecularID(uuid);
|
||||
mTESpecularMaps[te] = LLViewerTextureManager::getFetchedTexture(uuid, TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE, 0, 0, host);
|
||||
setChanged(TEXTURE);
|
||||
if (mDrawable.notNull())
|
||||
{
|
||||
gPipeline.markTextured(mDrawable);
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
//virtual
|
||||
void LLViewerObject::changeTEImage(S32 index, LLViewerTexture* new_image)
|
||||
{
|
||||
|
|
@ -4082,12 +4156,39 @@ void LLViewerObject::changeTEImage(S32 index, LLViewerTexture* new_image)
|
|||
mTEImages[index] = new_image ;
|
||||
}
|
||||
|
||||
void LLViewerObject::changeTENormalMap(S32 index, LLViewerTexture* new_image)
|
||||
{
|
||||
if(index < 0 || index >= getNumTEs())
|
||||
{
|
||||
return ;
|
||||
}
|
||||
mTENormalMaps[index] = new_image ;
|
||||
}
|
||||
|
||||
void LLViewerObject::changeTESpecularMap(S32 index, LLViewerTexture* new_image)
|
||||
{
|
||||
if(index < 0 || index >= getNumTEs())
|
||||
{
|
||||
return ;
|
||||
}
|
||||
mTESpecularMaps[index] = new_image ;
|
||||
}
|
||||
|
||||
S32 LLViewerObject::setTETexture(const U8 te, const LLUUID& uuid)
|
||||
{
|
||||
// Invalid host == get from the agent's sim
|
||||
return setTETextureCore(te, uuid, LLHost::invalid);
|
||||
}
|
||||
|
||||
S32 LLViewerObject::setTENormalMap(const U8 te, const LLUUID& uuid)
|
||||
{
|
||||
return setTENormalMapCore(te, uuid, LLHost::invalid);
|
||||
}
|
||||
|
||||
S32 LLViewerObject::setTESpecularMap(const U8 te, const LLUUID& uuid)
|
||||
{
|
||||
return setTESpecularMapCore(te, uuid, LLHost::invalid);
|
||||
}
|
||||
|
||||
S32 LLViewerObject::setTEColor(const U8 te, const LLColor3& color)
|
||||
{
|
||||
|
|
@ -4369,6 +4470,50 @@ LLViewerTexture *LLViewerObject::getTEImage(const U8 face) const
|
|||
}
|
||||
|
||||
|
||||
LLViewerTexture *LLViewerObject::getTENormalMap(const U8 face) const
|
||||
{
|
||||
// llassert(mTEImages);
|
||||
|
||||
if (face < getNumTEs())
|
||||
{
|
||||
LLViewerTexture* image = mTENormalMaps[face];
|
||||
if (image)
|
||||
{
|
||||
return image;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (LLViewerTexture*)(LLViewerFetchedTexture::sDefaultImagep);
|
||||
}
|
||||
}
|
||||
|
||||
llerrs << llformat("Requested Image from invalid face: %d/%d",face,getNumTEs()) << llendl;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LLViewerTexture *LLViewerObject::getTESpecularMap(const U8 face) const
|
||||
{
|
||||
// llassert(mTEImages);
|
||||
|
||||
if (face < getNumTEs())
|
||||
{
|
||||
LLViewerTexture* image = mTESpecularMaps[face];
|
||||
if (image)
|
||||
{
|
||||
return image;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (LLViewerTexture*)(LLViewerFetchedTexture::sDefaultImagep);
|
||||
}
|
||||
}
|
||||
|
||||
llerrs << llformat("Requested Image from invalid face: %d/%d",face,getNumTEs()) << llendl;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void LLViewerObject::fitFaceTexture(const U8 face)
|
||||
{
|
||||
llinfos << "fitFaceTexture not implemented" << llendl;
|
||||
|
|
|
|||
|
|
@ -292,7 +292,11 @@ public:
|
|||
/*virtual*/ void setNumTEs(const U8 num_tes);
|
||||
/*virtual*/ void setTE(const U8 te, const LLTextureEntry &texture_entry);
|
||||
/*virtual*/ S32 setTETexture(const U8 te, const LLUUID &uuid);
|
||||
/*virtual*/ S32 setTENormalMap(const U8 te, const LLUUID &uuid);
|
||||
/*virtual*/ S32 setTESpecularMap(const U8 te, const LLUUID &uuid);
|
||||
S32 setTETextureCore(const U8 te, const LLUUID& uuid, LLHost host);
|
||||
S32 setTENormalMapCore(const U8 te, const LLUUID& uuid, LLHost host);
|
||||
S32 setTESpecularMapCore(const U8 te, const LLUUID& uuid, LLHost host);
|
||||
/*virtual*/ S32 setTEColor(const U8 te, const LLColor3 &color);
|
||||
/*virtual*/ S32 setTEColor(const U8 te, const LLColor4 &color);
|
||||
/*virtual*/ S32 setTEScale(const U8 te, const F32 s, const F32 t);
|
||||
|
|
@ -313,7 +317,11 @@ public:
|
|||
/*virtual*/ BOOL setMaterial(const U8 material);
|
||||
virtual void setTEImage(const U8 te, LLViewerTexture *imagep); // Not derived from LLPrimitive
|
||||
virtual void changeTEImage(S32 index, LLViewerTexture* new_image) ;
|
||||
virtual void changeTENormalMap(S32 index, LLViewerTexture* new_image) ;
|
||||
virtual void changeTESpecularMap(S32 index, LLViewerTexture* new_image) ;
|
||||
LLViewerTexture *getTEImage(const U8 te) const;
|
||||
LLViewerTexture *getTENormalMap(const U8 te) const;
|
||||
LLViewerTexture *getTESpecularMap(const U8 te) const;
|
||||
|
||||
void fitFaceTexture(const U8 face);
|
||||
void sendTEUpdate() const; // Sends packed representation of all texture entry information
|
||||
|
|
@ -588,6 +596,8 @@ public:
|
|||
S32 mListIndex;
|
||||
|
||||
LLPointer<LLViewerTexture> *mTEImages;
|
||||
LLPointer<LLViewerTexture> *mTENormalMaps;
|
||||
LLPointer<LLViewerTexture> *mTESpecularMaps;
|
||||
|
||||
// Selection, picking and rendering variables
|
||||
U32 mGLName; // GL "name" used by selection code
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@
|
|||
#include "llviewershadermgr.h"
|
||||
#include "llvoavatar.h"
|
||||
#include "llvocache.h"
|
||||
#include "llmaterialmgr.h"
|
||||
|
||||
const S32 MIN_QUIET_FRAMES_COALESCE = 30;
|
||||
const F32 FORCE_SIMPLE_RENDER_AREA = 512.f;
|
||||
|
|
@ -919,6 +920,12 @@ LLFace* LLVOVolume::addFace(S32 f)
|
|||
{
|
||||
const LLTextureEntry* te = getTE(f);
|
||||
LLViewerTexture* imagep = getTEImage(f);
|
||||
if (te->getMaterialParams() != NULL)
|
||||
{
|
||||
LLViewerTexture* normalp = getTENormalMap(f);
|
||||
LLViewerTexture* specularp = getTESpecularMap(f);
|
||||
return mDrawable->addFace(te, imagep, normalp, specularp);
|
||||
}
|
||||
return mDrawable->addFace(te, imagep);
|
||||
}
|
||||
|
||||
|
|
@ -1404,6 +1411,11 @@ void LLVOVolume::regenFaces()
|
|||
|
||||
facep->setTEOffset(i);
|
||||
facep->setTexture(getTEImage(i));
|
||||
if (facep->getTextureEntry()->getMaterialParams() != NULL)
|
||||
{
|
||||
facep->setNormalMap(getTENormalMap(i));
|
||||
facep->setSpecularMap(getTESpecularMap(i));
|
||||
}
|
||||
facep->setViewerObject(this);
|
||||
|
||||
// If the face had media on it, this will have broken the link between the LLViewerMediaTexture and the face.
|
||||
|
|
@ -1979,13 +1991,33 @@ S32 LLVOVolume::setTEGlow(const U8 te, const F32 glow)
|
|||
|
||||
S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID)
|
||||
{
|
||||
S32 res = LLViewerObject::setTEMaterialID(te, pMaterialID);
|
||||
if (!pMaterialID.isNull())
|
||||
{
|
||||
LL_INFOS("Materials") << "Oh god it's a material! " << pMaterialID.asString() << LL_ENDL;
|
||||
S32 res = LLViewerObject::setTEMaterialID(te, pMaterialID);
|
||||
if (res)
|
||||
{
|
||||
LL_INFOS("Materials") << "We have a material!" << LL_ENDL;
|
||||
LLMaterialPtr pMatParam = LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID);
|
||||
setTEMaterialParams(te, pMatParam);
|
||||
gPipeline.markTextured(mDrawable);
|
||||
mFaceMappingChanged = TRUE;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
S32 LLVOVolume::setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams)
|
||||
{
|
||||
S32 res = LLViewerObject::setTEMaterialParams(te, pMaterialParams);
|
||||
if (res)
|
||||
{
|
||||
gPipeline.markTextured(mDrawable);
|
||||
mFaceMappingChanged = TRUE;
|
||||
}
|
||||
return res;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
S32 LLVOVolume::setTEScale(const U8 te, const F32 s, const F32 t)
|
||||
|
|
@ -4050,6 +4082,8 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
|
|||
LLViewerTexture* tex = facep->getTexture();
|
||||
|
||||
U8 index = facep->getTextureIndex();
|
||||
|
||||
LLMaterialID matid = facep->getTextureEntry()->getMaterialID();
|
||||
|
||||
bool batchable = false;
|
||||
|
||||
|
|
@ -4106,12 +4140,30 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
|
|||
U32 offset = facep->getIndicesStart();
|
||||
U32 count = facep->getIndicesCount();
|
||||
LLPointer<LLDrawInfo> draw_info = new LLDrawInfo(start,end,count,offset, tex,
|
||||
facep->getVertexBuffer(), fullbright, bump);
|
||||
facep->getVertexBuffer(), fullbright, bump);
|
||||
draw_info->mGroup = group;
|
||||
draw_info->mVSize = facep->getVirtualSize();
|
||||
draw_vec.push_back(draw_info);
|
||||
draw_info->mTextureMatrix = tex_mat;
|
||||
draw_info->mModelMatrix = model_mat;
|
||||
|
||||
if (!facep->getTextureEntry()->getMaterialID().isNull() && facep->getTextureEntry()->getMaterialParams() != NULL)
|
||||
{
|
||||
// We have a material. Update our draw info accordingly.
|
||||
//draw_info->mMaterialID = facep->getTextureEntry()->getMaterialID();
|
||||
LLVector4 specColor;
|
||||
specColor.mV[0] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightColor().mV[0] * (1.0 / 255);
|
||||
specColor.mV[1] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightColor().mV[1] * (1.0 / 255);
|
||||
specColor.mV[2] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightColor().mV[2] * (1.0 / 255);
|
||||
specColor.mV[3] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightExponent() * (1.0 / 255);
|
||||
draw_info->mSpecColor = specColor;
|
||||
draw_info->mEnvIntensity = facep->getTextureEntry()->getMaterialParams()->getEnvironmentIntensity() * (1.0 / 255);
|
||||
draw_info->mAlphaMaskCutoff = facep->getTextureEntry()->getMaterialParams()->getAlphaMaskCutoff() * (1.0 / 255);
|
||||
draw_info->mDiffuseAlphaMode = facep->getTextureEntry()->getMaterialParams()->getDiffuseAlphaMode();
|
||||
draw_info->mNormalMap = facep->getViewerObject()->getTENormalMap(facep->getTextureIndex());
|
||||
draw_info->mSpecularMap = facep->getViewerObject()->getTESpecularMap(facep->getTextureIndex());
|
||||
}
|
||||
|
||||
if (type == LLRenderPass::PASS_ALPHA)
|
||||
{ //for alpha sorting
|
||||
facep->setDrawInfo(draw_info);
|
||||
|
|
@ -4267,7 +4319,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
|
|||
}
|
||||
|
||||
if (vobj->isMesh() &&
|
||||
(vobj->getVolume() && !vobj->getVolume()->isMeshAssetLoaded() || !gMeshRepo.meshRezEnabled()))
|
||||
((vobj->getVolume() && !vobj->getVolume()->isMeshAssetLoaded()) || !gMeshRepo.meshRezEnabled()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
@ -5134,7 +5186,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
|
|||
registerFace(group, facep, LLRenderPass::PASS_POST_BUMP);
|
||||
}
|
||||
}
|
||||
else if (te->getBumpmap())
|
||||
else if (te->getBumpmap() || te->getMaterialParams() != NULL)
|
||||
{ //register in deferred bump pass
|
||||
registerFace(group, facep, LLRenderPass::PASS_BUMP);
|
||||
}
|
||||
|
|
@ -5169,7 +5221,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
|
|||
}
|
||||
else
|
||||
{
|
||||
if (LLPipeline::sRenderDeferred && LLPipeline::sRenderBump && te->getBumpmap())
|
||||
if (LLPipeline::sRenderDeferred && LLPipeline::sRenderBump && (te->getBumpmap() || te->getMaterialParams() != NULL))
|
||||
{ //non-shiny or fullbright deferred bump
|
||||
registerFace(group, facep, LLRenderPass::PASS_BUMP);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -187,6 +187,7 @@ public:
|
|||
/*virtual*/ S32 setTEMediaFlags(const U8 te, const U8 media_flags);
|
||||
/*virtual*/ S32 setTEGlow(const U8 te, const F32 glow);
|
||||
/*virtual*/ S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID);
|
||||
/*virtual*/ S32 setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams);
|
||||
/*virtual*/ S32 setTEScale(const U8 te, const F32 s, const F32 t);
|
||||
/*virtual*/ S32 setTEScaleS(const U8 te, const F32 s);
|
||||
/*virtual*/ S32 setTEScaleT(const U8 te, const F32 t);
|
||||
|
|
|
|||
Loading…
Reference in New Issue