[osg-users] Problem with RTT, stereo and setViewport
Hi All, I'm facing some trouble with camera->setViewport breaking stereo in RTT. I am using OSG 2.8 and have a camera that renders a scene into a texture. The resulting image is a side by side rendering of the left and right camera views. When the texture is bigger than the camera's viewport, the camera only renders to a portion of the texture (expected) with stereo intact (attachment osg_ss1.jpg). When I set camera->setViewport with the new dimensions so that the camera renders to the whole of the texture, this breaks stereo and I only end up seeing the right camera's rendering in the texture. (attachment osg_ss2.jpg) I observe that this issue has been talked about a while back http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/2007-October/003617.html but the solution mentioned there does not seem to fix my problem. osgPrerender also reflects this problem. Any help or suggestions would be greatly appreciated. Thank you! Cheers, Arun -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53752#53752 Attachments: http://forum.openscenegraph.org//files/osg_ss2_133.jpg http://forum.openscenegraph.org//files/osg_ss1_173.jpg ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Questions about OSG
OSG works fine for my game so far: http://www.reallyslick.com/retrobooster/I'm making heavy use of model loading, textures, shaders, nodemasks, render bins, and deriving Drawables. The linear math classes are very useful outside of the scenegraph as well. The only serious rendering task I'm not using OSG for is particles. OSG has osgParticles, but I haven't looked at it for a few years. It might have more of what I require now. I'm also using SDL and SDL_mixer. Together with OSG, these libraries reliably provide most of the heavy lifting of other game engines. -- Terry Welsh www.reallyslick.com > > Is OSG suited for a game engine? > > > ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Questions about OSG
On 04/22/2013 11:24 PM, Sergey Kurdakov wrote: >scenegraphs are too expensive for games. it depends, but due to extensive use, scenegraphs like OSG are quite optimized for minimizing state changes, and thus there are games on smartphones and PCs which are based on OSG. The "scene graphs are too expensive for games" is one of the urban legend "wisdoms", unfortunately. This was true maybe back in the 90's when scene graph meant Performer or something VRML ... The paradox is that most game developers that refuse to use scene graphs end up reinventing them in their own code at some point. Or the middleware/engine they are using does it for them. >I only know that Ogre3d is using an scenegraph too. that is correct, and Ogre3d is used in many games. the difference is though with OSG - that Ogre3d rendering pipeline is not thread safe, so only one core is used for all graphics operations ( while OSG can use one or more threads), Ogre3d is just somehow more popular among those who develops games, because it has additional features which are useful when developing games, but OSG is more powerful in respect to rendering flexibility Also if you need/want OpenGL, forget Ogre3D. The OpenGL renderer in Ogre is horrid (put nicely). I did profile it (we are using Ogre3D at work too) and it is basically wasting 90% of frame time doing state changes that are redundant and have no effect - reloading and rebinding textures and shaders, recreating display lists for no reason, duplicating textures, etc. It is a very naively written renderer. The Direct3D one is better, it shows that the developers were more interested in that API. Also the OSG API is much cleaner and more orthogonal than what is in Ogre3D, but I guess that is a personal opinion. >I also saw that there are many different implementations of scenegraphs, like BSP octree etc. OSG is not about octree of BSP thought there are use samples see /"OpenSceneGraph/ 3 Cookbook" for octree and also there are examples for BSP use in osgBullet and Delta3D which are related to OSG. Also OSG has KdTree implementation BSP and octree are actually data structures, not scene graphs. Scene graph can use those, but doesn't have to - there are different ways to organize things and optimize traversals and culling. Regards, Jan ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Questions about OSG
Hi Mike, in respect to vao you might look at this thread http://forum.openscenegraph.org/viewtopic.php?t=10001 with initial attempt to add it. with this you get a core profile, >Are scenegraphs in general suited for games? yes, not all games use scenegraphs but most I know - do. >scenegraphs are too expensive for games. it depends, but due to extensive use, scenegraphs like OSG are quite optimized for minimizing state changes, and thus there are games on smartphones and PCs which are based on OSG. >I only know that Ogre3d is using an scenegraph too. that is correct, and Ogre3d is used in many games. the difference is though with OSG - that Ogre3d rendering pipeline is not thread safe, so only one core is used for all graphics operations ( while OSG can use one or more threads), Ogre3d is just somehow more popular among those who develops games, because it has additional features which are useful when developing games, but OSG is more powerful in respect to rendering flexibility >I also saw that there are many different implementations of scenegraphs, like BSP octree etc. OSG is not about octree of BSP thought there are use samples see * "OpenSceneGraph* 3 Cookbook" for octree and also there are examples for BSP use in osgBullet and Delta3D which are related to OSG. Also OSG has KdTree implementation You might want to look at http://www.packtpub.com/openscenegraph-3-0-beginners-guide/book?tag=ns/openscene-abr4/0211book to get more details. as for 'non' scene graph games - in fact almost all are using rendering library of some sort, it is just that they could be less general than proper scenegraph to make some features to run faster, but I'm not a specialist in non scene graphs games, so could not elaborate on it much. Regards Sergey ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Questions about OSG
Core profile requires use of vertex array objects, and currently OSG doesn't support VAO. As a result, OSG can't currently use core profile. This may change in the future, when someone submits a patch that adds VAO support. On Sun, Apr 21, 2013 at 11:09 AM, maik klein wrote: > I am studying computer graphics at my university and I have a few > questions about OSG. > > Does OSG use the core profile? > > Are scenegraphs in general suited for games? Yesterday my professor said > that scenegraphs are too expensive for games. (because of many state > changes) Unfortunately he didn't mention an alternative. I also couldn't > find any information about this topic. I only know that Ogre3d is using an > scenegraph too. I also saw that there are many different implementations of > scenegraphs, like BSP octree etc. > > Is OSG suited for a game engine? > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=53714#53714 > > > > > > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > -- Paul Martz Skew Matrix Software LLC ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [Post-installation] wrong ELF class: ELFCLASS64
Hi Alain, perhaps you are linking a 32 bit application to a 64 bit library Martino 2013/3/1 Alain P > Hi all, > > I've a problem when I try to run a program which use OSG: > > "error while loading shared libraries: libOpenThreads.so.13: wrong ELF > class: ELFCLASS64" > > before that, i had to update my LD_LIBRARY_PATH and add /usr/lib, else > shared libraries wasn't found. > > I use debian (64bits). > > What I have to change to be able to get out this error ? > > Thanks in advance (and excuse my english...) > > Cheers, > Alain > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=52924#52924 > > > > > > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How do remove a node's built in offset?
Paul Martz wrote: > You could translate them with the .trans pseudoloader:osgconv > infile.ive.(-x,-y,-z).trans outfile.ive > > > I'm not sure that's the right syntax for the .trans pseudoloader, but you can > check the source code in src/osgPlugins/trans. > > > > On Mon, Apr 22, 2013 at 12:00 PM, Joshua Cook < ()> wrote: > > > Ok, so I have a set of IVE files and each one of them has some sort built > > in offset. For example: a cube with a center of X, Y, Z. I really would > > love to be able to save these off as an IVE with a center of 0, 0, 0. > > > > My Google-Fu is weak today, master, and I humbly request assistance with > > this problem. > > > > Thanks, > > soulsabr > > > > -- > > Read this topic online here: > > http://forum.openscenegraph.org/viewtopic.php?p=53725#53725 > > (http://forum.openscenegraph.org/viewtopic.php?p=53725#53725) > > > > > > > > > > > > ___ > > osg-users mailing list > > () > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org) > > > > > > > -- > Paul Martz > Skew Matrix Software LLC > > -- > Post generated by Mail2Forum I have never heard of this thing. I shall check it out post haste. Thanks for your suggestions. I'll let you know if it works. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53746#53746 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Height of the terrain on a given lang/long
Hi Shayne, S2LR wrote: > A couple of questions so that I have a clear understanding... > > 1) Why would you want to have the lower LODs available for doing collision > tests? You always want the highest LOD for doing intersection tests with the > terrain. I am trying to compute two functions. First function will find height of the terrain for a given lat/lon value. Second function will find all the intersection points of a ray with the terrain. Therefore I need to know all lower LODs of the terrain. > 2) What are you using for doing the LOS check between the line and the > terrain? Are you using your code snippet that you posted earlier or are you > using osgSim? I am using osgSim. I am checking all the intersection points with the terrain between two points. So, I can not get all intersection points If osg does not read lower LODs of the terrain. I tried moving camera to the area of the these points in the view based sample and Osg could read all lower LODs in this area, I got all the intersection points of a ray. I hope you understand my problem and there is a solution for it in the Osg. Regards -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53745#53745 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] culling and vertex shaders still a problem
Agreed, keeping Geometry out of the scene graph's inherent desire to deal with it as spatial data is a serious issue in OSG. One solution would be to disable culling on the Geode (as you did above) and place it under its own dedicated Camera. Kind of heavyweight, though. Another possibility would be to draw your Geometry from a post-draw callback, but I haven't tried this. On Sun, Apr 7, 2013 at 5:07 AM, Anton Fuhrmann wrote: > Hi, > > I need to disable culling on a geode which implements a skydome/plane as a > shader. > > The problem is that the vertex shader places the existing vertices > screen-aligned at the far plane, but OSG still thinks they are in their > original positions. > > This problem as already been discussed - but not conclusively solved - in > other threads: > (cannot post URLs at the moment) > viewtopic.php?t=20300 > viewtopic.php?t=10912 > > For this situation, disabling the culling is necessary because I do not > want the scene to include the "real" positions of the sky plane at > "infinity". It would defy near/far calculation and I would need to > introduce a callback that recalculates the positions outside the vertex > shader just so that the skydome node does not get clipped. > > I already tried > Code: > Geode->setCullingActive(false) > > and > Code: > Camera()->setCullingMode( osg::CullSettings::NO_CULLING ) > > > but both cull my node as soon as the original vertex positions are behind > the camera. > > My workaround at the moment is to set the initial bounds very large, but > this is unnecessarily inflates the BBox of the real scene. > > Any suggestions would be appreciated! > > ... > > Thank you! > > Cheers, > Anton > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=53481#53481 > > > > > > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > -- Paul Martz Skew Matrix Software LLC ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Can't run osgpointsprite.cpp example - std::bad_alloc at memory location
Hi, When I try to debug the osgpointsprites.cpp example, it builds fine, but I can't run it, I get a bad allocation memory error in xstring. What would be causing this or how can I get around it to run this code and view the result? Thank you! Cheers, Grace -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53448#53448 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Creating Custom Render Loop with the Leap Motion?
Hi, I am currently trying to implement camera control with the Leap Motion in an OpenSceneGraph world. However, the Leap has it's own frame function, like the OSG viewer. Naturally, when I run both frame loops, they are not asynchronous. They happen sequentially. I would like to set it up so that the graphics update in my Leap frame loop; if this isn't possible, I would like to set it up so that both loops are asynchronous and the Leap frames can send data to the viewer frames to update the camera. In my attempt to create a custom loop, mouse input is no longer recognized--the renderer / window freezes, but the Leap keeps obtaining new frames in the console. (Two windows appear when I run my program, the window with the OSG world and a console window that outputs Leap data). If you want to look at the code I actually use, it's below. Here's an example of setting up the Leap for a frame loop. Code: // Have the sample listener receive events from the controller controller.addListener(listener); // Keep this process running until Enter is pressed std::cout << "Press Enter to quit..." << std::endl; std::cin.get(); // Remove the sample listener when done controller.removeListener(listener); Here's an example of my attempt to update the scene within the Leap frame: Code: void SampleListener::onFrame(const Leap::Controller& controller) { // Get the most recent frame and report some basic information const Leap::Frame frame = controller.frame(); std::cout << "Frame id: " << frame.id() << ", timestamp: " << frame.timestamp() << ", hands: " << frame.hands().count() << ", fingers: " << frame.fingers().count() << ", tools: " << frame.tools().count() << ", gestures: " << frame.gestures().count() << std::endl; if(LeapFramesRunning) //LeapFramesRunning is true { viewer.frame(); } if (!frame.hands().empty()) { // Get the first hand const Leap::Hand hand = frame.hands()[0]; // Check if the hand has any fingers const Leap::FingerList fingers = hand.fingers(); if (!fingers.empty()) { // Calculate the hand's average finger tip position Leap::Vector avgPos; for (int i = 0; i < fingers.count(); ++i) { avgPos += fingers[i].tipPosition(); } avgPos /= (float)fingers.count(); std::cout << "Hand has " << fingers.count() << " fingers, average finger tip position" << avgPos << std::endl; } // Get the hand's sphere radius and palm position std::cout << "Hand sphere radius: " << hand.sphereRadius() << " mm, palm position: " << hand.palmPosition() << std::endl; // Get the hand's normal vector and direction const Leap::Vector normal = hand.palmNormal(); const Leap::Vector direction = hand.direction(); // Calculate the hand's pitch, roll, and yaw angles std::cout << "Hand pitch: " << direction.pitch() * Leap::RAD_TO_DEG << " degrees, " << "roll: " << normal.roll() * Leap::RAD_TO_DEG << " degrees, " << "yaw: " << direction.yaw() * Leap::RAD_TO_DEG << " degrees" << std::endl; } // Get gestures const Leap::GestureList gestures = frame.gestures(); for (int g = 0; g < gestures.count(); ++g) { Leap::Gesture gesture = gestures[g]; switch (gesture.type()) { case Leap::Gesture::TYPE_CIRCLE: { Leap::CircleGesture circle = gesture; std::string clockwiseness; if (circle.pointable().direction().angleTo(circle.normal()) <= Leap::PI/4) { clockwiseness = "clockwise"; } else { clockwiseness = "counterclockwise"; } // Calculate angle swept since last frame float sweptAngle = 0; if (circle.state() != Leap::Gesture::STATE_START) { Leap::CircleGesture previousUpdate = Leap::CircleGesture(controller.frame(1).gesture(circle.id())); sweptAngle = (circle.progress() - previousUpdate.progress()) * 2 * Leap::PI; } std::cout << "Circle id: " << gesture.id() << ", state: " << gesture.state() << ", progress: " << circle.progress() << ", radius: " << circle.radius() << ", angle " << sweptAngle * Leap::RAD_TO_DEG << ", " << clockwiseness << std::endl; break; } case Leap::Gesture::TYPE_SWIPE: { Leap::SwipeGesture swipe = gesture; std::cout << "Swipe id: " << gesture.id() << ", state: " << gesture.state() << ", direction: " << swipe.direction() << ", speed: " << swipe.speed() << std::endl; break; } case Leap::Gesture::TYPE_KEY_TAP: { Leap::KeyTapGesture tap = gesture; std::cout << "Key Tap id: " << gesture.id() << ", state: " << gesture.state() << ", position: " << tap.position()
[osg-users] [3rdparty] Removing a View from Scene
Hi, I set up multiple views in a sence.I need to use keyboarding to remove one of them. Please,how to achieve it in Visual Studio 2008 . Thank you! Cheers, Andy -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53498#53498 /** *Write by FlySky *zz...@163.com http://www.OsgChina.org **/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //¶¯Ì¬É¾³ýÊÓͼ´°¿Ú class DeletSlaveView:public osgGA::GUIEventHandler { public: bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&aa ) { osg::ref_ptr view = dynamic_cast(&aa); osg::ref_ptr viewer = dynamic_cast(view->getViewerBase()); switch(ea.getEventType()) { case osgGA::GUIEventAdapter::KEYDOWN: { if (ea.getKey()=='q') { //viewer->stopThreading(); viewer->removeView(view); //viewer->startThreading(); } } break; default: break; } return false; } }; int main() { //´´½¨CompositeViewer¶ÔÏó osg::ref_ptr viewer = new osgViewer::CompositeViewer() ; //¶ÁÈ¡Å£µÄÄ£ÐÍ osg::ref_ptr cow = osgDB::readNodeFile("cow.osg") ; //¶ÁÈ¡·É»úÄ£ÐÍ osg::ref_ptr cessna = osgDB::readNodeFile("cessna.osg"); //ÓÅ»¯³¡¾°Êý¾Ý osgUtil::Optimizer optimizer ; optimizer.optimize(cow.get()); optimizer.optimize(cessna.get()); //ÉèÖÃͼÐλ·¾³ÌØÐÔ osg::ref_ptr traits = new osg::GraphicsContext::Traits(); traits->x = 100; traits->y = 100; traits->width = 900; traits->height = 700; traits->windowDecoration = true; traits->doubleBuffer = true; traits->sharedContext = 0; //´´½¨Í¼Ðλ·¾³ÌØÐÔ osg::ref_ptr gc = osg::GraphicsContext::createGraphicsContext(traits.get()); if (gc->valid()) { osg::notify(osg::INFO)<<" GraphicsWindow has been created successfully."setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } else { osg::notify(osg::NOTICE)<<" GraphicsWindow has not been created successfully."< view = new osgViewer::View; viewer->addView(view.get()); //ÉèÖÃÊÓͼ³¡¾°Êý¾Ý view->setSceneData(cow.get()); //ÉèÖÃÏà»úÊÓ¿Ú¼°Í¼Ðλ·¾³ view->getCamera()->setViewport(new osg::Viewport(0,0, traits->width/2, traits->height/2)); view->getCamera()->setGraphicsContext(gc.get()); //ÉèÖòÙ×÷Æ÷ view->setCameraManipulator(new osgGA::TrackballManipulator); //Ìí¼Óʼþ´¦Àí view->addEventHandler( new osgViewer::StatsHandler ); view->addEventHandler( new osgViewer::WindowSizeHandler ); view->addEventHandler( new osgViewer::ThreadingHandler ); view->addEventHandler( new osgViewer::RecordCameraPathHandler ); } //ÊÓͼ¶þ { osg::ref_ptr view = new osgViewer::View; viewer->addView(view.get()); view->setSceneData(cessna.get()); view->getCamera()->setViewport(new osg::Viewport(traits->width/2,0, traits->width/2, traits->height/2)); view->getCamera()->setGraphicsContext(gc.get()); view->setCameraManipulator(new osgGA::TrackballManipulator); } //ÊÓͼÈý { osg::ref_ptr view = new osgViewer::View; viewer->addView(view.get()); view->setSceneData(cessna.get()); //¸ù¾Ý·Ö±æÂÊÀ´È·¶¨ºÏÊʵÄͶӰÀ´±£Ö¤ÏÔʾµÄͼÐβ»±äÐÎ double fovy, aspectRatio, zNear, zFar; view->getCamera()->getProjectionMatrixAsPerspective(fovy, aspectRatio, zNear, zFar); double newAspectRatio = double(traits->width) / double(traits->height/2); double aspectRatioChange = newAspectRatio / aspectRatio; if (aspectRatioChange != 1.0) { view->getCamera()->getProjectionMatrix() *= osg::Matrix::scale(1.0/aspectRatioChange,1.0,1.0); } view->getCamera()->setViewport(new osg::Viewport(0,traits->height/2, traits->width, traits->height/2)); view->getCamera
Re: [osg-users] build osgmotionblur
Hello, Another question though: I'd like to change osgmotionblur.cpp behavior so that not-fading-out equally-time-spaced "shots" of my moving object are left behind, kind of like a trail. My first attempt has been to keep ALL object positions behind. If this works, I can try to filter the positions I keep. I've played around with glAccum without success. My attempt looks something like: Code: // Original //glAccum(GL_MULT, s); //glAccum(GL_ACCUM, 1 - s); //glAccum(GL_RETURN, 1.0f); // My attempt glAccum(GL_MULT, 1.0f); glAccum(GL_ACCUM, 0.0f); glAccum(GL_RETURN, 1.0f); I wonder if it's possible to do it this way... Any help is appreciated. Thanks, Alfonso[/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53540#53540 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Driving 3D and 2D display by just rendering one time
Hi All, I want to drive two outputs. One output is 120hz 3D capable while other is 60HZ (2D capable). I thought of two approaches for obtaining this scenario. First : Render the scene graph two times one with 120Hz and other with 60HZ. This seems fine but here every computation is happening two times. Second Approach: Render the scene graph with 120HZ( Having both left and right frames) and just extract the left or right frame and give this as input to second display. I am not sure whether something like approach 2 can be done or not. Please guide me in this regard and suggest if there is a better way of obtaining the same result. ... Thank you! Cheers, Abhinav -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53585#53585 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] How to Node& = Node*
Hi, 1st of all I have to apologize for my english, this is not my native language. Let's go to the point. I'm trying to match a osg::Node* into a osg::Node&, but I'm having some troubles. My code is like: Code: void function(osg::Node& node){ ... osg::Node *n = (something that returns a pointer to an osg::Node) ¿node = n? ... } The thing is that I want to return that *Node into the &Node, and it must be like this because this is not my code, they gave me the function with the Node& argument and the function with the Node* return, so i have to take that Node* and match it into a Node&. I have tried to do the same thing I do with and int: Code: int a; int *b; a=*b; But I'm having that error: > Error 1 error C2248: 'osg::Object::operator =' : cannot access private member declared in class 'osg::Object' Can anyone help me, please? Thank you! Cheers, Oscar -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53610#53610 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How do remove a node's built in offset?
You could translate them with the .trans pseudoloader: osgconv infile.ive.(-x,-y,-z).trans outfile.ive I'm not sure that's the right syntax for the .trans pseudoloader, but you can check the source code in src/osgPlugins/trans. On Mon, Apr 22, 2013 at 12:00 PM, Joshua Cook wrote: > Ok, so I have a set of IVE files and each one of them has some sort built > in offset. For example: a cube with a center of X, Y, Z. I really would > love to be able to save these off as an IVE with a center of 0, 0, 0. > > My Google-Fu is weak today, master, and I humbly request assistance with > this problem. > > Thanks, > soulsabr > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=53725#53725 > > > > > > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > -- Paul Martz Skew Matrix Software LLC ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Hello
Hi, I'm new member of this forum and interested to share with others member. Thank you! Cheers, sharior -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53618#53618 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] About RTT
Hi, I create the scene like this: the root node is SceneRoot, a hud node is HUDCamera, a render-to-texutre node is RTTCamera, also a model root which is added as child to RTTCamera, then i add a model node to ModelRoot. Now I create a texture image attached to RTTCamera, and I render it to a quad as texture stateset on HUDCamera. The whole scene runs ok. Then i add a PickEventHandle to the osgViewer, the scene also runs right, but it stops when i click the scene everywhere, just like that it is deathlock. SceneRoot | | | RTTCamera -- ModelRoot HUDCamera | ModelNode I really do not know about it, and hope somebody can help me. Thank you! Cheers, -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53623#53623 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
osg-users@lists.openscenegraph.org
Hi, 1st of all I have to apologize for my english, this is not my native language. Let's go to the point. I'm trying to match a osg::Node* into a osg::Node&, but I'm having some troubles. My code is like: Code: void function(osg::Node& node){ ... osg::Node *n = (something that returns a pointer to an osg::Node) ¿node = n? ... } The thing is that I want to return that *Node into the &Node, and it must be like this because this is not my code, they gave me the function with the Node& argument and the function with the Node* return, so i have to take that Node* and match it into a Node&. I have tried to do the same thing I do with and int: Code: int a; int *b; a=*b; But I'm having that error: > Error 1 error C2248: 'osg::Object::operator =' : cannot access private member declared in class 'osg::Object' Can anyone help me, please? Thank you! Cheers, Xermi -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53630#53630 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] OSG Render Thread in Qt: Access to scene data from main app thread
u may try to set viewer's threading model as CullThreadPerCameraDrawThreadPerContext, i think it will help u. [quote="Pertur"]Hi Robert, So if I have a class where I describe the scene content and where I do changes in real time int update function like this: [code] DemoOSGScene.h /*! Cidetec data osg scene class */ class DemoOSGScene: public OSGScene { public: //! An DemoOSGScene constructor. /*! A more elaborate description of the constructor. */ DemoOSGScene(); //! An DemoOSGScene destructor. /*! A more elaborate description of the destructor. */ ~DemoOSGScene(void); /** \fn osgGenerals::OSGGroup* getSceneGroup() Return the scene group \return osgGenerals::OSGGroup */ osg::Group* getSceneGroup() { return _rootGroup; }; /** \fn void update() Update scene necesary values \return */ virtual void update(); void initialize(); protected: float getDistanceBetweenObjs(osg::Vec3 obj1, osg::Vec3 obj2); osg::MatrixTransform* _mainObject; std::vector_sceneObjectsContainer; osg::Vec3 _mainObjectV; //main object velocity vector int _dificulLevel; float _nextObject; osg::Node* _manzana; }; [/code] and the cpp [code] DemoOSGScene::DemoOSGScene() { _type = DEMO; _rootGroup = new osg::Group(); _rootGroup->setDataVariance( osg::Object::DYNAMIC ); //define scene camera positions LookAtCamera camera0 = {osg::Vec3f(0.0, 0.0,0.0), osg::Vec3f(0.0,100.0,100.0), osg::Vec3f(0.0,0.0,1.0)}; addCameraPos(camera0); //lights _rootGroup->addChild(osgGenerals::createLight(osg::Vec3(50.0,200.0,200.0), osg::Vec4(0.9,0.9,0.9,1.0))); //load scene models ... _dificulLevel = 1; _simulTime = 0.0; } DemoOSGScene::~DemoOSGScene(void) { } void DemoOSGScene::initialize() { _nextObject = 3.0; _mainObjectV.set(0.0,0.0,0.0); _sessionScore = 0.0; //clean object container for(int i=0;i<_sceneObjectsContainer.size();i++) { _rootGroup->removeChild(_sceneObjectsContainer[i].node); _sceneObjectsContainer.erase(_sceneObjectsContainer.begin()+i); i--; } _mainObject->setMatrix(osg::Matrix::translate(osg::Vec3(mainObjectInitPos[0],mainObjectInitPos[1],mainObjectInitPos[2]))); } void DemoOSGScene::update() { float delta = _simulTime - preSimulTime; //update objects position { ... } //verify scene object collisions { ... } //create or delete objects { ... } preSimulTime = _simulTime; } [/code] So in update function I need access to _rootGroup, _sceneObjectsContainer... I have found this solution: [code] class UpdateRootCallback : public osg::Drawable::UpdateCallback { public: virtual void update( osg::NodeVisitor* nv, osg::Drawable* drawable ) { ... } }; _rootGroup->setDataVariance( osg::Object::DYNAMIC ); _rootGroup->setUpdateCallback( new UpdateRootCallback ); [/code] But I need to pass my objects pointers from DemoOSGScene... and I don't know how to put thread access control for the objects... Is this the best solution? Maybe I should redesign the system... Thank you! Cheers, Aitor Edit: I modify the code to integrate de update callback into DemoOSGScene, and I change osg::Drawable::UpdateCallback for osg::NodeCallback (update(...) for operator()(...)). So I have total access to members. Assuming that I only going to modify objects in the function operate (), the only problem I see is the variable _simulTimer, which is modified in the main thread and read in the render thread.[/quote] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53631#53631 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [vpb] VPBmaster consumes over 16GB of RAM
Hello all, I'm having some significant problems using VPB processing extremely large datasets. For this example, we'll take a look at the ASTER dataset which comprises 528.2GB of data split among 21,844 GeoTIFFs. The first problem I had was an error about too many open file handles. I upped the allowable number of open files from 4096 to 65536 through PAM and limits.conf. No longer do I receive errors pertaining to open file limit issues, but now I'm seeing vpbmaster consuming over 16GB of system RAM when trying to generate databases (16GB is the amount of available RAM I have on the system, so it typically starts eating into significant SWAP and slows the system to a crawl). Is there a method to help limit vpbmaster from consuming that much RAM during normal use? Question two: I've attempted to process just one hemisphere at a time (North and South separately) to avoid issues with the out of memory, and it seemed to work great (only consumed about 4GB of RAM at any time). I pointed vpbmaster to a directory with only Northern hemisphere items, and the processing commenced normally. But, it began failing and blacklisting all of the cores as soon as it started processing southern hemisphere items. I was using the command > vpbmaster --geocentric --terrain -d /path/to/northernhemisphere -O > Compressor=zlib -o output.osgb Anyway, I decided to look in the code, and I commented out the blacklist command in the MachinePool.cpp and uncommented the IGNORE_FAILED_TASK, and everything worked fine from that point forward. Is there a reason that blacklisting is the first thing VPB goes to? Am I doing something wrong by allowing it to just ignore the failed tile and move on? Thanks so much, I'd love to hear your inputs! Arthur -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53677#53677 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Questions about OSG
I am studying computer graphics at my university and I have a few questions about OSG. Does OSG use the core profile? Are scenegraphs in general suited for games? Yesterday my professor said that scenegraphs are too expensive for games. (because of many state changes) Unfortunately he didn't mention an alternative. I also couldn't find any information about this topic. I only know that Ogre3d is using an scenegraph too. I also saw that there are many different implementations of scenegraphs, like BSP octree etc. Is OSG suited for a game engine? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53714#53714 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osg::Image pixel format conversion
i can think of that,thanks to my image convert (http://www.rasteredge.com/how-to/vb-net-imaging/), i am praised by my emplyer. :D -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53524#53524 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How convert osg::Image to OpenCV IplImage
wo,thanx for showing that to us -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53523#53523 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Image formats, most efficient?
finally, smomeone solve my problem thakx -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53522#53522 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [forum] use VPB osgdem to build the terrain, how to get actual projection coordinates of model in osg appalication
Hi, Original coordinate of tif file is the longitude and latitude coordinates,Use gdalwarp converts to merctor projection: gdalwarp -t_srs “+proj=merc +datum=WGS84” 0-40.tif merctor.tif, merctor.tif, Then use osgdem to make merctor. tif generate planar model: osgdem --cs “+proj=merc +datum=WGS84” –xx 10 –yy 10 –v 0.5 –l 3 –o merctor.ive And then load the merctor.ive in osg appalication,and use osgpick to pick up the model as following: osg::ref_ptr viewer = new osgViewer::Viewer; osg::ref_ptrgroup=new osg::Group; osg::ref_ptr node= osgDB::readNodeFile("merctor.ive"); osg::ref_ptr csn=new osg::CoordinateSystemNode; csn->setEllipsoidModel(new osg::EllipsoidModel); csn->addChild(node); csn->setFormat("PROJ4"); csn->setCoordinateSystem("+proj=merc +datum=WGS84"); osg::ref_ptr updatetext = new osgText::Text(); CreateHUD *hudText= new CreateHUD(); csn->addChild(hudText->createHUD(updatetext.get())); viewer->setSceneData(csn); viewer->addEventHandler(new osgViewer::WindowSizeHandler); viewer->addEventHandler(new osgViewer::StatsHandler); viewer->addEventHandler(new CPickHandler(updatetext.get())); //pick as follows: if (viewer->computeIntersections(x,y,intersections)) { osg::ref_ptr csn=dynamic_cast(viewer->getSceneData()->asGroup()); osg::EllipsoidModel* em=csn->getEllipsoidModel(); for(osgUtil::LineSegmentIntersector::Intersections::iterator hitr = intersections.begin();hitr != intersections.end();++hitr) { os<<"Mouse in World X:"<< hitr->getWorldIntersectPoint().x()<<"Y: "<< hitr->getWorldIntersectPoint().y()<<"Z: "<< hitr->getWorldIntersectPoint().z()getWorldIntersectPoint().x(),hitr->getWorldIntersectPoint().y(),hitr->getWorldIntersectPoint().z(),y,x,z); os getWorldIntersectPoint()); os
[osg-users] [osgPlugins] How to add Animations stored in Fbx to another Fbx model
Hi, we bought severall Models in .fbx with Animations. Most of the Animations lie in seperated .Fbx files. How can i add the Animations out of an .fbx file(with no Model included) to another Model out of another .fbx file? Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53489#53489 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] FBX only Black Texture shown
Hi, I fixed the issue by importing the Models in 3ds Max and there i changed the diffuse Color from black to white and everything works. But what do i do when i don't own such a software and just buy some Models. Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53488#53488 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [forum] RenderBin number for LightPointNode
Hi, I noticed the constructor for LightPointNode places the node in DepthSortedBin number 20. I can understand the general case for this, however when placing it after the default transparency bin (DepthSortedBin number 10) light points on helicopters don't get drawn when behind the transparent textures for rotors. The comment in the constructor for LightPointNode just states that it should be drawn well after the transparent bin. Can you tell me the reasoning for this? Is it acceptable to change the bin for the LightPointNode on specific geometries, or has anyone experienced problems with this? Thank you! Cheers, JP -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53174#53174 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [Post-installation] wrong ELF class: ELFCLASS64
Hi all, I've a problem when I try to run a program which use OSG: "error while loading shared libraries: libOpenThreads.so.13: wrong ELF class: ELFCLASS64" before that, i had to update my LD_LIBRARY_PATH and add /usr/lib, else shared libraries wasn't found. I use debian (64bits). What I have to change to be able to get out this error ? Thanks in advance (and excuse my english...) Cheers, Alain -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=52924#52924 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] culling and vertex shaders still a problem
Hi, I need to disable culling on a geode which implements a skydome/plane as a shader. The problem is that the vertex shader places the existing vertices screen-aligned at the far plane, but OSG still thinks they are in their original positions. This problem as already been discussed - but not conclusively solved - in other threads: (cannot post URLs at the moment) viewtopic.php?t=20300 viewtopic.php?t=10912 For this situation, disabling the culling is necessary because I do not want the scene to include the "real" positions of the sky plane at "infinity". It would defy near/far calculation and I would need to introduce a callback that recalculates the positions outside the vertex shader just so that the skydome node does not get clipped. I already tried Code: Geode->setCullingActive(false) and Code: Camera()->setCullingMode( osg::CullSettings::NO_CULLING ) but both cull my node as soon as the original vertex positions are behind the camera. My workaround at the moment is to set the initial bounds very large, but this is unnecessarily inflates the BBox of the real scene. Any suggestions would be appreciated! ... Thank you! Cheers, Anton -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53481#53481 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Height of the terrain on a given lang/long
I'm still not clear on what you're trying to accomplish. I thought you were trying to get HOT for a given lat/lon pair. In this case, there's only one intersection. From your last post, it sounds like you're tying find intersections with the terrain for a given LOS between two points. Is this true? A couple of questions so that I have a clear understanding... 1) Why would you want to have the lower LODs available for doing collision tests? You always want the highest LOD for doing intersection tests with the terrain. 2) What are you using for doing the LOS check between the line and the terrain? Are you using your code snippet that you posted earlier or are you using osgSim? You should be using the methods in osgSim because it pages in all the tiles you need to check for intersections between two points in the case of LOS on terrain. The highest LOD for each tile that lies between the two points is what you need for intersection testing... Shayne -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53726#53726 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] How do remove a node's built in offset?
Ok, so I have a set of IVE files and each one of them has some sort built in offset. For example: a cube with a center of X, Y, Z. I really would love to be able to save these off as an IVE with a center of 0, 0, 0. My Google-Fu is weak today, master, and I humbly request assistance with this problem. Thanks, soulsabr -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53725#53725 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Multipass rendering with shader
Hi Andrea, First of all there several errors. The first one is where you assign the texture as input to your stateset: for making this work you should write this: secondStateset->addUniform(new osg::Uniform("previousTexture",0)); secondStateset->setTextureAttributeAndModes(0,previousTexture, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); Note the first line using the value 0 to bind the sampler to the same texture unit (0) Secondly, for your test you are using a model without texture coordinates. This of course will not work if you want to use the gl_TexCoord attributes. So try with another model if you need them. Another problem was with your 2nd pass vertex/fragemt shader: Either you'll have to use the built-in gl_TexCoord and write to in the vertex shader, or u have to use your varying "texture_coordinate" In your example you are writing the varying "texture_coordinate" in your vertex shader and reading the built-in (which you don't write to) in the fragment shader. The result is surely not what you expected, but at least it is somehow projecting the result of the first frame to your model. I've taken the freedom to modify your shader a bit, but you'll still have to re-project the fragments to get the correct result if I understood you correctly. I'm still wondering what you are trying to achieve exactly. If there are further question, you can contact me directly via email Attached you'll find the fixed sources: #include #include #include #include #include #include #include #include #include #include // // Vertex shader pass 0 : Color // char vertexShaderSourcePass_0[] = "varying vec4 COLOR;\n" "\n" "varying vec2 texcoord;\n" "\n" "void main(void)\n" "{\n" "COLOR = gl_Color;\n" "gl_Position = ftransform();\n" "}\n"; // // fragment shader pass 0 : Color // char fragmentShaderSourcePass_0[] = "varying vec4 COLOR; \n" "\n" "void main(void) \n" "{\n" "vec4 newcolor = COLOR;\n" "COLOR.r = newcolor.b/2;\n" "COLOR.g = newcolor.r/3;\n" "COLOR.b = newcolor.g + 0.1;\n" "gl_FragColor = COLOR; \n" "}\n"; // // Vertex shader pass 1 : TWIST // char vertexShaderSourcePass_1[] = "uniform float time;\n" "uniform float height;\n" "uniform float angle_deg_max;\n" "\n" "varying vec2 texture_coordinate;\n" "varying vec4 normal, lightDir[3], eyeVec;\n" "\n" "vec4 DoTwist( vec4 pos, float t )\n" "{\n" "float st = sin(t);\n" "float ct = cos(t);\n" "vec4 new_pos;\n" "\n" "new_pos.x = pos.x*ct - pos.z*st;\n" "new_pos.z = pos.x*st + pos.z*ct;\n" "new_pos.y = pos.y;\n" "new_pos.w = pos.w;\n" "return( new_pos );\n" "}\n" " void main()\n" "{ \n" " float angle_deg = angle_deg_max*sin(time);\n" " float angle_rad = angle_deg * 3.14159 / 180.0;\n" " float ang = (height*0.5 + gl_Vertex.y)/height * angle_rad;\n" " vec4 twistedPosition = DoTwist(gl_Vertex, ang);\n" " // vec4 twistedNormal = DoTwist(vec4(gl_Normal, ang);\n" " gl_Position = gl_ModelViewProjectionMatrix * twistedPosition;\n" " vec3 vVertex = vec3(gl_ModelViewMatrix * twistedPosition);\n" " // lightDir[0] = vec3(gl_LightSource[0].position.xyz - vVertex);\n" " // lightDir[1] = vec3(gl_LightSource[1].position.xyz - vVertex);\n" " // lightDir[2] = vec3(gl_LightSource[2].position.xyz - vVertex);\n" " // eyeVec = -vVertex;\n" " // normal = gl_NormalMatrix * twistedNormal.xyz;\n" " gl_TexCoord[0] = gl_MultiTexCoord0;\n" " texture_coordinate = vec2(gl_MultiTexCoord0);\n" " //gl_Position = ftransform();\n" "}\n"; // // fragment shader pass 1 : TWIST // char fragmentShaderSourcePass_1[] = "uniform sampler2D previousTexture; \n" "varying vec2 texture_coordinate;\n" "\n" "void main(void) \n" "{\n" " vec4 somecolor = texture2D(previousTexture, gl_FragCoord.xy / vec2(1024.0,512.0));\n" " gl_FragColor = somecolor; \n" "}\n"; /*! * \fn osg::Camera* createHUDCamera( double left, double right, double bottom, double top ) * \brief Create an HUD Camera (as Post Render). Contains the result of the shader multiple pass * this code coming from openscenegraph 3 cookbook */ osg::Camera* createHUDCamera( double left, double right, double bottom, double top ) { osg::ref_ptr camera = new osg::Camera; camera->setReferenceFrame
[osg-users] Syncronized animation
Hi, I have to develop the animation of several object based on GPS time ( GPS tracking) Is there an easy way to synchronize all tracks? I saw that with "AnimationPathCallback" each object time start when I create it .. so not what I want. Thank you! Cheers, Tonino -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53723#53723 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Shadowed scene distortion after 3rd window recreation
I've found out that the glitches are fixed by simply recreating ShadowTechnique (SoftShadowMap). If anyone is interested, here's the working example: https://dl.dropboxusercontent.com/u/12634473/osg/osg_recreate_window_fixed.tar.bz2 2013/4/21 michael kapelko > For those who only read forum, here's the link to the full source code: > https://dl.dropboxusercontent.com/u/12634473/osg/osg_recreate_window.tar.bz2 > > 2013/4/20 michael kapelko > >> Hi. >> I'm implementing video settings change (and thus window recreation) in my >> game without game restart. I experience graphics glitches after re-running >> Viewer 3rd time: http://youtu.be/xOgTjENn2MM >> >> I recreate the window the following way: >> * Stop the viewer, stop threading. >> * Create new graphics context and attach it to the camera. >> * Run the viewer again. >> >> As seen in the video, ShadowedScene does not survive the 3rd Viewer >> restart and there appear some OpenGL errors in the logs. >> >> Can anybody help me, please? >> Thanks. >> >> PS: Full source code is attached to the mail, uses CMake and needs >> OpenSceneGraph-Data to run (dumptruck model), Page down recreates the >> window. >> > > ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Multipass rendering with shader
Hi Sebastian, here you can find a minimal compileable example : Code: #include #include #include #include #include #include #include #include #include #include // // Vertex shader pass 0 : Color // char vertexShaderSourcePass_0[] = "varying vec4 COLOR;\n" "\n" "varying vec2 texcoord;\n" "\n" "void main(void)\n" "{\n" "COLOR = gl_Color;\n" "gl_Position = ftransform();\n" "}\n"; // // fragment shader pass 0 : Color // char fragmentShaderSourcePass_0[] = "varying vec4 COLOR; \n" "\n" "void main(void) \n" "{\n" "vec4 newcolor = COLOR;\n" "COLOR.r = newcolor.b/2;\n" "COLOR.g = newcolor.r/3;\n" "COLOR.b = newcolor.g + 0.1;\n" "gl_FragColor = COLOR; \n" "}\n"; // // Vertex shader pass 1 : TWIST // char vertexShaderSourcePass_1[] = "uniform float time;\n" "uniform float height;\n" "uniform float angle_deg_max;\n" "\n" "varying vec2 texture_coordinate;\n" "varying vec4 normal, lightDir[3], eyeVec;\n" "\n" "vec4 DoTwist( vec4 pos, float t )\n" "{\n" "float st = sin(t);\n" "float ct = cos(t);\n" "vec4 new_pos;\n" "\n" "new_pos.x = pos.x*ct - pos.z*st;\n" "new_pos.z = pos.x*st + pos.z*ct;\n" "new_pos.y = pos.y;\n" "new_pos.w = pos.w;\n" "return( new_pos );\n" "}\n" " void main()\n" "{ \n" " float angle_deg = angle_deg_max*sin(time);\n" " float angle_rad = angle_deg * 3.14159 / 180.0;\n" " float ang = (height*0.5 + gl_Vertex.y)/height * angle_rad;\n" " vec4 twistedPosition = DoTwist(gl_Vertex, ang);\n" " // vec4 twistedNormal = DoTwist(vec4(gl_Normal, ang);\n" " gl_Position = gl_ModelViewProjectionMatrix * twistedPosition;\n" " vec3 vVertex = vec3(gl_ModelViewMatrix * twistedPosition);\n" " // lightDir[0] = vec3(gl_LightSource[0].position.xyz - vVertex);\n" " // lightDir[1] = vec3(gl_LightSource[1].position.xyz - vVertex);\n" " // lightDir[2] = vec3(gl_LightSource[2].position.xyz - vVertex);\n" " // eyeVec = -vVertex;\n" " // normal = gl_NormalMatrix * twistedNormal.xyz;\n" " //gl_TexCoord[0] = gl_MultiTexCoord0;\n" " texture_coordinate = vec2(gl_MultiTexCoord0);\n" " //gl_Position = ftransform();\n" "}\n"; // // fragment shader pass 1 : TWIST // char fragmentShaderSourcePass_1[] = "uniform sampler2D previousTexture; \n" "varying vec2 texture_coordinate;\n" "\n" "void main(void) \n" "{\n" " vec4 somecolor = texture2D(previousTexture, gl_TexCoord[0].xy);\n" " gl_FragColor = somecolor; \n" "}\n"; /*! * \fn osg::Camera* createHUDCamera( double left, double right, double bottom, double top ) * \brief Create an HUD Camera (as Post Render). Contains the result of the shader multiple pass * this code coming from openscenegraph 3 cookbook */ osg::Camera* createHUDCamera( double left, double right, double bottom, double top ) { osg::ref_ptr camera = new osg::Camera; camera->setReferenceFrame( osg::Transform::ABSOLUTE_RF ); camera->setClearMask( GL_DEPTH_BUFFER_BIT ); camera->setRenderOrder( osg::Camera::POST_RENDER ); camera->setAllowEventFocus( false ); camera->setProjectionMatrix( osg::Matrix::ortho2D(left, right, bottom, top) ); camera->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF ); return camera.release(); } /*! * \fn osg::Geode* createScreenQuad( float width, float height, float scale=1.0f) * \brief Create screen Quad for the HUD Camera * this code coming from openscenegraph 3 cookbook */ osg::Geode* createScreenQuad( float width, float height, float scale=1.0f) { osg::Geometry* geom = osg::createTexturedQuadGeometry( osg::Vec3(), osg::Vec3(width,0.0f,0.0f), osg::Vec3(0.0f,height,0.0f), 0.0f, 0.0f, width*scale, height*scale ); osg::ref_ptr quad = new osg::Geode; quad->addDrawable( geom ); int values = osg::StateAttribute::OFF|osg::StateAttribute::PROTECTED; quad->getOrCreateStateSet()->setAttribute( new osg::PolygonMode(osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::FILL), values ); quad->getOrCreateStateSet()->setMode( GL_LIGHTING, values ); return quad.
Re: [osg-users] Multipass rendering with shader
Hi Sebastian, the first pass works well. I have tested it using the test_pass_0 (vertex and fragment) and the HUD camera. (The result in the attached picture). I'm going to prepare a minimal compileable example. Thank you! Cheers, Andrea -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53719#53719 <>___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Multipass rendering with shader
Hello Andrea, I didn't go through every line of code of your example, as it is far from being minimal. Maybe I'll dig into it later on - but it would be best if you'd assemble a minimal compileable example. Also I'd suggest trying to do some minimal debugging, i.e. don't try to do everything at once. Instead try to debug-out the render2texture from the first pass in your HUD to see what is going on. cheers Sebastian Hi Sebastian, tahnk you for your suggestions. I have taken some days to study your solutions and to apply them to my osg application. It seem that something is going on, but i still get some doubts and some errors. In the following code, i simulate the use of two shader on the same 3D object (cessna.osg) using two PRE_RENDER camera : the first shader (test_Pass_0) change the object's color, the second shader (test_Pass_1) should apply a twist deformation on the same 3D Object. Finally, i use the HUD camera to visualize the final effect ( a twisted and colored cessna). So, briefly : I use the PRE_RENDER CAMERA (first Camera) to fill the frame buffer with a texture (first texture) coming from the first shader. A second PRE_RENDER CAMERA (second Camera), applies on the same object a twist deformation (with the vertex shader) and this second camera uses the first texture to get the color for the second shader (fragment shader). The second camera fills the FBO for the next camera (HUD camera). My doubt is : Is this approach correct? The error is : "Warning: detected OpenGL error 'invalid value' at After Renderer::compile" I get this error after the test_Pass_1.frag. What i see is the cessna.osg twisted, but completely black (it seems that the test_pass_1.frag doesn't see the correct sampler2D input (previousTexture) coming from the first shader (test_Pass_0.frag). (I report a snapshot about the this result). First i report the osg code. Code for HUD CAMERA : the image input means the result of the test_Pass_0 shader Code: // this code coming from openscenegraph 3 cookbook osg::Camera* createHUDCamera( double left, double right, double bottom, double top ) { osg::ref_ptr camera = new osg::Camera; camera->setReferenceFrame( osg::Transform::ABSOLUTE_RF ); camera->setClearMask( GL_DEPTH_BUFFER_BIT ); camera->setRenderOrder( osg::Camera::POST_RENDER ); camera->setAllowEventFocus( false ); camera->setProjectionMatrix( osg::Matrix::ortho2D(left, right, bottom, top) ); camera->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF ); return camera.release(); } // this code coming from openscenegraph 3 cookbook osg::Geode* createScreenQuad( float width, float height, float scale ) { osg::Geometry* geom = osg::createTexturedQuadGeometry( osg::Vec3(), osg::Vec3(width,0.0f,0.0f), osg::Vec3(0.0f,height,0.0f), 0.0f, 0.0f, width*scale, height*scale ); osg::ref_ptr quad = new osg::Geode; quad->addDrawable( geom ); int values = osg::StateAttribute::OFF|osg::StateAttribute::PROTECTED; quad->getOrCreateStateSet()->setAttribute( new osg::PolygonMode(osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::FILL), values ); quad->getOrCreateStateSet()->setMode( GL_LIGHTING, values ); return quad.release(); } void ApplyHUDCamera(osg::Texture2D *image, osg::Group* root) { std::cout << "APPLY HUD" << std::endl; { osg::ref_ptr mHudCamera; mHudCamera = createHUDCamera(0.0, 1.0, 0.0, 1.0); mHudCamera->addChild( createScreenQuad(1.0f, 1.0f)); osg::ref_ptr mStateset = mHudCamera->getOrCreateStateSet(); mStateset->setTextureAttributeAndModes( 0, image ); root->addChild(mHudCamera.get()); } return; } The following code, applies the first shader effect : simply, change object's color Code: osg::Texture2D* SingleTexturePass(osg::Group* root,osg::Node* viewnode,osg::Vec4 clearColor, int windowWidth, int windowHeight) { std::cout << "FIRST PASS" << std::endl; osg::ref_ptr firstTexture = new osg::Texture2D; firstTexture->setTextureSize(windowWidth, windowHeight); firstTexture->setInternalFormat(GL_RGBA); firstTexture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR); firstTexture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR); firstTexture->setWrap(osg::Texture2D::WRAP_S,osg::Texture2D::CLAMP_TO_BORDER); firstTexture->setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::CLAMP_TO_BORDER); //firstTexture->setBorderColor(osg::Vec4(1.0f,1.0f,1.0f,1.0f)); // set up the render to color texture camera. { osg::ref_ptr firstCamera = new osg::Camera; firstCamera->setName("FirstCamera"); // firstCamera->setClearColor(clearColor); firstCamera->setViewport(0,0,windowWidth,windowHeight); //first
Re: [osg-users] Multipass rendering with shader
Hi Sebastian, tahnk you for your suggestions. I have taken some days to study your solutions and to apply them to my osg application. It seem that something is going on, but i still get some doubts and some errors. In the following code, i simulate the use of two shader on the same 3D object (cessna.osg) using two PRE_RENDER camera : the first shader (test_Pass_0) change the object's color, the second shader (test_Pass_1) should apply a twist deformation on the same 3D Object. Finally, i use the HUD camera to visualize the final effect ( a twisted and colored cessna). So, briefly : I use the PRE_RENDER CAMERA (first Camera) to fill the frame buffer with a texture (first texture) coming from the first shader. A second PRE_RENDER CAMERA (second Camera), applies on the same object a twist deformation (with the vertex shader) and this second camera uses the first texture to get the color for the second shader (fragment shader). The second camera fills the FBO for the next camera (HUD camera). My doubt is : Is this approach correct? The error is : "Warning: detected OpenGL error 'invalid value' at After Renderer::compile" I get this error after the test_Pass_1.frag. What i see is the cessna.osg twisted, but completely black (it seems that the test_pass_1.frag doesn't see the correct sampler2D input (previousTexture) coming from the first shader (test_Pass_0.frag). (I report a snapshot about the this result). First i report the osg code. Code for HUD CAMERA : the image input means the result of the test_Pass_0 shader Code: // this code coming from openscenegraph 3 cookbook osg::Camera* createHUDCamera( double left, double right, double bottom, double top ) { osg::ref_ptr camera = new osg::Camera; camera->setReferenceFrame( osg::Transform::ABSOLUTE_RF ); camera->setClearMask( GL_DEPTH_BUFFER_BIT ); camera->setRenderOrder( osg::Camera::POST_RENDER ); camera->setAllowEventFocus( false ); camera->setProjectionMatrix( osg::Matrix::ortho2D(left, right, bottom, top) ); camera->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF ); return camera.release(); } // this code coming from openscenegraph 3 cookbook osg::Geode* createScreenQuad( float width, float height, float scale ) { osg::Geometry* geom = osg::createTexturedQuadGeometry( osg::Vec3(), osg::Vec3(width,0.0f,0.0f), osg::Vec3(0.0f,height,0.0f), 0.0f, 0.0f, width*scale, height*scale ); osg::ref_ptr quad = new osg::Geode; quad->addDrawable( geom ); int values = osg::StateAttribute::OFF|osg::StateAttribute::PROTECTED; quad->getOrCreateStateSet()->setAttribute( new osg::PolygonMode(osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::FILL), values ); quad->getOrCreateStateSet()->setMode( GL_LIGHTING, values ); return quad.release(); } void ApplyHUDCamera(osg::Texture2D *image, osg::Group* root) { std::cout << "APPLY HUD" << std::endl; { osg::ref_ptr mHudCamera; mHudCamera = createHUDCamera(0.0, 1.0, 0.0, 1.0); mHudCamera->addChild( createScreenQuad(1.0f, 1.0f)); osg::ref_ptr mStateset = mHudCamera->getOrCreateStateSet(); mStateset->setTextureAttributeAndModes( 0, image ); root->addChild(mHudCamera.get()); } return; } The following code, applies the first shader effect : simply, change object's color Code: osg::Texture2D* SingleTexturePass(osg::Group* root,osg::Node* viewnode,osg::Vec4 clearColor, int windowWidth, int windowHeight) { std::cout << "FIRST PASS" << std::endl; osg::ref_ptr firstTexture = new osg::Texture2D; firstTexture->setTextureSize(windowWidth, windowHeight); firstTexture->setInternalFormat(GL_RGBA); firstTexture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR); firstTexture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR); firstTexture->setWrap(osg::Texture2D::WRAP_S,osg::Texture2D::CLAMP_TO_BORDER); firstTexture->setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::CLAMP_TO_BORDER); //firstTexture->setBorderColor(osg::Vec4(1.0f,1.0f,1.0f,1.0f)); // set up the render to color texture camera. { osg::ref_ptr firstCamera = new osg::Camera; firstCamera->setName("FirstCamera"); // firstCamera->setClearColor(clearColor); firstCamera->setViewport(0,0,windowWidth,windowHeight); //firstCamera->setClearStencil(0); //firstCamera->setClearDepth(0.0); //firstCamera->setClearAccum(osg::Vec4(1.0,1.0,1.0,1.0)); //firstCamera->setClearMask(GL_COLOR_BUFFER_BIT); // | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); //firstCamera->setReferenceFrame(osg::Transform::ABSOLUTE_RF); //firstCamera->setCullingMode(osg::Camera::VIEW_FRUSTUM_SIDES_CULLING); //colorCamera->setViewport(the_viewport.get()); //colorCamera->setProjecti
Re: [osg-users] txp lod problem: switching in cycles
Hi Daniel, I am running large terrain (txp) on my laptop with no problems with the latest code from the trunk (although I don't think the txp loader was touched lately). What is the version of your archive? It seam that the code in the repository works the best with 2.1 archives. Also, good practice is to use s3 texture compression (dxt3 and dxt5) when building the archive in TerraVista. If you can build a block and post it I can take a look what is happening Let me know Nick On Mon, Apr 22, 2013 at 9:02 AM, Daniel Krikun wrote: > Hello, > > I have a "heavy" application which uses osg viewer and a TXP terrain. > After some time the application is running, LOD level of the terrain > starts being switched higher and lower all the time in cycles, so one > second I have trees and building being displayed and one second later - > they disappear. > Interesting, if I run just 2 instances of osgviewer.exe with a large TXP > terrain, after some time, I achieve the same effect. > > I suspect, TXP loader detects low memory available and switches LOD down, > then when some memory is freed due to this LOD switching, the loader > switches the LOD up, the memory gets low and it continues in cycles. > > Any ideas? > > I'm running Windows XP, 32-bit, GTX 670. Both osg-2.9.8 and 3.0.1 exhibit > this behaviour. > > Thanks, > > -- > Daniel Krikun > > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > -- trajce nikolov nick ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] txp lod problem: switching in cycles
Hello, I have a "heavy" application which uses osg viewer and a TXP terrain. After some time the application is running, LOD level of the terrain starts being switched higher and lower all the time in cycles, so one second I have trees and building being displayed and one second later - they disappear. Interesting, if I run just 2 instances of osgviewer.exe with a large TXP terrain, after some time, I achieve the same effect. I suspect, TXP loader detects low memory available and switches LOD down, then when some memory is freed due to this LOD switching, the loader switches the LOD up, the memory gets low and it continues in cycles. Any ideas? I'm running Windows XP, 32-bit, GTX 670. Both osg-2.9.8 and 3.0.1 exhibit this behaviour. Thanks, -- Daniel Krikun ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org