Commit 14c6ed89 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[ADD] added pre-blend scaling to postprocessing pipeline

parent 5d45355d
......@@ -46,6 +46,11 @@ WGEPostprocessor::WGEPostprocessor( std::string name, std::string 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. This settings does not affect all postprocessors.", false );
m_effectScale = m_properties->addProperty( "Effect Scaling", "Use this to overemphasize an effect or to weaken it. Technically spoken, this "
"factor determines the pre-multiplication done prior to blending with the input color.", 1.0,
true );
m_effectScale->setMin( 0.0 );
m_effectScale->setMax( 10.0 );
// for convenience, also create a preprocessor for this property
m_effectOnlyPreprocessor = WGEShaderPreprocessor::SPtr( new WGEShaderPropertyDefineOptions< WPropBool >( m_effectOnly,
......
......@@ -44,8 +44,6 @@
#include "../../common/WProperties.h"
#include "../../common/WPrototyped.h"
/**
* The base class for all custom post-processors. It allows building an own texture processing pipeline for special processings.
*/
......@@ -264,6 +262,11 @@ protected:
*/
WPropBool m_effectOnly;
/**
* Scale the effect prior to blending it.
*/
WPropDouble m_effectScale;
/**
* For convenience, this is a shader preprocessor controlled by m_effectOnly property.
*/
......
......@@ -127,6 +127,10 @@ WGEPostprocessorLineAO::WGEPostprocessorLineAO( osg::ref_ptr< WGEOffscreenRender
const size_t size = 64;
osg::ref_ptr< WGETexture2D > randTex = wge::genWhiteNoiseTexture( size, size, 3 );
lineAOPass->bind( randTex, gBufUnitOffset );
// also utilize the pre-blend scale
m_effectScale->setHidden( false );
lineAOPass->getOrCreateStateSet()->addUniform( new WGEPropertyUniform< WPropDouble >( "u_effectPreBlendScale", m_effectScale ) );
}
WGEPostprocessorLineAO::~WGEPostprocessorLineAO()
......
......@@ -37,6 +37,8 @@
// These are NOT specific to any postprocessor
uniform float u_effectPreBlendScale = 1.0;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Varying
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -516,10 +518,10 @@ void main()
// for black borders, multiply edge with color
#ifdef WGE_POSTPROCESSOR_EDGE_BLACKEDGE
#define EDGEOP * ( 1.0 - getEdge() )
#define EDGEOP * u_effectPreBlendScale * ( 1.0 - getEdge() )
#else
// for white borders, add
#define EDGEOP + vec3( getEdge() )
#define EDGEOP + vec3( u_effectPreBlendScale * getEdge() )
#endif
// apply operation and output color
......@@ -538,7 +540,7 @@ void main()
#ifdef WGE_POSTPROCESSOR_CEL
// output the depth and final color.
gl_FragData[0] = getCelShading();
gl_FragData[0] = u_effectPreBlendScale * getCelShading();
#endif
#ifdef WGE_POSTPROCESSOR_GAUSS
......@@ -607,18 +609,18 @@ void main()
#ifdef WGE_POSTPROCESSOR_SSAO
// output color AND SSAO?
#ifdef WGE_POSTPROCESSOR_OUTPUT_COMBINE
gl_FragData[0] = vec4( getColor().rgb * getSSAO(), 1.0 );
gl_FragData[0] = vec4( getColor().rgb * u_effectPreBlendScale * getSSAO(), 1.0 );
#else
gl_FragData[0] = vec4( vec3( getSSAO() ), 1.0 );
gl_FragData[0] = vec4( vec3( u_effectPreBlendScale * getSSAO() ), 1.0 );
#endif
#endif
#ifdef WGE_POSTPROCESSOR_LINEAO
// output color AND SSAO?
#ifdef WGE_POSTPROCESSOR_OUTPUT_COMBINE
gl_FragData[0] = vec4( getColor().rgb * getLineAO(), 1.0 );
gl_FragData[0] = vec4( getColor().rgb * u_effectPreBlendScale * getLineAO(), 1.0 );
#else
gl_FragData[0] = vec4( vec3( getLineAO() ), 1.0 );
gl_FragData[0] = vec4( vec3( u_effectPreBlendScale * getLineAO() ), 1.0 );
#endif
#endif
}
......
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