Hi Hans,
have you tried other values for start/end, things like start=10, end=1000?
>From what I can see you're setting up a grid of objects in the range
x=-50..50, y=-50..50 so the grid is merely 100x100 units in size. Depending on
where your camera is (probably determined by the manipulator based on the
bounding sphere radius) your fog range may actually be further away than the
objects are.
The reason you're seeing results when using negative numbers could be down to
the way the fog parameter is calculated (for LINEAR):
f = (end - z) / (end - start)
So for an object at z=100 and start=-200 end=-300 you get
f = (-300 - 100) / (-300 - -200) = -400 / -100 = 4, clamped to 1.0
So you're seeing some fog, but not necessarily what you'd expect.
(I hope I'm making sense without my first cup of coffee. So please bear that in
mind if you're thinking "all wrong, that bloddy idiot" ;-)
Cheers,
/ulrich
Quoting "Elbers, H.P." <[EMAIL PROTECTED]>:
> Thank you all for comments so far!
>
> I did'n specify a source for fog coordinates.
> Adding the following made no difference:
> fog->setFogCoordinateSource(osg::Fog::FRAGMENT_DEPTH);
>
> I also added the following to be sure, no luck...
> state->setMode(GL_DEPTH_TEST,osg::StateAttribute::ON);
> state->setMode(GL_FOG, osg::StateAttribute::ON);
>
> The starnge thing is tha (linear) fog works fine when I do
> fog->setStart(-200.f); fog->setEnd(-300.f);
>
> But NOT when I do:
> fog->setStart(200.f); fog->setEnd(300.f);
>
> Recap: current settings:
>
> StateSet *state= world->getOrCreateStateSet();
> state->setMode(GL_DEPTH_TEST,osg::StateAttribute::ON);
> state->setMode(GL_FOG, osg::StateAttribute::ON);
>
> fog->setColor(Vec4(1.,0.,0., 1.)); // Red fog for testing
> fog->setDensity(0.);
> fog->setMode(Fog::LINEAR);
> fog->setStart(200.f); fog->setEnd(300.f); // Does not work
> fog->setStart(-200.f); fog->setEnd(-300.f); // Works
> fog->setFogCoordinateSource(osg::Fog::FRAGMENT_DEPTH);
> state->setAttributeAndModes(fog,StateAttribute::ON);
> > >>>
> > >>> Node *obj = osgDB::readNodeFile("obj.osg");
> > >>> if (obj) for (int i=-5; i<=5; i++) for (int j=-5; j<=5; j++) {
> > >>> PositionAttitudeTransform *T = new
> > PositionAttitudeTransform();
> > >>> world->addChild(T);
> > >>> T->setPosition(Vec3(10.*i, 10.*j, 0.));
> > >>> T->addChild(obj);
> > >>> }
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org