Commit 1e98860b authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] lineAO algo now allows disabling the occluder-lihgt contribution....

[CHANGE] lineAO algo now allows disabling the occluder-lihgt contribution. Also changed some constraints for the radius properties.
parent 0c1cfaf1
......@@ -54,8 +54,8 @@ WGEPostprocessorLineAO::WGEPostprocessorLineAO( osg::ref_ptr< WGEOffscreenRender
lineaoScalers->setMax( 8 );
WPropDouble lineaoRadiusSS = m_properties->addProperty( "Radius", "The radius around the pixel to sample for occluders in pixels.", 2.0 );
lineaoRadiusSS->setMin( 0.01 );
lineaoRadiusSS->setMax( 10.0 );
lineaoRadiusSS->setMin( 0.0 );
lineaoRadiusSS->setMax( 100.0 );
WPropDouble lineaoTotalStrength = m_properties->addProperty( "Total Strength", "The strength of the effect. Higher values emphasize the effect.",
1.0 );
......@@ -75,6 +75,11 @@ WGEPostprocessorLineAO::WGEPostprocessorLineAO( osg::ref_ptr< WGEOffscreenRender
"described in the paper, this is turned off by default to "
"ensure that details of far occluders are retained (the "
"images look crispier).", false );
WPropBool lineaoUseOccluderLight = m_properties->addProperty( "Use Occluder Light", "When enabling, the LineAO algorithm uses the light "
"reflected by the occluder as contribution to ambient "
"light energy of the pixel. This creates a more realistic "
"rendering but might brighten areas you might want to stay "
"dark.", true );
// NOTE: The paper proposes to use a gaussian pyramid of the depth and normal maps. We skip this step. Skipping this causes the AO to look
// more crispy and more detailed at local scope.
......@@ -97,6 +102,11 @@ WGEPostprocessorLineAO::WGEPostprocessorLineAO( osg::ref_ptr< WGEOffscreenRender
"WGE_POSTPROCESSOR_LINEAO_USEGAUSSPYRAMID" ) )
);
s->addPreprocessor( WGEShaderPreprocessor::SPtr(
new WGEShaderPropertyDefineOptions< WPropBool >( lineaoUseOccluderLight, "WGE_POSTPROCESSOR_LINEAO_NOOCCLUDERLIGHT",
"WGE_POSTPROCESSOR_LINEAO_OCCLUDERLIGHT" ) )
);
// create the LineAO rendering pass
osg::ref_ptr< WGEOffscreenTexturePass > lineAOPass = offscreen->addTextureProcessingPass( s, "LineAO" );
lineAOPass->getOrCreateStateSet()->addUniform( new WGEPropertyUniform< WPropDouble >( "u_lineaoDensityWeight", lineaoDensityWeight ) );
......
......@@ -49,7 +49,7 @@ WGEPostprocessorSSAO::WGEPostprocessorSSAO( osg::ref_ptr< WGEOffscreenRenderNode
WPropDouble ssaoRadius = m_properties->addProperty( "Radius", "The radius around the pixel to sample for occluders in pixels.", 10.0 );
ssaoRadius->setMin( 0.0 );
ssaoRadius->setMax( 100.0 );
ssaoRadius->setMax( 500.0 );
WPropDouble ssaoTotalStrength = m_properties->addProperty( "Total Strength", "The strength of the effect. Higher values emphasize the effect.",
2.0 );
......
......@@ -352,7 +352,8 @@ float getLineAO( vec2 where )
// the radius of the sphere is, in screen-space, half a pixel. So the hemisphere covers nearly one pixel. Scaling by depth somehow makes it
// more invariant for zooming
float radius = ( getZoom() * u_lineaoRadiusSS / float( u_texture0SizeX ) ) / ( 1.0 - currentPixelDepth );
float maxPixels = max( u_colorSizeX, u_colorSizeY );
float radius = ( getZoom() * u_lineaoRadiusSS / maxPixels ) / ( 1.0 - currentPixelDepth );
// some temporaries needed inside the loop
vec3 ray; // the current ray inside the sphere
......@@ -431,9 +432,15 @@ float getLineAO( vec2 where )
float pointDiffuse = max( dot( hemisphereVector, normal ), 0.0 ); // this equals the diffuse term in Phong if lightDir is the
// occluder's surface
// calculate the diffuse reflected light of the occluder, which might contribute to the current pixels brightness
#ifdef WGE_POSTPROCESSOR_LINEAO_OCCLUDERLIGHT
vec3 t = getTangent( hemispherePoint.xy, lod ).xyz;
vec3 newnorm = normalize( cross( normalize( cross( t, normalize( hemisphereVector ) ) ), t ) );
float occluderDiffuse = max( dot( newnorm, gl_LightSource[0].position.xyz ), 0.0 );
#else
// you can disable this effect.
float occluderDiffuse = 0.0;
#endif
// incorporate specular reflection
vec3 H = normalize( gl_LightSource[0].position.xyz + normalize( hemisphereVector ) );
......
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