Commit 0ee166c2 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[ADD] - added some options for both effects

parent 59ee8c0d
......@@ -46,7 +46,12 @@ WGEPostprocessor::WGEPostprocessor( osg::ref_ptr< WGEOffscreenRenderNode > /* of
m_description( description )
{
// there is always one property:
m_effectOnly = m_properties->addProperty( "Effect only", "If active, the plain effect will be shown instead a combination of effect and color", false );
m_effectOnly = m_properties->addProperty( "Effect only", "If active, the plain effect will be shown instead a combination of effect "
"and color. This settings does not affect all postprocessors.", false );
// for convenience, also create a preprocessor for this property
m_effectOnlyPreprocessor = WGEShaderPreprocessor::SPtr( new WGEShaderPropertyDefineOptions< WPropBool >( m_effectOnly,
"WGE_POSTPROCESSOR_OUTPUT_COMBINE", "WGE_POSTPROCESSOR_OUTPUT_EFFECT_ONLY" ) );
}
WGEPostprocessor::~WGEPostprocessor()
......
......@@ -39,6 +39,8 @@
#include "../offscreen/WGEOffscreenRenderPass.h"
#include "../offscreen/WGEOffscreenFinalPass.h"
#include "../shaders/WGEShaderPropertyDefineOptions.h"
#include "../../common/WProperties.h"
#include "../../common/WPrototyped.h"
......@@ -205,6 +207,11 @@ protected:
* A flag denoting whether the effect should be combined with color or not.
*/
WPropBool m_effectOnly;
/**
* For convenience, this is a shader preprocessor controlled by m_effectOnly property.
*/
WGEShaderPreprocessor::SPtr m_effectOnlyPreprocessor;
private:
/**
......
......@@ -24,7 +24,6 @@
#include <osg/Camera>
#include "../shaders/WGEShaderPropertyDefineOptions.h"
#include "../shaders/WGEPropertyUniform.h"
#include "WGEPostprocessorCelShading.h"
......@@ -45,6 +44,9 @@ WGEPostprocessorCelShading::WGEPostprocessorCelShading( osg::ref_ptr< WGEOffscre
bins->setMin( 1 );
bins->setMax( 100 );
// hide m_effectOnly since this is not useful for Cel Shading
m_effectOnly->setHidden( true );
// construct pipeline
// Use the standard postprocessor uber-shader
......@@ -52,9 +54,7 @@ WGEPostprocessorCelShading::WGEPostprocessorCelShading( osg::ref_ptr< WGEOffscre
s->setDefine( "WGE_POSTPROCESSOR_CEL" );
// also add the m_effectOnly property as shader preprocessor
s->addPreprocessor( WGEShaderPreprocessor::SPtr(
new WGEShaderPropertyDefineOptions< WPropBool >( m_effectOnly, "COMBINE_COLOR_WITH_EFFECT", "EFFECT_ONLY" ) )
);
s->addPreprocessor( m_effectOnlyPreprocessor );
// create the rendering pass
osg::ref_ptr< WGEOffscreenTexturePass > pass = offscreen->addTextureProcessingPass( s, "Cel Shading" );
......
......@@ -39,22 +39,24 @@ WGEPostprocessorEdgeEnhance::WGEPostprocessorEdgeEnhance( osg::ref_ptr< WGEOffsc
WGEPostprocessor( offscreen, gbuffer, "Edge Enhance",
"Edge detection filter to emphasize edges in complex geometry." )
{
// construct pipeline
// we also provide a property
WPropBool whiteEdge = m_properties->addProperty( "White Edge", "If set, the edge is drawn in white instead of black.", false );
// Use the standard postprocessor uber-shader
WGEShader::RefPtr s = new WGEShader( "WGEPostprocessor" );
s->setDefine( "WGE_POSTPROCESSOR_EDGE" );
// also add the m_effectOnly property as shader preprocessor
s->addPreprocessor( m_effectOnlyPreprocessor );
s->addPreprocessor( WGEShaderPreprocessor::SPtr(
new WGEShaderPropertyDefineOptions< WPropBool >( m_effectOnly, "COMBINE_COLOR_WITH_EFFECT", "EFFECT_ONLY" ) )
new WGEShaderPropertyDefineOptions< WPropBool >( whiteEdge, "WGE_POSTPROCESSOR_EDGE_BLACKEDGE", "WGE_POSTPROCESSOR_EDGE_WHITEEDGE" ) )
);
// create the rendering pass
osg::ref_ptr< WGEOffscreenTexturePass > pass = offscreen->addTextureProcessingPass( s, "Edge Detection" );
// attach color0 output
m_resultTexture = pass->attach( osg::Camera::COLOR_BUFFER0, GL_RGBA );
m_resultTexture = pass->attach( osg::Camera::COLOR_BUFFER0, GL_RGB );
// provide the Gbuffer input
gbuffer.bind( pass );
......
......@@ -58,53 +58,6 @@ uniform int u_celShadingBins = 2;
// Postprocessors
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Phong based Per-Pixel-Lighting.
*
* \param normal the surface normal. Normalized.
* \param lightParams the ligh parameters
*
* \return the intensity.
*/
float getPPLPhong( in wge_LightIntensityParameter lightParams, in vec3 normal )
{
return blinnPhongIlluminationIntensity( lightParams, normal );
}
/**
* Phong based Per-Pixel-Lighting.
*
* \param normal the surface normal. Normalized.
*
* \return the intensity.
*/
float getPPLPhong( in vec3 normal )
{
return blinnPhongIlluminationIntensity( normal );
}
/**
* Phong based Per-Pixel-Lighting based on the specified color.
*
* \return the new lighten color.
*/
float getPPLPhong()
{
return getPPLPhong( getNormal().xyz );
}
/**
* Phong based Per-Pixel-Lighting based on the specified color.
*
* \param lightParams the ligh parameters
*
* \return the intensity.
*/
float getPPLPhong( in wge_LightIntensityParameter lightParams )
{
return getPPLPhong( lightParams, getNormal().xyz );
}
/**
* Apply laplace-filter to depth buffer. An edge is > 0.0.
*
......@@ -191,7 +144,28 @@ void main()
#ifdef WGE_POSTPROCESSOR_EDGE
// output the depth and final color.
gl_FragColor = vec4( vec3( 1.0 - getEdge() ), 1.0 );
#ifdef WGE_POSTPROCESSOR_OUTPUT_COMBINE
// for black borders, multiply edge with color
#ifdef WGE_POSTPROCESSOR_EDGE_BLACKEDGE
#define EDGEOP * ( 1.0 - getEdge() )
#else
// for white borders, add
#define EDGEOP + vec3( getEdge() )
#endif
// apply operation and output color
gl_FragColor = vec4( getColor().rgb EDGEOP, 1.0 );
#else
// also do this for the effect-only output
#ifdef WGE_POSTPROCESSOR_EDGE_BLACKEDGE
#define EDGEOP 1.0 -
#else
// for white borders, add
#define EDGEOP 0.0 +
#endif
gl_FragColor = vec4( vec3( EDGEOP getEdge() ), 1.0 );
#endif
#endif
#ifdef WGE_POSTPROCESSOR_CEL
......
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