Commit ccd73535 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[ADD] - added some options for both effects

parent 0ee166c2
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "../../common/WItemSelection.h" #include "../../common/WItemSelection.h"
#include "../shaders/WGEShaderPropertyDefineOptions.h" #include "../shaders/WGEShaderPropertyDefineOptions.h"
#include "../callbacks/WGENodeMaskCallback.h"
#include "../WGEUtils.h" #include "../WGEUtils.h"
#include "WGEPostprocessor.h" #include "WGEPostprocessor.h"
...@@ -43,6 +44,8 @@ WGEPostprocessingNode::WGEPostprocessingNode( osg::ref_ptr< osg::Camera > refere ...@@ -43,6 +44,8 @@ WGEPostprocessingNode::WGEPostprocessingNode( osg::ref_ptr< osg::Camera > refere
// this node has some properties: // this node has some properties:
boost::shared_ptr< WItemSelection > m_possibleSelections = boost::shared_ptr< WItemSelection >( new WItemSelection() ); boost::shared_ptr< WItemSelection > m_possibleSelections = boost::shared_ptr< WItemSelection >( new WItemSelection() );
m_possibleSelections->addItem( "None", "No postprocessing." ); m_possibleSelections->addItem( "None", "No postprocessing." );
m_showHud = m_properties->addProperty( "Texture Debug", "If set, all intermediate texture are shown on screen for debugging.", false );
m_active = m_properties->addProperty( "Enable", "If set, post-processing is enabled.", false, true ); m_active = m_properties->addProperty( "Enable", "If set, post-processing is enabled.", false, true );
m_activePostprocessor = m_properties->addProperty( "Postprocessor", "Selection one of the postprocessors.", m_activePostprocessor = m_properties->addProperty( "Postprocessor", "Selection one of the postprocessors.",
m_possibleSelections->getSelectorFirst(), m_possibleSelections->getSelectorFirst(),
...@@ -50,12 +53,17 @@ WGEPostprocessingNode::WGEPostprocessingNode( osg::ref_ptr< osg::Camera > refere ...@@ -50,12 +53,17 @@ WGEPostprocessingNode::WGEPostprocessingNode( osg::ref_ptr< osg::Camera > refere
WPropertyHelper::PC_SELECTONLYONE::addTo( m_activePostprocessor ); WPropertyHelper::PC_SELECTONLYONE::addTo( m_activePostprocessor );
WPropertyHelper::PC_NOTEMPTY::addTo( m_activePostprocessor ); WPropertyHelper::PC_NOTEMPTY::addTo( m_activePostprocessor );
// control texture HUD
osg::ref_ptr< WGENodeMaskCallback > textureHudCallback = new WGENodeMaskCallback( m_showHud );
// get available postprocessors and setup the node // get available postprocessors and setup the node
WGEPostprocessor::ProcessorList processors = WGEPostprocessor::getPostprocessors(); WGEPostprocessor::ProcessorList processors = WGEPostprocessor::getPostprocessors();
for( WGEPostprocessor::ProcessorList::const_iterator iter = processors.begin(); iter != processors.end(); ++iter ) for( WGEPostprocessor::ProcessorList::const_iterator iter = processors.begin(); iter != processors.end(); ++iter )
{ {
// offscreen node // offscreen node
osg::ref_ptr< WGEOffscreenRenderNode > offscreen( new WGEOffscreenRenderNode( reference, width, height, noHud ) ); osg::ref_ptr< WGEOffscreenRenderNode > offscreen( new WGEOffscreenRenderNode( reference, width, height, noHud ) );
offscreen->getTextureHUD()->addUpdateCallback( textureHudCallback );
// the geometry render step // the geometry render step
osg::ref_ptr< WGEOffscreenRenderPass > render = offscreen->addGeometryRenderPass( osg::ref_ptr< WGEOffscreenRenderPass > render = offscreen->addGeometryRenderPass(
m_childs, m_childs,
......
...@@ -154,6 +154,11 @@ private: ...@@ -154,6 +154,11 @@ private:
*/ */
WPropBool m_active; WPropBool m_active;
/**
* Activate to show the texture HUDs
*/
WPropBool m_showHud;
/** /**
* The property containing the currently active method or a combination. * The property containing the currently active method or a combination.
*/ */
......
...@@ -40,7 +40,7 @@ WGEPostprocessorCelShading::WGEPostprocessorCelShading( osg::ref_ptr< WGEOffscre ...@@ -40,7 +40,7 @@ WGEPostprocessorCelShading::WGEPostprocessorCelShading( osg::ref_ptr< WGEOffscre
"This postprocessor reduces color by binning colors." ) "This postprocessor reduces color by binning colors." )
{ {
// we also provide a property // we also provide a property
WPropInt bins = m_properties->addProperty( "Number of Bins", "The number of color bins used for cel shading.", 2 ); WPropInt bins = m_properties->addProperty( "Number of Bins", "The number of color bins used for cel shading.", 10 );
bins->setMin( 1 ); bins->setMin( 1 );
bins->setMax( 100 ); bins->setMax( 100 );
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <osg/Camera> #include <osg/Camera>
#include "../shaders/WGEPropertyUniform.h"
#include "../shaders/WGEShaderPropertyDefineOptions.h" #include "../shaders/WGEShaderPropertyDefineOptions.h"
#include "WGEPostprocessorEdgeEnhance.h" #include "WGEPostprocessorEdgeEnhance.h"
...@@ -41,6 +42,12 @@ WGEPostprocessorEdgeEnhance::WGEPostprocessorEdgeEnhance( osg::ref_ptr< WGEOffsc ...@@ -41,6 +42,12 @@ WGEPostprocessorEdgeEnhance::WGEPostprocessorEdgeEnhance( osg::ref_ptr< WGEOffsc
{ {
// we also provide a property // we also provide a property
WPropBool whiteEdge = m_properties->addProperty( "White Edge", "If set, the edge is drawn in white instead of black.", false ); WPropBool whiteEdge = m_properties->addProperty( "White Edge", "If set, the edge is drawn in white instead of black.", false );
WPropDouble edgeThresholdL = m_properties->addProperty( "Edge Lower Threshold", "Define the edge threshold. Filters way \"weak\" edges.", 0.0 );
WPropDouble edgeThresholdU = m_properties->addProperty( "Edge Upper Threshold", "Define the edge threshold. Filters way \"weak\" edges.", 1.0 );
edgeThresholdL->setMin( 0.0 );
edgeThresholdL->setMax( 1.0 );
edgeThresholdU->setMin( 0.0 );
edgeThresholdU->setMax( 1.0 );
// Use the standard postprocessor uber-shader // Use the standard postprocessor uber-shader
WGEShader::RefPtr s = new WGEShader( "WGEPostprocessor" ); WGEShader::RefPtr s = new WGEShader( "WGEPostprocessor" );
...@@ -54,6 +61,8 @@ WGEPostprocessorEdgeEnhance::WGEPostprocessorEdgeEnhance( osg::ref_ptr< WGEOffsc ...@@ -54,6 +61,8 @@ WGEPostprocessorEdgeEnhance::WGEPostprocessorEdgeEnhance( osg::ref_ptr< WGEOffsc
// create the rendering pass // create the rendering pass
osg::ref_ptr< WGEOffscreenTexturePass > pass = offscreen->addTextureProcessingPass( s, "Edge Detection" ); osg::ref_ptr< WGEOffscreenTexturePass > pass = offscreen->addTextureProcessingPass( s, "Edge Detection" );
pass->getOrCreateStateSet()->addUniform( new WGEPropertyUniform< WPropDouble >( "u_edgeEdgeThresholdUpper", edgeThresholdU ) );
pass->getOrCreateStateSet()->addUniform( new WGEPropertyUniform< WPropDouble >( "u_edgeEdgeThresholdLower", edgeThresholdL ) );
// attach color0 output // attach color0 output
m_resultTexture = pass->attach( osg::Camera::COLOR_BUFFER0, GL_RGB ); m_resultTexture = pass->attach( osg::Camera::COLOR_BUFFER0, GL_RGB );
......
...@@ -42,6 +42,12 @@ ...@@ -42,6 +42,12 @@
*/ */
uniform int u_celShadingBins = 2; uniform int u_celShadingBins = 2;
/**
* The threshold used to clip away "unwanted" borders. Basically removes noise
*/
uniform float u_edgeEdgeThresholdLower = 0.25;
uniform float u_edgeEdgeThresholdUpper = 0.75;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Varying // Varying
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
...@@ -96,7 +102,7 @@ float getEdge() ...@@ -96,7 +102,7 @@ float getEdge()
0.0 * edgebl + 1.0 * edgeb + 0.0 * edgebr 0.0 * edgebl + 1.0 * edgeb + 0.0 * edgebr
); );
return edge; return smoothstep( u_edgeEdgeThresholdLower, u_edgeEdgeThresholdUpper, edge );
} }
/** /**
......
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