Added automatic detection of alpha values, switching on blending when alpah!=1.0
This commit is contained in:
@@ -348,6 +348,8 @@ void GeometryTechnique::init()
|
||||
}
|
||||
}
|
||||
|
||||
bool containsTransparency = false;
|
||||
|
||||
if (colorLayer)
|
||||
{
|
||||
osgTerrain::ImageLayer* imageLayer = dynamic_cast<osgTerrain::ImageLayer*>(colorLayer);
|
||||
@@ -362,17 +364,22 @@ void GeometryTechnique::init()
|
||||
stateset->setTextureAttributeAndModes(color_index, texture2D, osg::StateAttribute::ON);
|
||||
|
||||
texture2D->setFilter(osg::Texture::MAG_FILTER, filter==TerrainNode::LINEAR ? osg::Texture::LINEAR : osg::Texture::NEAREST);
|
||||
|
||||
|
||||
if (tf)
|
||||
{
|
||||
// up the precision of hte internal texture format to its maximum.
|
||||
//image->setInternalTextureFormat(GL_LUMINANCE32F_ARB);
|
||||
image->setInternalTextureFormat(GL_LUMINANCE16);
|
||||
}
|
||||
else
|
||||
{
|
||||
containsTransparency = image->isImageTranslucent();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (tf)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Requires TransferFunction"<<std::endl;
|
||||
@@ -385,6 +392,8 @@ void GeometryTechnique::init()
|
||||
texture1D->setFilter(osg::Texture::MAG_FILTER, osg::Texture::NEAREST);
|
||||
stateset->setTextureAttributeAndModes(tf_index, texture1D, osg::StateAttribute::ON);
|
||||
|
||||
containsTransparency = image->isImageTranslucent();
|
||||
|
||||
if (colorLayer)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Using fragment program"<<std::endl;
|
||||
@@ -430,6 +439,13 @@ void GeometryTechnique::init()
|
||||
osg::notify(osg::NOTICE)<<"Using standard OpenGL fixed function pipeline"<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (containsTransparency)
|
||||
{
|
||||
osg::StateSet* stateset = _geode->getOrCreateStateSet();
|
||||
stateset->setMode(GL_BLEND, osg::StateAttribute::ON);
|
||||
stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
|
||||
}
|
||||
|
||||
// if (_terrainGeometry.valid()) _terrainGeometry->setUseDisplayList(false);
|
||||
if (_geometry.valid()) _geometry->setUseVertexBufferObjects(true);
|
||||
|
||||
Reference in New Issue
Block a user