Commit 11c7036b authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[ADD] - added colormapping to fiberDisplaySimple

parent 6d7d6a31
......@@ -32,6 +32,7 @@
#include "../../dataHandler/WDataTexture3D.h"
#include "../../graphicsEngine/callbacks/WGEFunctorCallback.h"
#include "../../graphicsEngine/callbacks/WGENodeMaskCallback.h"
#include "../../graphicsEngine/WGEColormapping.h"
#include "../../graphicsEngine/shaders/WGEShader.h"
#include "../../graphicsEngine/shaders/WGEShaderDefineOptions.h"
#include "../../graphicsEngine/shaders/WGEShaderPropertyDefineOptions.h"
......@@ -93,6 +94,10 @@ void WMFiberDisplaySimple::properties()
m_illuminationEnable = m_properties->addProperty( "Illumination", "Enable line illumination.", true );
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 );
m_clipPlaneGroup = m_properties->addPropertyGroup( "Clipping", "Clip the fiber data basing on an arbitrary plane." );
m_clipPlaneEnabled = m_clipPlaneGroup->addProperty( "Enabled", "If set, clipping of fibers is done using an arbitrary plane and plane distance.",
false );
......@@ -100,7 +105,9 @@ void WMFiberDisplaySimple::properties()
m_clipPlanePoint = m_clipPlaneGroup->addProperty( "Plane point", "An point on the plane.", WPosition( 0.0, 0.0, 0.0 ) );
m_clipPlaneVector = m_clipPlaneGroup->addProperty( "Plane normal", "The normal of the plane.", WPosition( 1.0, 0.0, 0.0 ) );
m_clipPlaneDistance= m_clipPlaneGroup->addProperty( "Clip distance", "The distance from the plane where fibers get clipped.", 10.0 );
m_clipPlaneDistance->removeConstraint( m_clipPlaneDistance->getMax() ); // there simply is no max.
//m_clipPlaneDistance->removeConstraint( m_clipPlaneDistance->getMax() ); // there simply is no max.
m_clipPlaneDistance->setMin( 0.0 );
m_clipPlaneDistance->setMax( 1000.0 );
m_tubeGroup = m_properties->addPropertyGroup( "Tube Rendering", "If true, advanced fake-tube rendering is used." );
m_tubeEnable = m_tubeGroup->addProperty( "Enable Tubes", "If set, fake-tube rendering is used.", false, m_propCondition );
......@@ -169,6 +176,7 @@ void WMFiberDisplaySimple::moduleMain()
new WGEShaderPropertyDefineOptions< WPropBool >( m_tubeRibbon, "RIBBON_DISABLED", "RIBBON_ENABLED" ) )
);
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 );
// get notified about data changes
m_moduleState.setResetable( true, true );
......@@ -187,6 +195,7 @@ void WMFiberDisplaySimple::moduleMain()
rootState->addUniform( clipPlaneVectorUniform );
rootState->addUniform( clipPlaneDistanceUniform );
rootState->addUniform( tubeSizeUniform );
rootState->addUniform( colormapRationUniform );
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->insert( rootNode );
// needed to observe the properties of the input connector data
......@@ -257,6 +266,9 @@ void WMFiberDisplaySimple::moduleMain()
// Apply the shader. This is for clipping.
m_shader->apply( geode );
// apply colormapping
WGEColormapping::apply( geode, m_shader );
// Add geometry
// Add geometry
if ( m_clipPlaneShowPlane->get() )
......@@ -357,15 +369,9 @@ osg::ref_ptr< osg::Node > WMFiberDisplaySimple::createFiberGeode( boost::shared_
WDataSetFibers::ColorScheme::ColorMode fibColorMode = fibers->getColorScheme()->getMode();
debugLog() << "Color mode is " << fibColorMode << ".";
WDataSetFibers::ColorArray fibColors = fibers->getColorScheme()->getColor();
// enable blending, select transparent bin if RGBA mode is used
if ( fibColorMode == WDataSetFibers::ColorScheme::RGBA )
{
enableTransparency( state );
}
else
{
state->setMode( GL_BLEND, osg::StateAttribute::OFF );
}
// enable blending, select transparent bin
enableTransparency( state );
// progress indication
boost::shared_ptr< WProgress > progress1 = boost::shared_ptr< WProgress >( new WProgress( "Adding fibers to geode", fibStart->size() ) );
......
......@@ -123,6 +123,11 @@ private:
*/
WPropBool m_illuminationEnable;
/**
* The ratio between colormap and fiber color.
*/
WPropDouble m_colormapRatio;
/**
* A property group for all the clipping related props.
*/
......
......@@ -24,6 +24,8 @@
#version 120
#include "WGEColormapping-fragment.glsl"
#include "WGEShadingTools.glsl"
#include "WGETextureTools.glsl"
#include "WGEPostprocessing.glsl"
......@@ -39,6 +41,11 @@
*/
uniform float u_distance = 1.0;
/**
* Ratio between colormap and fiber color.
*/
uniform float u_colormapRatio = 1.0;
/////////////////////////////////////////////////////////////////////////////
// Attributes
/////////////////////////////////////////////////////////////////////////////
......@@ -105,13 +112,16 @@ void main()
// Calculate light finally
#ifdef ILLUMINATION_ENABLED
float light = blinnPhongIlluminationIntensity( wge_DefaultLightIntensityLessDiffuse, normal );
float light = blinnPhongIlluminationIntensity( wge_DefaultLightIntensity, normal );
#else
float light = 1.0;
#endif
// apply colormapping to the input color
vec4 finalColor = mix( gl_Color, colormapping(), u_colormapRatio );
// finally set the color and depth
wge_FragColor = vec4( vec3( gl_Color.xyz * light * colorScaler ), gl_Color.a );
wge_FragColor = vec4( vec3( light * finalColor.xyz * colorScaler ), finalColor.a );
wge_FragNormal = textureNormalize( normal );
gl_FragDepth = depth;
}
......
......@@ -24,6 +24,8 @@
#version 120
#include "WGEColormapping-vertex.glsl"
#include "WMFiberDisplaySimple-varyings.glsl"
/////////////////////////////////////////////////////////////////////////////
......@@ -118,6 +120,11 @@ void main()
v_normal *= sign( dot( v_normal, vec3( 0.0, 0.0, 1.0 ) ) );
#endif // ( defined ILLUMINATION_ENABLED || defined TUBE_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 );
// Simply project the vertex afterwards
gl_Position = gl_ProjectionMatrix * v_vertex;
gl_FrontColor = gl_Color;
......
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