Basic normal mapping support.

meow-7.2.2
Geenz 2013-01-28 19:56:18 -05:00
parent 97f9ab80f9
commit 66a01ba4c5
5 changed files with 41 additions and 22 deletions

View File

@ -677,6 +677,7 @@ BOOL LLDrawPoolBump::bindBumpMap(U8 bump_code, LLViewerTexture* texture, F32 vsi
break;
case BE_CUSTOM:
bump = tex;
bump->addTextureStats(vsize);
break;
default:
if( bump_code < LLStandardBumpmap::sStandardBumpmapCount )

View File

@ -120,7 +120,7 @@ public:
F32 mDistance;
U32 mDrawMode;
LLMaterialID *mMaterialID; // If this is false, the following parameters are unused.
const LLMaterialID *mMaterialID; // If this is false, the following parameters are unused.
LLPointer<LLViewerTexture> mSpecularMap;
const LLMatrix4* mSpecularMapMatrix;
LLPointer<LLViewerTexture> mNormalMap;

View File

@ -4110,8 +4110,8 @@ S32 LLViewerObject::setTENormalMapCore(const U8 te, const LLUUID& uuid, LLHost h
{
LL_INFOS("Materials") << "Maybe normal maps! " << uuid << LL_ENDL;
S32 retval = 0;
if (uuid != getTE(te)->getMaterialParams()->getNormalID() ||
uuid == LLUUID::null)
//if (uuid != getTE(te)->getMaterialParams()->getNormalID() ||
//uuid == LLUUID::null)
{
LL_INFOS("Materials") << "Normal maps! " << uuid << LL_ENDL;
retval = TEM_CHANGE_TEXTURE;
@ -4380,6 +4380,7 @@ S32 LLViewerObject::setTEMaterialParams(const U8 te, const LLMaterialPtr pMateri
else if (pMaterialParams != tep->getMaterialParams())
{
retval = LLPrimitive::setTEMaterialParams(te, pMaterialParams);
setTENormalMap(te, tep->getMaterialParams()->getNormalID());
setChanged(TEXTURE);
if (mDrawable.notNull() && retval)
{

View File

@ -1989,6 +1989,18 @@ S32 LLVOVolume::setTEGlow(const U8 te, const F32 glow)
return res;
}
void LLVOVolume::setTEMaterialParamsCallback(const LLMaterialID &pMaterialID, const LLMaterialPtr pMaterialParams)
{
for (U8 i = 0; i < getNumTEs(); i++)
{
if (getTE(i)->getMaterialID() == pMaterialID)
{
LL_INFOS("Materials") << "Material params callback triggered!" << LL_ENDL;
setTEMaterialParams(i, pMaterialParams);
}
}
}
S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID)
{
if (!pMaterialID.isNull())
@ -1998,8 +2010,8 @@ S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID)
if (res)
{
LL_INFOS("Materials") << "We have a material!" << LL_ENDL;
LLMaterialPtr pMatParam = LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID);
setTEMaterialParams(te, pMatParam);
LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2));
//setTEMaterialParams(te, pMatParam);
gPipeline.markTextured(mDrawable);
mFaceMappingChanged = TRUE;
}
@ -4083,7 +4095,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
U8 index = facep->getTextureIndex();
LLMaterialID matid = facep->getTextureEntry()->getMaterialID();
const LLMaterialID* matid = &facep->getTextureEntry()->getMaterialID();
bool batchable = false;
@ -4118,7 +4130,8 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
draw_vec[idx]->mFullbright == fullbright &&
draw_vec[idx]->mBump == bump &&
draw_vec[idx]->mTextureMatrix == tex_mat &&
draw_vec[idx]->mModelMatrix == model_mat)
draw_vec[idx]->mModelMatrix == model_mat &&
draw_vec[idx]->mMaterialID == matid)
{
draw_vec[idx]->mCount += facep->getIndicesCount();
draw_vec[idx]->mEnd += facep->getGeomCount();
@ -4146,22 +4159,25 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
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)
if (!facep->getTextureEntry()->getMaterialID().isNull())
{
// 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 (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)

View File

@ -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);
void setTEMaterialParamsCallback(const LLMaterialID& pMaterialID, const LLMaterialPtr pMaterialParams);
/*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);