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

[CHANGE] - ported surface animator to new texturing mechanism

parent 94e7ca9a
......@@ -34,7 +34,7 @@
#include <osg/Projection>
#include "../../kernel/WKernel.h"
#include "../../dataHandler/WDataTexture3D.h"
#include "../../dataHandler/WDataTexture3D_2.h"
#include "../../common/WColor.h"
#include "../../common/WBoundingBox.h"
#include "../../graphicsEngine/WGEUtils.h"
......@@ -144,14 +144,12 @@ osg::ref_ptr< osg::Node > WMSurfaceParameterAnimator::renderSurface( const WBoun
m_shader->apply( cube );
// bind the texture to the node
osg::ref_ptr< osg::Texture3D > texture3D = m_dataSet->getTexture()->getTexture();
osg::ref_ptr< osg::Texture3D > tracesTexture3D = m_tracesDataSet->getTexture()->getTexture();
osg::StateSet* rootState = cube->getOrCreateStateSet();
rootState->setTextureAttributeAndModes( 0, texture3D, osg::StateAttribute::ON );
rootState->setTextureAttributeAndModes( 1, tracesTexture3D, osg::StateAttribute::ON );
//tracesTexture3D->setFilter( osg::Texture::MIN_FILTER, osg::Texture::NEAREST );
//tracesTexture3D->setFilter( osg::Texture::MAG_FILTER, osg::Texture::NEAREST );
osg::ref_ptr< WGETexture3D > texture3D = m_dataSet->getTexture2();
osg::ref_ptr< WGETexture3D > tracesTexture3D = m_tracesDataSet->getTexture2();
texture3D->bind( cube, 0 );
tracesTexture3D->bind( cube, 1 );
// enable transparency
rootState->setMode( GL_BLEND, osg::StateAttribute::ON );
......@@ -160,15 +158,6 @@ osg::ref_ptr< osg::Node > WMSurfaceParameterAnimator::renderSurface( const WBoun
// setup all those uniforms
////////////////////////////////////////////////////////////////////////////////////////////////////
// for the texture, also bind the appropriate uniforms
rootState->addUniform( new osg::Uniform( "tex0", 0 ) );
rootState->addUniform( new osg::Uniform( "tex1", 1 ) );
// we need to specify the texture scaling parameters to the shader
rootState->addUniform( new osg::Uniform( "u_tex1Scale", m_tracesDataSet->getTexture()->getMinMaxScale() ) );
rootState->addUniform( new osg::Uniform( "u_tex1Min", m_tracesDataSet->getTexture()->getMinValue() ) );
rootState->addUniform( new osg::Uniform( "u_tex1Max", m_tracesDataSet->getTexture()->getMaxValue() ) );
osg::ref_ptr< osg::Uniform > isovalue = new osg::Uniform( "u_isovalue", static_cast< float >( m_isoValue->get() / 100.0 ) );
isovalue->setUpdateCallback( new SafeUniformCallback( this ) );
......
......@@ -43,19 +43,16 @@
// **************************************************************************
// texture containing the data
uniform sampler3D tex0;
uniform sampler3D u_texture0Sampler;
// texture containing the tracing data
uniform sampler3D tex1;
uniform sampler3D u_texture1Sampler;
// texture containing the tracing data -> the scaling factor of the values in the texture
uniform float u_tex1Scale;
uniform float u_texture1Scale;
// texture containing the tracing data -> the min value of the values in the texture
uniform float u_tex1Min;
// texture containing the tracing data -> the max value of the values in the texture
uniform float u_tex1Max;
uniform float u_texture1Min;
// **************************************************************************
// Uniforms for the isosurface mode
......@@ -230,7 +227,7 @@ void main()
while ( i < u_steps ) // we do not need to ch
{
// get current value
value = texture3D( tex0, curPoint ).r;
value = texture3D( u_texture0Sampler, curPoint ).r;
// is it the isovalue?
if ( abs( value - u_isovalue ) < 0.1 )
......@@ -246,12 +243,12 @@ void main()
// 3: find a proper normal for a headlight
float s = 0.005;
float valueXP = texture3D( tex0, curPoint + vec3( s, 0.0, 0.0 ) ).r;
float valueXM = texture3D( tex0, curPoint - vec3( s, 0.0, 0.0 ) ).r;
float valueYP = texture3D( tex0, curPoint + vec3( 0.0, s, 0.0 ) ).r;
float valueYM = texture3D( tex0, curPoint - vec3( 0.0, s, 0.0 ) ).r;
float valueZP = texture3D( tex0, curPoint + vec3( 0.0, 0.0, s ) ).r;
float valueZM = texture3D( tex0, curPoint - vec3( 0.0, 0.0, s ) ).r;
float valueXP = texture3D( u_texture0Sampler, curPoint + vec3( s, 0.0, 0.0 ) ).r;
float valueXM = texture3D( u_texture0Sampler, curPoint - vec3( s, 0.0, 0.0 ) ).r;
float valueYP = texture3D( u_texture0Sampler, curPoint + vec3( 0.0, s, 0.0 ) ).r;
float valueYM = texture3D( u_texture0Sampler, curPoint - vec3( 0.0, s, 0.0 ) ).r;
float valueZP = texture3D( u_texture0Sampler, curPoint + vec3( 0.0, 0.0, s ) ).r;
float valueZM = texture3D( u_texture0Sampler, curPoint - vec3( 0.0, 0.0, s ) ).r;
vec3 dir = v_ray;
dir += vec3( valueXP, 0.0, 0.0 );
......@@ -279,13 +276,14 @@ void main()
float minSize = ( paramSpaceSize * 0.05 ); // the minimum size of 1% of the parameter space size
float maxSize = ( paramSpaceSize * 0.30 ); // the maximum size -> 30% of parameter space size
float trace = texture3D( tex1, curPoint ).r * ( paramSpaceSize );
float traceInv = ( 1.0 - texture3D( tex1, curPoint ).r ) * ( paramSpaceSize );
float trace = texture3D( u_texture1Sampler, curPoint ).r * ( paramSpaceSize );
float traceInv = ( 1.0 - texture3D( u_texture1Sampler, curPoint ).r ) * ( paramSpaceSize );
// 4: prepare animation
// the current time step:
float timeStep = u_animationTime / 4.0; // scale 100th of a second to 25 times per second
//timeStep = 25;
// create a triangle function increasing time in 1/100 steps
float relativeSpeed1 = float( u_speed1 ) / 2.0;
float relativeSpeed2 = float( u_speed2 ) / 2.0;
......
......@@ -36,12 +36,6 @@
// Uniforms
/////////////////////////////////////////////////////////////////////////////
// texture containing the data
uniform sampler3D tex0;
// texture containing the directional data
uniform sampler3D tex1;
/////////////////////////////////////////////////////////////////////////////
// Attributes
/////////////////////////////////////////////////////////////////////////////
......
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