Commit 0578eb24 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] - some minor updates in postprocessor stuff.

parent e493bef3
......@@ -96,12 +96,6 @@ WGEPostprocessingNode::WGEPostprocessingNode( osg::ref_ptr< osg::Camera > refere
// let the props control some stuff
addUpdateCallback( new WGESwitchCallback< WPropSelection >( m_activePostprocessor ) );
// some of the post-processors need some white noise, like the ssao
/* const size_t size = 64;
osg::ref_ptr< WGETexture2D > randTex = wge::genWhiteNoiseTexture( size, size, 3 );
m_postprocess->bind( randTex, 4 );
*/
}
WGEPostprocessingNode::~WGEPostprocessingNode()
......
......@@ -22,6 +22,8 @@
//
//---------------------------------------------------------------------------
#include <string>
#include "WGEPostprocessorEdgeEnhance.h"
#include "WGEPostprocessorCelShading.h"
......@@ -86,13 +88,15 @@ WGEPostprocessor::PostprocessorInput WGEPostprocessor::PostprocessorInput::attac
return buf;
}
void WGEPostprocessor::PostprocessorInput::bind( osg::ref_ptr< WGEOffscreenRenderPass > to ) const
size_t WGEPostprocessor::PostprocessorInput::bind( osg::ref_ptr< WGEOffscreenRenderPass > to ) const
{
to->bind( m_colorTexture, 0 );
to->bind( m_normalTexture, 1 );
to->bind( m_parameterTexture, 2 );
to->bind( m_depthTexture, 3 );
to->bind( m_tangentTexture, 4 );
return 5;
}
WGEPostprocessor::ProcessorList WGEPostprocessor::getPostprocessors()
......
......@@ -71,8 +71,10 @@ public:
* Attaches these textures to the specified renderpass
*
* \param to attach to this
*
* \return the ID of the NEXT free texture unit you can use
*/
void bind( osg::ref_ptr< WGEOffscreenRenderPass > to ) const;
size_t bind( osg::ref_ptr< WGEOffscreenRenderPass > to ) const;
/**
* Color in RGBA
......@@ -186,7 +188,8 @@ protected:
* \param name a name for this postprocessor
* \param description a useful description
*/
WGEPostprocessor( osg::ref_ptr< WGEOffscreenRenderNode > offscreen, const PostprocessorInput& gbuffer, std::string name, std::string description );
WGEPostprocessor( osg::ref_ptr< WGEOffscreenRenderNode > offscreen, const PostprocessorInput& gbuffer,
std::string name, std::string description );
/**
* The texture contains the result
......@@ -213,7 +216,6 @@ protected:
*/
WGEShaderPreprocessor::SPtr m_effectOnlyPreprocessor;
private:
/**
* Name string. Set by the constructor.
*/
......
......@@ -35,7 +35,6 @@
class WGEPostprocessorCelShading: public WGEPostprocessor
{
public:
/**
* Convenience typedef for a boost::shared_ptr< WGEPostprocessorCelShading >.
*/
......
......@@ -35,7 +35,6 @@
class WGEPostprocessorEdgeEnhance: public WGEPostprocessor
{
public:
/**
* Convenience typedef for a boost::shared_ptr< WGEPostprocessorEdgeEnhance >.
*/
......
......@@ -32,21 +32,10 @@
#include "WGEPostprocessorUtils-fragment.glsl"
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Uniforms
// Global Uniforms
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// These are specific to the postprocessor
/**
* The number of bins to use for cel shading
*/
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;
// These are NOT specific to any postprocessor
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Varying
......@@ -64,6 +53,14 @@ uniform float u_edgeEdgeThresholdUpper = 0.75;
// Postprocessors
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#ifdef WGE_POSTPROCESSOR_EDGE
/**
* The threshold used to clip away "unwanted" borders. Basically removes noise
*/
uniform float u_edgeEdgeThresholdLower = 0.25;
uniform float u_edgeEdgeThresholdUpper = 0.75;
/**
* Apply laplace-filter to depth buffer. An edge is > 0.0.
*
......@@ -105,6 +102,15 @@ float getEdge()
return smoothstep( u_edgeEdgeThresholdLower, u_edgeEdgeThresholdUpper, edge );
}
#endif
#ifdef WGE_POSTPROCESSOR_CEL
/**
* The number of bins to use for cel shading
*/
uniform int u_celShadingBins = 2;
/**
* Calculate the cel-shading of a specified color. The number of colors is defined by the u_celShadingSamples uniform.
*
......@@ -131,6 +137,8 @@ vec4 getCelShading()
return getCelShading( getColor() );
}
#endif
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Main
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -143,6 +151,7 @@ void main()
// don't do this stuff for background pixel
float depth = getDepth();
gl_FragDepth = depth;
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
if( depth > 0.99 )
{
discard;
......
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
......
......@@ -237,5 +237,27 @@ float getZoom()
return getZoom( pixelCoord );
}
/**
* Grab a vector from the noise texture. You should of course bind a RGB texture to u_noiseSampler.
*
* \param where position
*
* \return the unscaled vector in [-1,1] for each component
*/
vec3 getNoiseAsVector( in vec2 where )
{
return texture2D( u_noiseSampler, where ).rgb * 2.0 - vec3( 1.0 );
}
/**
* Grab a vector from the noise texture. You should of course bind a RGB texture to u_noiseSampler.
*
* \return the unscaled vector in [-1,1] for each component
*/
vec3 getNoiseAsVector()
{
return getNoiseAsVector( pixelCoord );
}
#endif // WGEPOSTPROCESSORUTILS_FRAGMENT_GLSL
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