27 #include "../shaders/WGEPropertyUniform.h"
28 #include "../shaders/WGEShaderPropertyDefine.h"
29 #include "WGEPostprocessorGauss.h"
30 #include "WGEPostprocessorEdgeEnhance.h"
31 #include "WGEPostprocessorMergeOp.h"
33 #include "WGEPostprocessorHalftone.h"
37 "Halftone is a dithering effect to emphasize certain structures of a surface." )
44 "Halftone is a dithering effect to emphasize certain structures of a surface." )
47 WPropDouble ditherRotationMatrixAngle =
m_properties->addProperty(
"Rotation angle",
48 "Rotate the dither effect by this angle.", 30.0 );
49 ditherRotationMatrixAngle->setMin( 0 );
50 ditherRotationMatrixAngle->setMax( 180 );
52 WPropDouble ditherTexSize =
m_properties->addProperty(
"Texture Size",
54 ditherTexSize->setMin( 0 );
55 ditherTexSize->setMax( 10 );
57 WPropDouble ditherCrossHatchThreshold =
m_properties->addProperty(
"Cross Hatch Threshold",
59 ditherCrossHatchThreshold->setMin( 0 );
60 ditherCrossHatchThreshold->setMax( 10 );
62 WPropDouble ditherClip =
m_properties->addProperty(
"Dither Clip",
64 ditherClip->setMin( 0.0 );
65 ditherClip->setMax( 1.0 );
67 WPropColor hatchColor =
m_properties->addProperty(
"Hatch Color",
"Write", WColor( 0.1, 0.1, 0.1, 1.0 ) );
76 edgeProcessor->getOutput()->setFilter( osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR );
77 edgeProcessor->getProperties()->getProperty(
"Effect Only" )->toPropBool()->set(
true );
79 m_properties->addProperty( edgeProcessor->getProperties() );
86 s->setDefine(
"WGE_POSTPROCESSOR_HALFTONE" );
92 osg::ref_ptr< WGEOffscreenTexturePass > htPass = offscreen->addTextureProcessingPass( s,
"Halftone" );
104 m_resultTextures.push_back( htPass->attach( osg::Camera::COLOR_BUFFER0, GL_RGBA ) );
107 gbuffer.
m_depthTexture->setFilter( osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR );
108 gbuffer.
m_normalTexture->setFilter( osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR );
109 gbuffer.
m_tangentTexture->setFilter( osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR );
111 size_t gBufUnitOffset = gbuffer.
bind( htPass );
114 const size_t size = 64;
116 htPass->bind( randTex, gBufUnitOffset );
117 htPass->bind( edgeProcessor->getOutput(), gBufUnitOffset + 1 );
Edge enhancing postprocessor.
virtual WGEPostprocessor::SPtr create(osg::ref_ptr< WGEOffscreenRenderNode > offscreen, const PostprocessorInput &gbuffer) const
Create instance.
virtual ~WGEPostprocessorHalftone()
Destructor.
virtual WGEPostprocessor::SPtr create(osg::ref_ptr< WGEOffscreenRenderNode > offscreen, const PostprocessorInput &gbuffer) const
Create instance.
WGEPostprocessorHalftone()
Default constructor.
This class encapsulates a G-Buffer.
osg::ref_ptr< osg::Texture2D > m_normalTexture
Normal in RGB.
osg::ref_ptr< osg::Texture2D > m_tangentTexture
Tangent in RGB.
osg::ref_ptr< osg::Texture2D > m_depthTexture
Depth.
size_t bind(osg::ref_ptr< WGEOffscreenRenderPass > to) const
Attaches these textures to the specified renderpass.
The base class for all custom post-processors.
WGEShaderPreprocessor::SPtr m_effectOnlyPreprocessor
For convenience, this is a shader preprocessor controlled by m_effectOnly property.
WPropGroup m_properties
All the properties of the post-processor.
WPropDouble m_effectScale
Scale the effect prior to blending it.
std::shared_ptr< WGEPostprocessor > SPtr
Convenience typedef for an osg::ref_ptr< WGEPostprocessor >.
std::vector< osg::ref_ptr< osg::Texture2D > > m_resultTextures
The textures contain the result.
Class encapsulating the OSG Program class for a more convenient way of adding and modifying shader.
osg::ref_ptr< WGEShader > RefPtr
Convenience typedef for an osg::ref_ptr.
osg::ref_ptr< WGETexture< osg::Texture1D > > genWhiteNoiseTexture(size_t sizeX, size_t channels)
This generates an 1D texture only containing white noise in its channels.