From ec89769e6b345a29912908ee7ee3e992b70b0a8e Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 20 Feb 2012 16:00:46 +0000 Subject: [PATCH] From Luc Frauciel, "When dae plugin is used with daeUseSequencedTextureUnitsoption, the transparency processing is done with the wrong texture unit I've remplaced the unused parameter diffuseColorName by the diffuseTextureUnit effectively used." --- src/osgPlugins/dae/daeRMaterials.cpp | 12 ++++++------ src/osgPlugins/dae/daeReader.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/osgPlugins/dae/daeRMaterials.cpp b/src/osgPlugins/dae/daeRMaterials.cpp index b404645b8..22216e905 100644 --- a/src/osgPlugins/dae/daeRMaterials.cpp +++ b/src/osgPlugins/dae/daeRMaterials.cpp @@ -384,7 +384,7 @@ void daeReader::processProfileCOMMON(osg::StateSet *ss, domProfile_COMMON *pc ) ss->setAttributeAndModes(lightmodel, osg::StateAttribute::ON); } - processTransparencySettings(b->getTransparent(), b->getTransparency(), ss, mat.get(), DiffuseTextureName ); + processTransparencySettings(b->getTransparent(), b->getTransparency(), ss, mat.get(), _pluginOptions.usePredefinedTextureUnits ? MAIN_TEXTURE_UNIT : 0 ); } // // elements: @@ -461,7 +461,7 @@ void daeReader::processProfileCOMMON(osg::StateSet *ss, domProfile_COMMON *pc ) ss->setAttributeAndModes(lightmodel, osg::StateAttribute::ON); } - processTransparencySettings(p->getTransparent(), p->getTransparency(), ss, mat.get(), DiffuseTextureName ); + processTransparencySettings(p->getTransparent(), p->getTransparency(), ss, mat.get(), _pluginOptions.usePredefinedTextureUnits ? MAIN_TEXTURE_UNIT : 0 ); } // // elements: @@ -526,7 +526,7 @@ void daeReader::processProfileCOMMON(osg::StateSet *ss, domProfile_COMMON *pc ) OSG_WARN << "Ambient occlusion map only supported when diffuse texture also specified" << std::endl; } - processTransparencySettings(l->getTransparent(), l->getTransparency(), ss, mat.get(), DiffuseTextureName ); + processTransparencySettings(l->getTransparent(), l->getTransparency(), ss, mat.get(), _pluginOptions.usePredefinedTextureUnits ? MAIN_TEXTURE_UNIT : 0 ); } // // elements: @@ -551,7 +551,7 @@ void daeReader::processProfileCOMMON(osg::StateSet *ss, domProfile_COMMON *pc ) // Use the emission colour as the main colour in transparency calculations mat->setDiffuse(osg::Material::FRONT_AND_BACK, mat->getEmission(osg::Material::FRONT_AND_BACK)); - processTransparencySettings(c->getTransparent(), c->getTransparency(), ss, mat.get(), NULL ); + processTransparencySettings(c->getTransparent(), c->getTransparency(), ss, mat.get(), _pluginOptions.usePredefinedTextureUnits ? MAIN_TEXTURE_UNIT : 0 ); // Kill the lighting mat->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(0.0, 0.0, 0.0, 1.0)); @@ -1181,7 +1181,7 @@ void daeReader::processTransparencySettings( domCommon_transparent_type *ctt, domCommon_float_or_param_type *pTransparency, osg::StateSet *ss, osg::Material *material, - xsNCName diffuseTextureName ) + unsigned int diffuseTextureUnit ) { if (ss == NULL) return; @@ -1259,7 +1259,7 @@ void daeReader::processTransparencySettings( domCommon_transparent_type *ctt, if (!strictTransparency) { const osg::Texture* pMainTexture = dynamic_cast( - ss->getTextureAttribute(MAIN_TEXTURE_UNIT, osg::StateAttribute::TEXTURE)); + ss->getTextureAttribute(diffuseTextureUnit, osg::StateAttribute::TEXTURE)); bool haveTranslucentTexture = pMainTexture && pMainTexture->getImage(0) && pMainTexture->getImage(0)->isImageTranslucent(); strictTransparency = !haveTranslucentTexture; diff --git a/src/osgPlugins/dae/daeReader.h b/src/osgPlugins/dae/daeReader.h index 07d5de0ad..6065daaec 100644 --- a/src/osgPlugins/dae/daeReader.h +++ b/src/osgPlugins/dae/daeReader.h @@ -347,7 +347,7 @@ private: domCommon_float_or_param_type *pTransparency, osg::StateSet*, osg::Material *material, - xsNCName diffuseTextureName ); + unsigned int diffuseTextureUnit ); bool GetFloat4Param(xsNCName Reference, domFloat4 &f4) const; bool GetFloatParam(xsNCName Reference, domFloat &f) const;