Commit ed1e7d50 authored by Mathias Goldau's avatar Mathias Goldau
Browse files

[ADD] Fiber Stipple module, now also uses grid offsets in order to calculate...

[ADD] Fiber Stipple module, now also uses grid offsets in order to calculate texture coordinates properly.
parent 8d63dadf
......@@ -227,13 +227,22 @@ void WMFiberStipples::initOSG( boost::shared_ptr< WDataSetScalar > probTract )
}
// create a new geode containing the slices
osg::ref_ptr< osg::Node > slice = genScatteredDegeneratedQuads( 1000, minV, osg::Vec3( sizes[0], 0.0, 0.0 ),
osg::ref_ptr< osg::Node > slice = genScatteredDegeneratedQuads( 100000, minV, osg::Vec3( sizes[0], 0.0, 0.0 ),
osg::Vec3( 0.0, 0.0, sizes[2] ) );
slice->setName( "Coronal Slice" );
osg::ref_ptr< osg::Uniform > u_aVec = new osg::Uniform( "u_aVec", osg::Vec3( sizes[0], 0.0, 0.0 ) );
osg::ref_ptr< osg::Uniform > u_bVec = new osg::Uniform( "u_bVec", osg::Vec3( 0.0, 0.0, sizes[2] ) );
osg::ref_ptr< osg::Uniform > u_WorldTransform = new osg::Uniform( "u_WorldTransform", osg::Matrix::identity() );
boost::shared_ptr< const WGridRegular3D > grid = boost::shared_dynamic_cast< const WGridRegular3D >( probTract->getGrid() );
if( !grid )
{
errorLog() << "This module can only process probabilistic Tracts with regular 3D grids, Hence you may see garbage from now on.";
}
boost::array< double, 3 > offsets = getOffsets( grid );
osg::ref_ptr< osg::Uniform > u_pixelSizeX = new osg::Uniform( "u_pixelSizeX", static_cast< float >( offsets[0] ) );
osg::ref_ptr< osg::Uniform > u_pixelSizeY = new osg::Uniform( "u_pixelSizeY", static_cast< float >( offsets[1] ) );
osg::ref_ptr< osg::Uniform > u_pixelSizeZ = new osg::Uniform( "u_pixelSizeZ", static_cast< float >( offsets[2] ) );
osg::ref_ptr< osg::Uniform > u_color = new WGEPropertyUniform< WPropColor >( "u_color", m_color );
osg::ref_ptr< osg::Uniform > u_threshold = new WGEPropertyUniform< WPropDouble >( "u_threshold", m_threshold );
osg::ref_ptr< osg::Uniform > u_maxConnectivityScore = new osg::Uniform( "u_maxConnectivityScore", static_cast< float >( probTract->getMax() ) );
......@@ -242,6 +251,9 @@ void WMFiberStipples::initOSG( boost::shared_ptr< WDataSetScalar > probTract )
states->addUniform( u_aVec );
states->addUniform( u_bVec );
states->addUniform( u_WorldTransform );
states->addUniform( u_pixelSizeX );
states->addUniform( u_pixelSizeY );
states->addUniform( u_pixelSizeZ );
states->addUniform( u_color );
states->addUniform( u_threshold );
states->addUniform( u_maxConnectivityScore );
......
......@@ -48,10 +48,37 @@ uniform sampler3D u_vectorsSampler;
*/
uniform sampler3D u_probTractSampler;
/**
* Number of voxels in X direction.
*/
uniform int u_probTractSizeX;
/**
* Number of voxels in Y direction.
*/
uniform int u_probTractSizeY;
/**
* Number of voxels in Z direction.
*/
uniform int u_probTractSizeZ;
// For correct transformation into texture space we also need the size of each voxel.
/**
* Voxel size in X direction.
*/
uniform float u_pixelSizeX;
/**
* Voxel size in Y direction.
*/
uniform float u_pixelSizeY;
/**
* Voxel size in Z direction.
*/
uniform float u_pixelSizeZ;
// vectors spanning the plane of the quad
uniform vec3 u_aVec;
uniform vec3 u_bVec;
......@@ -114,9 +141,9 @@ void main()
// compute texture coordinates from worldspace coordinates for texture access
vec3 texturePosition = ( u_WorldTransform * gl_Vertex ).xyz;
texturePosition.x /= u_probTractSizeX;
texturePosition.y /= u_probTractSizeY;
texturePosition.z /= u_probTractSizeZ;
texturePosition.x /= u_pixelSizeX * u_probTractSizeX;
texturePosition.y /= u_pixelSizeY * u_probTractSizeY;
texturePosition.z /= u_pixelSizeZ * u_probTractSizeZ;
// get connectivity score from probTract and with maximum value scale it between 0.0..1.0. from now on we call it probability
probability = texture3D( u_probTractSampler, texturePosition ).r / float( u_maxConnectivityScore );
......
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