|
|
|
@ -184,6 +184,7 @@ namespace Shader
|
|
|
|
|
, mAdditiveBlending(false)
|
|
|
|
|
, mDiffuseHeight(false)
|
|
|
|
|
, mNormalHeight(false)
|
|
|
|
|
, mReconstructNormalZ(false)
|
|
|
|
|
, mTexStageRequiringTangents(-1)
|
|
|
|
|
, mSoftParticles(false)
|
|
|
|
|
, mNode(nullptr)
|
|
|
|
@ -429,6 +430,7 @@ namespace Shader
|
|
|
|
|
normalMapTex->setFilter(osg::Texture::MAG_FILTER, diffuseMap->getFilter(osg::Texture::MAG_FILTER));
|
|
|
|
|
normalMapTex->setMaxAnisotropy(diffuseMap->getMaxAnisotropy());
|
|
|
|
|
normalMapTex->setName("normalMap");
|
|
|
|
|
normalMap = normalMapTex;
|
|
|
|
|
|
|
|
|
|
int unit = texAttributes.size();
|
|
|
|
|
if (!writableStateSet)
|
|
|
|
@ -440,6 +442,23 @@ namespace Shader
|
|
|
|
|
mRequirements.back().mNormalHeight = normalHeight;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (normalMap != nullptr && normalMap->getImage(0))
|
|
|
|
|
{
|
|
|
|
|
// Special handling for red-green normal maps (e.g. BC5 or R8G8).
|
|
|
|
|
switch (normalMap->getImage(0)->getPixelFormat())
|
|
|
|
|
{
|
|
|
|
|
case GL_RG:
|
|
|
|
|
case GL_RG_INTEGER:
|
|
|
|
|
case GL_COMPRESSED_RED_GREEN_RGTC2_EXT:
|
|
|
|
|
case GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT:
|
|
|
|
|
{
|
|
|
|
|
mRequirements.back().mReconstructNormalZ = true;
|
|
|
|
|
mRequirements.back().mNormalHeight = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mAutoUseSpecularMaps && diffuseMap != nullptr && specularMap == nullptr && diffuseMap->getImage(0))
|
|
|
|
|
{
|
|
|
|
|
std::string specularMapFileName = diffuseMap->getImage(0)->getFileName();
|
|
|
|
@ -629,6 +648,7 @@ namespace Shader
|
|
|
|
|
|
|
|
|
|
defineMap["diffuseParallax"] = reqs.mDiffuseHeight ? "1" : "0";
|
|
|
|
|
defineMap["parallax"] = reqs.mNormalHeight ? "1" : "0";
|
|
|
|
|
defineMap["reconstructNormalZ"] = reqs.mReconstructNormalZ ? "1" : "0";
|
|
|
|
|
|
|
|
|
|
writableStateSet->addUniform(new osg::Uniform("colorMode", reqs.mColorMode));
|
|
|
|
|
addedState->addUniform("colorMode");
|
|
|
|
|