Commit cc4f8c3d authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[ADD #222] added postproc to isosurface

parent e23f1d38
......@@ -52,6 +52,7 @@
#include "core/graphicsEngine/shaders/WGEPropertyUniform.h"
#include "core/graphicsEngine/shaders/WGEShaderPropertyDefineOptions.h"
#include "core/graphicsEngine/shaders/WGEShaderPropertyDefine.h"
#include "core/graphicsEngine/postprocessing/WGEPostprocessingNode.h"
#include "core/graphicsEngine/WGEColormapping.h"
#include "core/graphicsEngine/WGEUtils.h"
#include "core/kernel/WKernel.h"
......@@ -109,10 +110,30 @@ void WMIsosurface::moduleMain()
m_moduleState.add( m_input->getDataChangedCondition() );
m_moduleState.add( m_recompute );
// create the post-processing node which actually does the nice stuff to the rendered image
osg::ref_ptr< WGEPostprocessingNode > postNode = new WGEPostprocessingNode(
WKernel::getRunningKernel()->getGraphicsEngine()->getViewer()->getCamera()
);
// provide the properties of the post-processor to the user
m_properties->addProperty( postNode->getProperties() );
// add to scene
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->insert( postNode );
// signal ready state
ready();
// create shader
m_shader = osg::ref_ptr< WGEShader >( new WGEShader( "WMIsosurface", m_localPath ) );
m_shader->addPreprocessor( WGEShaderPreprocessor::SPtr(
new WGEShaderPropertyDefineOptions< WPropBool >( m_useTextureProp, "COLORMAPPING_DISABLED", "COLORMAPPING_ENABLED" ) )
);
m_moduleNode = new WGEManagedGroupNode( m_active );
m_moduleNode->getOrCreateStateSet()->addUniform( new WGEPropertyUniform< WPropInt >( "u_opacity", m_opacityProp ) );
// add it to postproc node and register shader
postNode->insert( m_moduleNode, m_shader );
// loop until the module container requests the module to quit
while( !m_shutdownFlag() )
......@@ -177,7 +198,7 @@ void WMIsosurface::moduleMain()
progress->finish();
}
WKernel::getRunningKernel()->getGraphicsEngine()->getViewer()->getScene()->remove( m_moduleNode );
WKernel::getRunningKernel()->getGraphicsEngine()->getViewer()->getScene()->remove( postNode );
}
void WMIsosurface::connectors()
......@@ -431,29 +452,15 @@ void WMIsosurface::renderMesh()
surfaceGeometry->setUseDisplayList( false );
surfaceGeometry->setUseVertexBufferObjects( true );
// ------------------------------------------------
// Shader stuff
osg::ref_ptr< WGEShader > shader = osg::ref_ptr< WGEShader >( new WGEShader( "WMIsosurface", m_localPath ) );
shader->addPreprocessor( WGEShaderPreprocessor::SPtr(
new WGEShaderPropertyDefineOptions< WPropBool >( m_useTextureProp, "COLORMAPPING_DISABLED", "COLORMAPPING_ENABLED" ) )
);
state->addUniform( new WGEPropertyUniform< WPropInt >( "u_opacity", m_opacityProp ) );
shader->apply( m_surfaceGeode );
m_shader->apply( m_surfaceGeode );
// enable transparency
wge::enableTransparency( m_surfaceGeode );
// Colormapping
WGEColormapping::apply( m_surfaceGeode, shader );
WGEColormapping::apply( m_surfaceGeode, m_shader );
m_moduleNode->insert( m_surfaceGeode );
if( !m_moduleNodeInserted )
{
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->insert( m_moduleNode );
m_moduleNodeInserted = true;
}
m_moduleNode->addUpdateCallback( new WGEFunctorCallback< osg::Node >( boost::bind( &WMIsosurface::updateGraphicsCallback, this ) ) );
}
......
......@@ -158,6 +158,11 @@ private:
bool m_moduleNodeInserted; //!< ensures that the above module node gets inserted once the first triangle mesh has been calculated.
osg::ref_ptr< osg::Geode > m_surfaceGeode; //!< Pointer to geode containing the surface.
/**
* The shader
*/
osg::ref_ptr< WGEShader > m_shader;
};
#endif // WMISOSURFACE_H
......@@ -25,7 +25,8 @@
#version 120
#include "WGEColormapping-fragment.glsl"
#include "WGETextureTools.glsl"
#include "WGEPostprocessing.glsl"
#include "WGEShadingTools.glsl"
// opacity in percent
......@@ -34,6 +35,9 @@ uniform int u_opacity;
// The surface normal
varying vec3 v_normal;
// modelview matrix' scaling factor
varying float v_worldScale;
void main()
{
vec4 col = gl_Color;
......@@ -48,5 +52,12 @@ void main()
// opacity of the surface
col.rgb = light * col.rgb;
col.a = float( u_opacity ) * 0.01;
gl_FragColor = col;
// finally set the color and depth
wgeInitGBuffer();
wge_FragColor = col;
wge_FragNormal = textureNormalize( normalize( v_normal ) );
wge_FragZoom = v_worldScale;
wge_FragTangent = textureNormalize( v_normal );
}
......@@ -25,10 +25,14 @@
#version 120
#include "WGEColormapping-vertex.glsl"
#include "WGETransformationTools.glsl"
// The surface normal
varying vec3 v_normal;
// modelview matrix' scaling factor
varying float v_worldScale;
void main()
{
// prepare colormapping
......@@ -37,6 +41,9 @@ void main()
// prepare light
v_normal = gl_NormalMatrix * gl_Normal;
// Calc the scaling factor in the MV matrix
v_worldScale = getModelViewScale();
gl_FrontColor = gl_Color;
gl_Position = ftransform();
}
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