[osg-users] osgCal and osg::Fog

Vladimir Shabanov vshabanoff at gmail.com
Thu Oct 18 05:38:19 PDT 2007

2007/10/17, Laurent Di Cesare <laurent.dicesare at masagroup.net>:
> Hello,
> I am using osg to render a scene, and osgCal to display some character
> models.
> When I try to use osg::Fog in the scene, everything works fine except
> for characters rendered by osgCal: They seem to get fogged only when
> very far (lod?) but they aren't fogged at all when they are near.
> Does anyone have any pointer to why this doesn't work, or where I should
> be looking at? The stateset has been set with:
>         setAttribute( fog /* an osg::Fog */, osg::StateAttribute::ON );
>         setMode( GL_FOG, osg::StateAttribute::ON );
> on the osg::Group containing the character I try to render.
> Setting the mode to OVERRIDE or PROTECTED doesn't change the behaviour.
> I think I must set a FOG shader flag in the osgCal core model but it
> doesn't seem to be retrieved from the stateset.
> I'm a little lost in the osgCal code, but I can't find a way to set the
> shader_flag_fog there.
> HwMeshStateSetCache::createHwMeshStateSet seems not to read it from the
> stateset?

Hello, I've added possiblity of setting FOG shader flag at CoreModel load phase.
  CoreModel::load( cfgFileName, osgCal::CoreModel::FOG_EXP )
to get models with fog supported. Besides FOG_EXP you can use FOG_EXP2
or FOG_LINEAR flags. Currently it's not possible to enable/disable fog
dynamically for Model, only for CoreModel at load time. Fog parameters
are set using osg::Fog state attribute. Hope it helps.

More information about the osg-users mailing list