Commit 7d71e19e authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[FIX #200] enabled transparency for isosurfaces and raytraced isosurfaces

parent 71485425
......@@ -208,3 +208,24 @@ WColor wge::getNthHSVColor( int n )
return createColorFromHSV( h, s, v );
}
void wge::enableTransparency( osg::ref_ptr< osg::Node > node )
{
osg::StateSet* state = node->getOrCreateStateSet();
// NOTE: this does not en/disable blending. This is always on.
state->setRenderingHint( osg::StateSet::TRANSPARENT_BIN );
// Enable depth test so that an opaque polygon will occlude a transparent one behind it.
state->setMode( GL_DEPTH_TEST, osg::StateAttribute::ON );
// Conversely, disable writing to depth buffer so that a transparent polygon will allow polygons behind it to shine through.
// OSG renders transparent polygons after opaque ones.
// NOTE: USEFUL?
// osg::Depth* depth = new osg::Depth;
// depth->setWriteMask( false );
// state->setAttributeAndModes( depth, osg::StateAttribute::ON );
// blending. Without this, setting alpha does not cause anything
state->setMode( GL_BLEND, osg::StateAttribute::ON );
}
......@@ -38,10 +38,15 @@
#include "../common/WAssert.h"
#include "../common/math/linearAlgebra/WLinearAlgebra.h"
namespace wge
{
/**
* Enable transparency for the given node. This enabled blending and sets the node to the transparency bin.
*
* \param node the node
*/
void enableTransparency( osg::ref_ptr< osg::Node > node );
/**
* Transforms a direction given via two points into a RGB color.
*
......
......@@ -441,6 +441,9 @@ void WMIsosurface::renderMesh()
state->addUniform( new WGEPropertyUniform< WPropInt >( "u_opacity", m_opacityProp ) );
shader->apply( m_surfaceGeode );
// enable transparency
wge::enableTransparency( m_surfaceGeode );
// Colormapping
WGEColormapping::apply( m_surfaceGeode, shader );
......
......@@ -266,6 +266,11 @@ void WMIsosurfaceRaytracer::moduleMain()
// bind the texture to the node
osg::StateSet* rootState = cube->getOrCreateStateSet();
// enable transparency
wge::enableTransparency( cube );
// bind the data texture
osg::ref_ptr< WGETexture3D > texture3D = dataSet->getTexture();
texture3D->bind( cube );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment