Commit 2a1e51ca authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] - speedup in fiberdisplaySimple. Colormapping for such an amount of...

[CHANGE] - speedup in fiberdisplaySimple. Colormapping for such an amount of lines simply is slow. Made it optional
parent 6f44f318
......@@ -93,6 +93,8 @@ void WMFiberDisplaySimple::properties()
m_illuminationEnable = m_properties->addProperty( "Illumination", "Enable line illumination.", true );
m_colormapEnabled = m_properties->addProperty( "Enable Colormapping", "Check this to enable colormapping. On large data, this can cause "
"massive FPS drop.", false );
m_colormapRatio = m_properties->addProperty( "Colormap Ratio", "Defines the ratio between colormap and fiber color.", 0.0 );
m_colormapRatio->setMin( 0.0 );
m_colormapRatio->setMax( 1.0 );
......@@ -194,6 +196,9 @@ void WMFiberDisplaySimple::moduleMain()
osg::ref_ptr< WGEPropertyUniform< WPropDouble > > tubeSizeUniform = new WGEPropertyUniform< WPropDouble >( "u_tubeSize", m_tubeSize );
osg::ref_ptr< WGEPropertyUniform< WPropDouble > > colormapRationUniform =
new WGEPropertyUniform< WPropDouble >( "u_colormapRatio", m_colormapRatio );
m_shader->addPreprocessor( WGEShaderPreprocessor::SPtr(
new WGEShaderPropertyDefineOptions< WPropBool >( m_colormapEnabled, "COLORMAPPING_DISABLED", "COLORMAPPING_ENABLED" ) )
);
// get notified about data changes
m_moduleState.setResetable( true, true );
......@@ -472,6 +477,9 @@ osg::ref_ptr< osg::Node > WMFiberDisplaySimple::createFiberGeode( boost::shared_
{
geometry->setTexCoordArray( 0, texcoords );
}
// enable VBO
geometry->setUseDisplayList( false );
geometry->setUseVertexBufferObjects( true );
// set drawable
geode->addDrawable( geometry );
......
......@@ -128,6 +128,11 @@ private:
*/
WPropDouble m_colormapRatio;
/**
* True if colormapping should be used.
*/
WPropBool m_colormapEnabled;
/**
* A property group for all the clipping related props.
*/
......
......@@ -118,7 +118,10 @@ void main()
#endif
// apply colormapping to the input color
vec4 finalColor = mix( gl_Color, colormapping(), u_colormapRatio );
vec4 finalColor = gl_Color;
#ifdef COLORMAPPING_ENABLED
finalColor = mix( finalColor, colormapping(), u_colormapRatio );
#endif
// finally set the color and depth
wge_FragColor = vec4( vec3( light * finalColor.xyz * colorScaler ), finalColor.a );
......
......@@ -120,10 +120,12 @@ void main()
v_normal *= sign( dot( v_normal, vec3( 0.0, 0.0, 1.0 ) ) );
#endif // ( defined ILLUMINATION_ENABLED || defined TUBE_ENABLED )
#ifdef COLORMAPPING_ENABLED
// Allow the colormapper to do some precalculations with the real vertex coordinate in ow-scene-space
// NOTE: v_vertex is in world-space. We need to get it back to scene space. Directly using gl_Vertex would be possible too but this would
// ignore the actual width of the tube.
colormapping( gl_ModelViewMatrixInverse * v_vertex );
#endif
// Simply project the vertex afterwards
gl_Position = gl_ProjectionMatrix * v_vertex;
......
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