Commit 76a737aa authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[ADD] - added option to show complete slices

parent da982ebe
...@@ -57,7 +57,6 @@ void colormap( inout vec4 color, in sampler3D sampler, in vec3 coord, float minV ...@@ -57,7 +57,6 @@ void colormap( inout vec4 color, in sampler3D sampler, in vec3 coord, float minV
// compositing: // compositing:
// associated colors needed // associated colors needed
src.rgb *= src.a; src.rgb *= src.a;
//src.a = 1.0;
// apply front-to-back compositing // apply front-to-back compositing
color = ( 1.0 - color.a ) * src + color; color = ( 1.0 - color.a ) * src + color;
} }
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "../../graphicsEngine/WGEGeodeUtils.h" #include "../../graphicsEngine/WGEGeodeUtils.h"
#include "../../graphicsEngine/callbacks/WGELinearTranslationCallback.h" #include "../../graphicsEngine/callbacks/WGELinearTranslationCallback.h"
#include "../../graphicsEngine/callbacks/WGENodeMaskCallback.h" #include "../../graphicsEngine/callbacks/WGENodeMaskCallback.h"
#include "../../graphicsEngine/callbacks/WGEPropertyUniformCallback.h"
#include "../../graphicsEngine/callbacks/WGEShaderAnimationCallback.h" #include "../../graphicsEngine/callbacks/WGEShaderAnimationCallback.h"
#include "../../graphicsEngine/shaders/WGEPropertyUniform.h" #include "../../graphicsEngine/shaders/WGEPropertyUniform.h"
#include "../../graphicsEngine/shaders/WGEShader.h" #include "../../graphicsEngine/shaders/WGEShader.h"
...@@ -85,6 +86,9 @@ void WMNavigationSlices::connectors() ...@@ -85,6 +86,9 @@ void WMNavigationSlices::connectors()
void WMNavigationSlices::properties() void WMNavigationSlices::properties()
{ {
m_noTransparency = m_properties->addProperty( "No Transparency", "If checked, transparency is not used. This will show the complete slices.",
false );
m_sliceGroup = m_properties->addPropertyGroup( "Slices", "Slice Options." ); m_sliceGroup = m_properties->addPropertyGroup( "Slices", "Slice Options." );
// enable slices // enable slices
...@@ -222,6 +226,11 @@ void WMNavigationSlices::initOSG() ...@@ -222,6 +226,11 @@ void WMNavigationSlices::initOSG()
state->addUniform( animationUniform ); state->addUniform( animationUniform );
animationUniform->setUpdateCallback( new WGEShaderAnimationCallback() ); animationUniform->setUpdateCallback( new WGEShaderAnimationCallback() );
// transparency property
osg::ref_ptr< osg::Uniform > transparencyUniform = new osg::Uniform( "u_noTransparency", false );
state->addUniform( transparencyUniform );
transparencyUniform->setUpdateCallback( new WGEPropertyUniformCallback< WPropBool >( m_noTransparency ) );
// add the transformation nodes to the output group // add the transformation nodes to the output group
m_output->insert( mX ); m_output->insert( mX );
m_output->insert( mY ); m_output->insert( mY );
......
...@@ -196,6 +196,8 @@ private: ...@@ -196,6 +196,8 @@ private:
*/ */
osg::ref_ptr< WGEManagedGroupNode > m_output; osg::ref_ptr< WGEManagedGroupNode > m_output;
WPropBool m_noTransparency; //!< if true, the whole slices are shown.
WPropGroup m_sliceGroup; //!< the group contains several slice properties WPropGroup m_sliceGroup; //!< the group contains several slice properties
WPropDouble m_xPos; //!< x position of the slice WPropDouble m_xPos; //!< x position of the slice
......
...@@ -35,6 +35,9 @@ uniform float u_picked; ...@@ -35,6 +35,9 @@ uniform float u_picked;
// animation time. Used for pick-animation // animation time. Used for pick-animation
uniform int u_timer; uniform int u_timer;
// if true, no transparency should be used.
uniform bool u_noTransparency;
/** /**
* Applies colormapping. * Applies colormapping.
*/ */
...@@ -47,9 +50,18 @@ void main() ...@@ -47,9 +50,18 @@ void main()
// NOTE: the 100.0 depends on the timer tick. We have a timer that counts one per a hundreth of a second. // NOTE: the 100.0 depends on the timer tick. We have a timer that counts one per a hundreth of a second.
float pickColorIntensity = 0.5 * ( 1.0 + sin( 3.0 * 3.1472 * float( u_timer ) / 100.0 ) ); float pickColorIntensity = 0.5 * ( 1.0 + sin( 3.0 * 3.1472 * float( u_timer ) / 100.0 ) );
// as we use this for blending, we want it to swing in [0.5-0.75] // as we use this for blending, we want it to swing in [0.5-0.75]
pickColorIntensity = 0.5 + ( pickColorIntensity * 0.25 ); pickColorIntensity = ( pickColorIntensity * 0.25 ) + 0.5;
// remove transparency?
float removeTransparency = clamp( u_picked + float( u_noTransparency ), 0.0, 1.0 );
cmap.a = ( ( 1.0 - removeTransparency ) * cmap.a ) + removeTransparency;
// mix colormapping and pick color // mix colormapping and pick color
gl_FragColor = mix( pickColor, cmap, ( ( 1.0 - u_picked ) * 1.0 ) + ( u_picked * pickColorIntensity ) ); vec4 finalColor = mix( pickColor, cmap,
( 1.0 - u_picked ) + ( u_picked * pickColorIntensity ) // mix intensity. This is influenced by the pick-state.
);
// set as fragColor and remove transparency if needed.
gl_FragColor = vec4( finalColor.rgba );
} }
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