I want to realize a scene (as solar system, same problem). As you can imagine, I have a clipping problem. Here's an example :
1.
My first cube (foreground) is clip (the second is far : 10^12).
I have searched why and I have read information about Z-Buffer :
2.
and
3.
After, I have read osg forum (and others google results) to find a solution :
- Change nearfarRatio. But change nearfarRatio doesn't solve clip problem and z-fighting problem at the same time, my scene is too big.
- Use osgDepthPartitionExample : It's very good solution and my cubes are exactly draw. But I want to draw line (as orbit) and it's catastrophic ! Line appear/disappear or shake when I move camera (rotate and zoom). Nevertheless, near and far for each camera seem to be good (next to each other). It's very annoying. I can post screen or video if you want to see.
Have you any explanation ? some solution ? (cut scene ? use 2 cameras and not 5 when i have lines ? use "osg normal render" and use one camera for foreground ? cut the scene background and project part cut onto far plan ? something else ? ... ?)
Thank you!
Cheers,
Clem
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=38775#38775
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
In svn/trunk and 2.9.11 onwards there is now support built into
osgViewer for doing depth partitioning, I haven't had a chance to roll
this into the old osgdepthpartition example yet though. You can see
the osgViewer depth partitition code in the osgshadow example so have
a look there, the osgViewer is simpler to manage than the
osgdepthpatition example as it moves the task into viewer
configuration, via multiple slave cameras, rather than scene graph
management.
Using osgViewer will simply you app, but it won't fix the precision
issues of objects in the scene. The way to solve there are to keep
geometry objects relative to their local origin and have a
MatrixTransform placed above them in the scene graph position them in
their final 3D position in space. The OSG's camera matrices and the
cull traversal of the projection and modelview matrices is all done in
doubles so it's able to handle large values of translation that will
cancel out when the camera is near to geometry.
Robert.
Thank you for the indication. I had some problem with osg upgrade (2.9.12) but it's ok (installation in my development environment and MatrixManipulator <-> CameraManipulator) !
osgShadows isn't a special depth partition example and I guess I don't understand everything (about how to use). In the case of osgDepthPartition Example, I've added DepthPartitionNode, which is at the top of my tree. Here, with osgViewer depth partition this isn't the same thing.
I use setUpDepthPartition() and with my implementation, I've some problem yet (with setGraphicsContext I guess).
I will consider it with serious and I'll seek help if needed.
I've created this post to say thank you and I'm interested in your answer. ;)
Cheers,
Clem
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=38824#38824
As I said, I've looked at osgViewer depth partitition and I've some problems. I'll give you as much information as possible and I hope you can help me.
First of all, I use OSG with Qt :
Code:
int main( int argc, char **argv )
{
QApplication a( argc, argv );
QWidget gloWgt;
gloWgt.setLayout(new QGridLayout());
3DSceneWidget* viewerWindow = new 3DSceneWidget;
gloWgt.layout()->addWidget(viewerWindow);
viewerWindow->addToScene(cube(9.0));
osg::setNotifyLevel(osg::DEBUG_FP);
viewerWindow->setUpDepthPartition();
viewerWindow->getCameraManipulator()->setCamera(osg::Vec3d(0.0,0.0,20.0),osg::Vec3d(0.0,0.0,8.0),osg::Vec3d(0.0,1.0,0.0));
gloWgt.setMinimumSize(1000, 800);
gloWgt.show();
a.connect( &a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()) );
return a.exec();
}
This main is very simple : some Qt objects, one viewer (3DSceneWidget), simple scene (a cube) and one camera movement. 3DSceneWidget allows the "connection" between the osgViewer and Qt.
Code:
class 3DSceneWidget : public osgViewer::Viewer, public QGLWidget
I've a problem with window resizing. Indeed, I've a segmentation fault when I launch my program. GDB (GNU Debugger) provides the following information :
Code:
(gdb) bt
#0 0x08504662 in osg::Viewport::setViewport (this=0x0, x=0, y=0, width=978, height=778) at /home/godel//OSG-2.9.12/LNX_gcc3.4/include/osg/Viewport:69
#1 0x08500e18 in 3DSceneWidget::resizeGL (this=0x9311980, width=978, height=778) at 3DSceneWidget.cxx:186
#2 0x088d106d in QGLWidget::resizeEvent ()
#3 0x08914019 in QWidget::event ()
#4 0x088a466b in QGLWidget::event ()
#5 0x088d651a in QApplicationPrivate::notify_helper ()
#6 0x088d6768 in QApplication::notify ()
#7 0x08ef8822 in QCoreApplication::notifyInternal ()
#8 0x0890e42b in QWidgetPrivate::sendPendingMoveAndResizeEvents ()
#9 0x0891575d in QWidgetPrivate::show_helper ()
#10 0x08915cbc in QWidget::setVisible ()
#11 0x089161f1 in QWidgetPrivate::showChildren ()
#12 0x08915774 in QWidgetPrivate::show_helper ()
#13 0x08915cbc in QWidget::setVisible ()
#14 0x084d7d04 in QWidget::show (this=0xbfffeda0) at /home/godel//QT-4.4.3/LNX_gcc3.4/include/QtGui/qwidget.h:464
#15 0x084d42cc in main (argc=1, argv=0xbfffee64) at main.cxx:120
So, I've looked at resizeGL :
Code:
void 3DSceneWidget::resizeGL( int width, int height )
{
_gw->getEventQueue()->windowResize(0, 0, width, height );
_gw->resized(0,0,width,height);
getCamera()->getViewport()->setViewport(0.0,0.0,width, height );
int numSlave = getNumSlaves();
for (int i=0; i < numSlave; i++)
{
getSlave(i)._camera->setViewport(0.0,0.0,width, height );
}
}
Indeed,
Code:
line 186 : getCamera()->getViewport()->setViewport(0.0,0.0,width, height );
have no sens. When I've used setUpDepthPartition(), cameraToPartition->setGraphicsContext(0) and cameraToPartition->setViewport(0) (line 1801/1802 in view.cpp, osg 2.9.12) do inoperable the main camera.
So, I've comment the line 186 but I've a render problem as if the resizing doesn't work with slave camera or as if I'm required to use the main camera.
I'm very disappointed because I want to solve my depth problem and I like this method.
I can give you information yet :
- With this horrible rendering, I've the following message for each frame :
Code:
cull_draw() 0xnumber
Warning: detected OpenGL error 'invalid enumerant' at after RenderBin::draw(..)
end cull_draw() 0xnumber
- I've this following message (by view.cpp) View::setUpDepthPartitionForCamera(..) Replacing main Camera
I've some questions anyway :
- Why do you not use the main camera for the first element of the partition ? Can I do this ? Do you think, it will solve my problem ?
- Do you think, slave cameras have a problem with rezising (without main camera) ?
I hope you can help me, it's very important ;)
Thank you!
Cheers,
Clem
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=38955#38955
Attachments:
http://forum.openscenegraph.org//files/render_196.png