27 #include "../shaders/WGEPropertyUniform.h"
28 #include "../shaders/WGEShaderPropertyDefine.h"
29 #include "WGEPostprocessorGauss.h"
30 #include "WGEPostprocessorMergeOp.h"
32 #include "WGEPostprocessorLineAO.h"
36 "LineAO is a special ambient occlusion technique optimized for dense line and tube rendering." )
43 "LineAO is a special ambient occlusion technique optimized for dense line and tube rendering." )
46 WPropInt lineaoSamples =
m_properties->addProperty(
"Samples",
"The number of samples to take in screen-space. Higher values produce better "
47 "quality but can reduce FPS dramatically.", 32 );
48 lineaoSamples->setMin( 1 );
49 lineaoSamples->setMax( 128 );
51 WPropInt lineaoScalers =
m_properties->addProperty(
"Hemispheres",
"The number of hemispheres to sample around each pixel. Higher values "
52 "produce better quality but can reduce FPS dramatically.", 3 );
53 lineaoScalers->setMin( 1 );
54 lineaoScalers->setMax( 8 );
56 WPropDouble lineaoRadiusSS =
m_properties->addProperty(
"Radius",
"The radius around the pixel to sample for occluders in pixels.", 2.0 );
57 lineaoRadiusSS->setMin( 0.0 );
58 lineaoRadiusSS->setMax( 100.0 );
60 WPropDouble lineaoTotalStrength =
m_properties->addProperty(
"Total Strength",
"The strength of the effect. Higher values emphasize the effect.",
62 lineaoTotalStrength->setMin( 0.0 );
63 lineaoTotalStrength->setMax( 5.0 );
65 WPropDouble lineaoDensityWeight =
m_properties->addProperty(
"Density Weight",
"The strength of the occluder influence in relation to the "
66 "geometry density. The higher the value, the larger the "
67 "influence. Low values remove the drop-shadow effect. "
68 "This defines the influence of one occluder to the overall "
70 lineaoDensityWeight->setMin( 0.001 );
71 lineaoDensityWeight->setMax( 2.0 );
73 WPropBool lineaoUseGaussedNDMap =
m_properties->addProperty(
"Use Gaussed ND-Map",
"When enabling, the LineAO algorithm uses a scale-base "
74 "pyramid for sampling the depth and normal maps. Unlike "
75 "described in the paper, this is turned off by default to "
76 "ensure that details of far occluders are retained (the "
77 "images look crispier).",
false );
78 WPropBool lineaoUseOccluderLight =
m_properties->addProperty(
"Use Occluder Light",
"When enabling, the LineAO algorithm uses the light "
79 "reflected by the occluder as contribution to ambient "
80 "light energy of the pixel. This creates a more realistic "
81 "rendering but might brighten areas you might want to stay "
89 s->setDefine(
"WGE_POSTPROCESSOR_LINEAO" );
102 "WGE_POSTPROCESSOR_LINEAO_USEGAUSSPYRAMID" ) )
107 "WGE_POSTPROCESSOR_LINEAO_OCCLUDERLIGHT" ) )
111 osg::ref_ptr< WGEOffscreenTexturePass > lineAOPass = offscreen->addTextureProcessingPass( s,
"LineAO" );
117 m_resultTextures.push_back( lineAOPass->attach( WGECamera::COLOR_BUFFER0, GL_RGB ) );
120 gbuffer.
m_depthTexture->setFilter( osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR );
121 gbuffer.
m_normalTexture->setFilter( osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR );
122 gbuffer.
m_tangentTexture->setFilter( osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR );
124 size_t gBufUnitOffset = gbuffer.
bind( lineAOPass );
127 const size_t size = 64;
129 lineAOPass->bind( randTex, gBufUnitOffset );
virtual WGEPostprocessor::SPtr create(osg::ref_ptr< WGEOffscreenRenderNode > offscreen, const PostprocessorInput &gbuffer) const
Create instance.
virtual ~WGEPostprocessorLineAO()
Destructor.
WGEPostprocessorLineAO()
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.
std::shared_ptr< WGEShaderPreprocessor > SPtr
Shared pointer for this class.
This is a WGEShaderDefineOptions class which additionally uses a property to automatically control th...
This class is able to provide arbitrary values as define statements in GLSL code.
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.