Commit 1e69b383 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] - renamed direct volume rendering module as it is an isosurface raytracer

parent aadb219d
......@@ -39,7 +39,7 @@
#include "../modules/coordinateSystem/WMCoordinateSystem.h"
#include "../modules/dataTypeConversion/WMDataTypeConversion.h"
#include "../modules/deterministicFTMori/WMDeterministicFTMori.h"
#include "../modules/directVolumeRendering/WMDirectVolumeRendering.h"
#include "../modules/isosurfaceRaytracer/WMIsosurfaceRaytracer.h"
#include "../modules/distanceMap/WMDistanceMap.h"
#include "../modules/distanceMap/WMDistanceMapIsosurface.h"
#include "../modules/eegView/WMEEGView.h"
......@@ -102,7 +102,7 @@ void WModuleFactory::load()
m_prototypeAccess->get().insert( boost::shared_ptr< WModule >( new WMData() ) );
m_prototypeAccess->get().insert( boost::shared_ptr< WModule >( new WMDataTypeConversion() ) );
m_prototypeAccess->get().insert( boost::shared_ptr< WModule >( new WMDeterministicFTMori() ) );
m_prototypeAccess->get().insert( boost::shared_ptr< WModule >( new WMDirectVolumeRendering() ) );
m_prototypeAccess->get().insert( boost::shared_ptr< WModule >( new WMIsosurfaceRaytracer() ) );
m_prototypeAccess->get().insert( boost::shared_ptr< WModule >( new WMDistanceMap() ) );
m_prototypeAccess->get().insert( boost::shared_ptr< WModule >( new WMDistanceMapIsosurface() ) );
m_prototypeAccess->get().insert( boost::shared_ptr< WModule >( new WMEEGView() ) );
......
......@@ -39,48 +39,48 @@
#include "../../graphicsEngine/WGEGeodeUtils.h"
#include "../../graphicsEngine/WShader.h"
#include "WMDirectVolumeRendering.h"
#include "directvolumerendering.xpm"
#include "WMIsosurfaceRaytracer.h"
#include "isosurfaceraytracer.xpm"
WMDirectVolumeRendering::WMDirectVolumeRendering():
WMIsosurfaceRaytracer::WMIsosurfaceRaytracer():
WModule(),
m_rootNode( new osg::Node() )
{
// Initialize members
}
WMDirectVolumeRendering::~WMDirectVolumeRendering()
WMIsosurfaceRaytracer::~WMIsosurfaceRaytracer()
{
// Cleanup!
}
boost::shared_ptr< WModule > WMDirectVolumeRendering::factory() const
boost::shared_ptr< WModule > WMIsosurfaceRaytracer::factory() const
{
return boost::shared_ptr< WModule >( new WMDirectVolumeRendering() );
return boost::shared_ptr< WModule >( new WMIsosurfaceRaytracer() );
}
const char** WMDirectVolumeRendering::getXPMIcon() const
const char** WMIsosurfaceRaytracer::getXPMIcon() const
{
return directvolumerendering_xpm;
return isosurfaceraytracer_xpm;
}
const std::string WMDirectVolumeRendering::getName() const
const std::string WMIsosurfaceRaytracer::getName() const
{
// Specify your module name here. This name must be UNIQUE!
return "Direct Volume Rendering";
return "Isosurface Raytracer";
}
const std::string WMDirectVolumeRendering::getDescription() const
const std::string WMIsosurfaceRaytracer::getDescription() const
{
// Specify your module description here. Be detailed. This text is read by the user.
return "This module shows a direct volume rendering of the specified scalar dataset.";
return "This module shows a fast raytraced isosurface of the specified scalar dataset.";
}
void WMDirectVolumeRendering::connectors()
void WMIsosurfaceRaytracer::connectors()
{
// DVR needs one input: the scalar dataset
m_input = boost::shared_ptr< WModuleInputData < WDataSetScalar > >(
new WModuleInputData< WDataSetScalar >( shared_from_this(), "in", "The scalar dataset shown using DVR." )
new WModuleInputData< WDataSetScalar >( shared_from_this(), "in", "The scalar dataset shown using isosurface." )
);
// As properties, every connector needs to be added to the list of connectors.
......@@ -90,13 +90,11 @@ void WMDirectVolumeRendering::connectors()
WModule::connectors();
}
void WMDirectVolumeRendering::properties()
void WMIsosurfaceRaytracer::properties()
{
// Initialize the properties
m_propCondition = boost::shared_ptr< WCondition >( new WCondition() );
m_isoSurface = m_properties->addProperty( "Isosurface Mode", "If enabled, the Volume Renderer will render an isosurface and ignores the "
"transfer function.", true );
m_isoValue = m_properties->addProperty( "Isovalue", "The isovalue used whenever the isosurface Mode is turned on.",
50 );
m_isoColor = m_properties->addProperty( "Iso Color", "The color to blend the isosurface with.", WColor( 1.0, 1.0, 1.0, 1.0 ),
......@@ -112,9 +110,9 @@ void WMDirectVolumeRendering::properties()
m_useSimpleDepthColoring = m_properties->addProperty( "Use Depth Cueing", "Enable it to have simple depth dependent coloring only.", false );
}
void WMDirectVolumeRendering::moduleMain()
void WMIsosurfaceRaytracer::moduleMain()
{
m_shader = osg::ref_ptr< WShader > ( new WShader( "DVRRaycast" ) );
m_shader = osg::ref_ptr< WShader > ( new WShader( "IsosurfaceRaytracer" ) );
// let the main loop awake if the data changes or the properties changed.
m_moduleState.setResetable( true, true );
......@@ -200,9 +198,6 @@ void WMDirectVolumeRendering::moduleMain()
osg::ref_ptr< osg::Uniform > isovalue = new osg::Uniform( "u_isovalue", static_cast< float >( m_isoValue->get() / 100.0 ) );
isovalue->setUpdateCallback( new SafeUniformCallback( this ) );
osg::ref_ptr< osg::Uniform > isosurface = new osg::Uniform( "u_isosurface", m_isoSurface->get() );
isosurface->setUpdateCallback( new SafeUniformCallback( this ) );
osg::ref_ptr< osg::Uniform > steps = new osg::Uniform( "u_steps", m_stepCount->get() );
steps->setUpdateCallback( new SafeUniformCallback( this ) );
......@@ -213,7 +208,6 @@ void WMDirectVolumeRendering::moduleMain()
depthCueingOnly->setUpdateCallback( new SafeUniformCallback( this ) );
rootState->addUniform( isovalue );
rootState->addUniform( isosurface );
rootState->addUniform( steps );
rootState->addUniform( alpha );
rootState->addUniform( depthCueingOnly );
......@@ -232,23 +226,19 @@ void WMDirectVolumeRendering::moduleMain()
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->remove( m_rootNode );
}
void WMDirectVolumeRendering::SafeUpdateCallback::operator()( osg::Node* node, osg::NodeVisitor* nv )
void WMIsosurfaceRaytracer::SafeUpdateCallback::operator()( osg::Node* node, osg::NodeVisitor* nv )
{
// currently, there is nothing to update
traverse( node, nv );
}
void WMDirectVolumeRendering::SafeUniformCallback::operator()( osg::Uniform* uniform, osg::NodeVisitor* /* nv */ )
void WMIsosurfaceRaytracer::SafeUniformCallback::operator()( osg::Uniform* uniform, osg::NodeVisitor* /* nv */ )
{
// update some uniforms:
if ( m_module->m_isoValue->changed() && ( uniform->getName() == "u_isovalue" ) )
{
uniform->set( static_cast< float >( m_module->m_isoValue->get( true ) / 100.0 ) );
}
if ( m_module->m_isoSurface->changed() && ( uniform->getName() == "u_isosurface" ) )
{
uniform->set( m_module->m_isoSurface->get( true ) );
}
if ( m_module->m_stepCount->changed() && ( uniform->getName() == "u_steps" ) )
{
uniform->set( m_module->m_stepCount->get( true ) );
......@@ -263,7 +253,7 @@ void WMDirectVolumeRendering::SafeUniformCallback::operator()( osg::Uniform* uni
}
}
void WMDirectVolumeRendering::activate()
void WMIsosurfaceRaytracer::activate()
{
// Activate/Deactivate the DVR
if ( m_rootNode )
......
......@@ -22,8 +22,8 @@
//
//---------------------------------------------------------------------------
#ifndef WMDIRECTVOLUMERENDERING_H
#define WMDIRECTVOLUMERENDERING_H
#ifndef WMISOSURFACERAYTRACER_H
#define WMISOSURFACERAYTRACER_H
#include <string>
......@@ -37,23 +37,23 @@
#include "../../kernel/WModuleOutputData.h"
/**
* This module build the base for DirectVolumeRendering in OpenWalnut. It uses shader based raytracing and will be able to have multi dimensional
* transfer functions.
* This module builds the base for fast raytracing of isosurfacesin OpenWalnut. It uses shader based raytracing.
*
* \ingroup modules
*/
class WMDirectVolumeRendering: public WModule
class WMIsosurfaceRaytracer: public WModule
{
public:
/**
* Default constructor.
*/
WMDirectVolumeRendering();
WMIsosurfaceRaytracer();
/**
* Destructor.
*/
virtual ~WMDirectVolumeRendering();
virtual ~WMIsosurfaceRaytracer();
/**
* Gives back the name of this module.
......@@ -119,11 +119,6 @@ private:
*/
boost::shared_ptr< WDataSetScalar > m_dataSet;
/**
* If this property is true, as special shader is used which emulates isosurfaces using the m_isoValue property.
*/
WPropBool m_isoSurface;
/**
* The Isovalue used in the case m_isoSurface is true.
*/
......@@ -172,7 +167,7 @@ private:
*
* \param module just set the creating module as pointer for later reference.
*/
explicit SafeUpdateCallback( WMDirectVolumeRendering* module ): m_module( module ), m_initialUpdate( true )
explicit SafeUpdateCallback( WMIsosurfaceRaytracer* module ): m_module( module ), m_initialUpdate( true )
{
};
......@@ -187,7 +182,7 @@ private:
/**
* Pointer used to access members of the module to modify the node.
*/
WMDirectVolumeRendering* m_module;
WMIsosurfaceRaytracer* m_module;
/**
* Denotes whether the update callback is called the first time.
......@@ -207,7 +202,7 @@ private:
*
* \param module just set the creating module as pointer for later reference.
*/
explicit SafeUniformCallback( WMDirectVolumeRendering* module ): m_module( module )
explicit SafeUniformCallback( WMIsosurfaceRaytracer* module ): m_module( module )
{
};
......@@ -222,9 +217,9 @@ private:
/**
* Pointer used to access members of the module to modify the node.
*/
WMDirectVolumeRendering* m_module;
WMIsosurfaceRaytracer* m_module;
};
};
#endif // WMDIRECTVOLUMERENDERING_H
#endif // WMISOSURFACERAYTRACER_H
/* XPM */
static const char * directvolumerendering_xpm[] = {
static const char * isosurfaceraytracer_xpm[] = {
"32 32 224 2",
" c None",
". c #0000FF",
......
......@@ -28,7 +28,7 @@
// Varyings
/////////////////////////////////////////////////////////////////////////////
#include "DVRRaycast.varyings"
#include "IsosurfaceRaytracer.varyings"
/////////////////////////////////////////////////////////////////////////////
// Uniforms
......@@ -40,9 +40,6 @@ uniform sampler3D tex0;
// The isovalue to use.
uniform float u_isovalue;
// Should the shader create some kind of isosurface instead of a volume rendering?
uniform bool u_isosurface;
// True if only the simple depth value should be used for coloring
uniform bool u_depthCueingOnly;
......@@ -106,86 +103,82 @@ void main()
float totalDistance = 0.0;
vec3 rayEnd = findRayEnd( totalDistance );
// Isosurface Mode
if ( u_isosurface )
{
// the point along the ray in cube coordinates
vec3 curPoint = v_rayStart;
// the point along the ray in cube coordinates
vec3 curPoint = v_rayStart;
// the current value inside the data
float value;
// the current value inside the data
float value;
// the step counter
int i = 0;
float stepDistance = totalDistance / float( u_steps );
while ( i < u_steps ) // we do not need to ch
{
// get current value
value = texture3D( tex0, curPoint ).r;
// the step counter
int i = 0;
float stepDistance = totalDistance / float( u_steps );
while ( i < u_steps ) // we do not need to ch
{
// get current value
value = texture3D( tex0, curPoint ).r;
// is it the isovalue?
if ( abs( value - u_isovalue ) < 0.1 )
// is it the isovalue?
if ( abs( value - u_isovalue ) < 0.1 )
{
// we need to know the depth value of the current point inside the cube
// Therefore, the complete standard pipeline is reproduced here:
// 1: transfer to world space and right after it, to eye space
vec4 curPointProjected = gl_ModelViewProjectionMatrix * vec4( curPoint, 1.0 );
// 2: scale to screen space and [0,1]
// -> x and y is not needed
// curPointProjected.x /= curPointProjected.w;
// curPointProjected.x = curPointProjected.x * 0.5 + 0.5 ;
// curPointProjected.y /= curPointProjected.w;
// curPointProjected.y = curPointProjected.y * 0.5 + 0.5 ;
curPointProjected.z /= curPointProjected.w;
curPointProjected.z = curPointProjected.z * 0.5 + 0.5 ;
// 3: set depth value
gl_FragDepth = curPointProjected.z;
// 4: set color
vec4 color;
if ( u_depthCueingOnly )
{
// we need to know the depth value of the current point inside the cube
// Therefore, the complete standard pipeline is reproduced here:
// 1: transfer to world space and right after it, to eye space
vec4 curPointProjected = gl_ModelViewProjectionMatrix * vec4( curPoint, 1.0 );
// 2: scale to screen space and [0,1]
// -> x and y is not needed
// curPointProjected.x /= curPointProjected.w;
// curPointProjected.x = curPointProjected.x * 0.5 + 0.5 ;
// curPointProjected.y /= curPointProjected.w;
// curPointProjected.y = curPointProjected.y * 0.5 + 0.5 ;
curPointProjected.z /= curPointProjected.w;
curPointProjected.z = curPointProjected.z * 0.5 + 0.5 ;
// 3: set depth value
gl_FragDepth = curPointProjected.z;
// 4: set color
vec4 color;
if ( u_depthCueingOnly )
{
float d = 1.0 - curPointProjected.z;
color = gl_Color * 1.5 * d * d;
}
else
{
// NOTE: these are a lot of weird experiments ;-)
float d = 1.0 - curPointProjected.z;
d = 1.5*pointDistance( curPoint, vec3( 0.5 ) );
float w = dot( normalize( vec3( 0.5 ) - curPoint ), normalize( v_ray ) );
w = ( w + 0.5 );
if ( w > 0.8 ) w = 0.8;
float d2 = w*d*d*d*d*d;
color = gl_Color * 11.0 * d2;
}
color.a = u_alpha;
gl_FragColor = color;
break;
float d = 1.0 - curPointProjected.z;
color = gl_Color * 1.5 * d * d;
}
else
{
// no it is not the iso value
// -> continue along the ray
curPoint += stepDistance * v_ray;
// NOTE: these are a lot of weird experiments ;-)
float d = 1.0 - curPointProjected.z;
d = 1.5*pointDistance( curPoint, vec3( 0.5 ) );
float w = dot( normalize( vec3( 0.5 ) - curPoint ), normalize( v_ray ) );
w = ( w + 0.5 );
if ( w > 0.8 ) w = 0.8;
float d2 = w*d*d*d*d*d;
color = gl_Color * 11.0 * d2;
}
// do not miss to count the steps already done
i++;
}
color.a = u_alpha;
gl_FragColor = color;
// the ray did never hit the surface --> discard the pixel
if ( i == u_steps )
break;
}
else
{
discard;
// no it is not the iso value
// -> continue along the ray
curPoint += stepDistance * v_ray;
}
// do not miss to count the steps already done
i++;
}
// the ray did never hit the surface --> discard the pixel
if ( i == u_steps )
{
discard;
}
}
......@@ -28,7 +28,7 @@
// Varyings
/////////////////////////////////////////////////////////////////////////////
#include "DVRRaycast.varyings"
#include "IsosurfaceRaytracer.varyings"
/////////////////////////////////////////////////////////////////////////////
// Uniforms
......
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