What steps will reproduce the problem?
I am using a cell shader implementation, where the outline is created by
drawing the backfaces in wireframe mode with activated front face culling:
"osg::ref_ptr<osg::StateSet> linestate = node->getOrCreateStateSet();
linestate->setAttribute(new osg::LineWidth(4.0f));
linestate->setAttribute(new osg::CullFace(osg::CullFace::FRONT));
linestate->setAttribute(new osg::PolygonMode(osg::PolygonMode::BACK,
osg::PolygonMode::LINE));"
The fragment shader draws a black fragment, if the fragment is backface and the
regular color, if the fragment is front face:
"...
void main()
{
if (gl_FrontFacing)
{
gl_FragColor = lighting();
}
else
{
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.80);
}
}
..."
In the reflection image the front- and backface is switched(as seen in the
picture).
I changed the frontface mode to clockwise for the reflection camera to fix this
issue.
osgOcean::OceanScene::init(), OceanScene.cpp, line 363
BEFORE:
"// clip everything below water line
_reflectionCamera=renderToTexturePass( reflectionTexture.get() );
_reflectionCamera->setClearColor( osg::Vec4( 0.0, 0.0, 0.0, 0.0 ) );
_reflectionCamera->setCullMask( _reflectionSceneMask );
_reflectionCamera->setCullCallback( new CameraCullCallback(this) );
_reflectionCamera->getOrCreateStateSet()->setMode( GL_CLIP_PLANE0+0, osg::StateAttribute::ON );
_reflectionCamera->getOrCreateStateSet()->setMode( GL_CULL_FACE, osg::StateAttribute::OFF );"
AFTER:
"// clip everything below water line
_reflectionCamera=renderToTexturePass( reflectionTexture.get() );
_reflectionCamera->setClearColor( osg::Vec4( 0.0, 0.0, 0.0, 0.0 ) );
_reflectionCamera->setCullMask( _reflectionSceneMask );
_reflectionCamera->setCullCallback( new CameraCullCallback(this) );
_reflectionCamera->getOrCreateStateSet()->setMode( GL_CLIP_PLANE0+0, osg::StateAttribute::ON );
_reflectionCamera->getOrCreateStateSet()->setMode( GL_CULL_FACE, osg::StateAttribute::OFF );
_reflectionCamera->getOrCreateStateSet()->setAttributeAndModes(new osg::FrontFace(osg::FrontFace::CLOCKWISE), osg::StateAttribute::ON | osg::StateAttribute::PROTECTED);"
The fix is also working, if the front and backface are drawn normally and it
should also be helpfull if the backface is not drawn at all.
Original issue reported on code.google.com by marcel.p...@googlemail.com on 2 Jan 2012 at 2:50
Original issue reported on code.google.com by
marcel.p...@googlemail.com
on 2 Jan 2012 at 2:50Attachments: