From 0fe80844993b90ac6f25d0ba610a65f9984f8358 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 8 Jun 2009 09:47:27 +0000 Subject: [PATCH] From Johan Nouvel, fix to handling of transparent textured objects. Tweak from Robert Osfield, commented out disabling of depth write as this is not appropriate by default. --- src/osgPlugins/vrml/ReaderWriterVRML2.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/osgPlugins/vrml/ReaderWriterVRML2.cpp b/src/osgPlugins/vrml/ReaderWriterVRML2.cpp index a839fe46e..8bc82b2e6 100644 --- a/src/osgPlugins/vrml/ReaderWriterVRML2.cpp +++ b/src/osgPlugins/vrml/ReaderWriterVRML2.cpp @@ -385,8 +385,9 @@ osg::ref_ptr ReaderWriterVRML2::convertFromVRML(openvrml::node *obj) { osg_mat->setTransparency(osg::Material::FRONT_AND_BACK, vrml_material->transparency()); osg_stateset->setMode(GL_BLEND, osg::StateAttribute::ON); - osg_stateset->setAttribute(new osg::Depth(osg::Depth::LESS, 0.0, 1.0, false)); // GvdB: transparent objects do not write depth osg_stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); + // commenting out osg:::Depth entry as it's not usual for transparent objects to disable depth. + // osg_stateset->setAttribute(new osg::Depth(osg::Depth::LESS, 0.0, 1.0, false)); // GvdB: transparent objects do not write depth } else { @@ -438,7 +439,7 @@ osg::ref_ptr ReaderWriterVRML2::convertFromVRML(openvrml::node *obj) const openvrml::sfbool *sfb = dynamic_cast(wrap_fv.get()); if (!sfb->value()) - texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP); + texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP); } catch (...) { @@ -447,6 +448,15 @@ osg::ref_ptr ReaderWriterVRML2::convertFromVRML(openvrml::node *obj) osg_stateset->setTextureAttributeAndModes(0, texture.get()); //osg_stateset->setMode(GL_BLEND,osg::StateAttribute::ON); //bhbn + if(image->isImageTranslucent()) + { + osg_stateset->setMode(GL_BLEND, osg::StateAttribute::ON); + osg_stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); + // commenting out osg:::Depth entry as it's not usual for transparent objects to disable depth. + osg_stateset->setAttribute(new osg::Depth(osg::Depth::LESS, 0.0, 1.0, false)); // GvdB: transparent objects do not write depth + } + + } else