Re: [osg-users] [osgOcean] Masked FFTOceanSurface
Hi Kim, I attached the two files to this posting. The usage is simple, just use osgDB::readImageFile(FILEPATH) to get the a mask image that will then be applied to modulate the heights in the computeSea function. The mask is white where no change is needed and black where the ocean should not be visible. Currently it has some drawbacks: -The average height and the height of the lesser LOD's treats the masking height (e.g. -100.0f) like the valid heights -It is not easy to produce a specific height distribution aside from a plain surface thats bounded by a definable shore. A river that flows down some rapids or multiple waterfalls are hard to get correctly. It would be better if the mask is supplied with specific (relative) ground heights so that e.g. 0 means no change and a mask value of e.g. 10 means the surface should on average be 10 units elevated -LOD 0 (1 Quad) currently cannot benefit from the masking, maybe by using a shader/texture that has alpha values set like the mask, this effect can still be conveyed at LOD0 Cheers, Oliver -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=47991#47991 Attachments: http://forum.openscenegraph.org//files/fftoceansurface_864.cpp http://forum.openscenegraph.org//files/1719_1338534512._126. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [osgOcean] Masked FFTOceanSurface
Hi, I added a user-definable mask functionallity to FFTOceanSurface. The mask applies a height offset to the ocean tiles which allows the usage of the FFTOceanSurface as rivers and lakes on different altitudes in the same scene without having it protrude the ground (I plan to combine this with osgEarth). Its currently more of a dirty hack, but still its quite usable. In the FFTOceanSurface Header I added 2 variables and changed the ctor: Code: osg::Image *_surfMask; float _sufMaskMaxDist; public: FFTOceanSurface(unsigned int FFTGridSize = 64, unsigned int resolution = 256, unsigned int numTiles = 17, const osg::Vec2f windDirection = osg::Vec2f(1.1f, 1.1f), float windSpeed = 12.f, float depth = 1000.f, float reflectionDamping = 0.35f, float waveScale = 1e-8f, bool isChoppy = true, float choppyFactor = -2.5f, float animLoopTime = 10.f, unsigned int numFrames = 256, osg::Image *_surfMask=NULL, float _sufMaskMaxDist=100.0f ); In FFTOceanSurface.cpp I added this to the computeSea method: Before the frame loop: Code: int imgDim = 0; int imgBytesPerLine = 0; int imgBytePerPixel = 0; if(_surfMask) { imgDim =__min(_surfMask-s(),_surfMask-t()); imgBytePerPixel = _surfMask-computeNumComponents(_surfMask-getPixelFormat()); imgBytesPerLine = _surfMask-s()*imgBytePerPixel; } Within the frame loop before calling OceanTile() for level 0: Code: int sizeHeights = heights-size(); int dimHeights = (int)floor(sqrt((float)sizeHeights)+0.5f); if(_surfMask imgDim0 dimHeights0) // Apply surface mask { //Handle scaling difference between if(dimHeights = imgDim) { int imgScaling = dimHeights/imgDim; int scaledImgDim = imgDim*imgScaling; for(int y= 0; y dimHeights;y++) { int yRow = dimHeights*y; unsigned char* pImgOsgLine = ((unsigned char*)_surfMask-data())+ imgBytesPerLine * (y/imgScaling); for(int x = 0; x dimHeights;x++) { if((x scaledImgDim) (y scaledImgDim)) { float alpha =(float)*((unsigned char*)(pImgOsgLine+(x/imgScaling)*imgBytePerPixel))/255.0f; float oldVal = heights-at(yRow+x); heights-at(yRow+x) = alpha*oldVal - _sufMaskMaxDist*(1.0f-alpha); } else { heights-at(yRow+x) = -_sufMaskMaxDist; } } } } else { int imgScaling_d1 = imgDim/dimHeights; int scaledImgDim = imgDim/imgScaling_d1; for(int y= 0; y dimHeights;y++) { int yRow = dimHeights*y; unsigned char* pImgOsgLine = ((unsigned char*)_surfMask-data()) + imgBytesPerLine * y*imgScaling_d1; for(int x = 0; x dimHeights;x++) { if((x scaledImgDim) (y scaledImgDim) ) { float alpha =(float)*((unsigned char*)(pImgOsgLine+x*imgScaling_d1*imgBytePerPixel))/255.0f; float oldVal = heights-at(yRow+x); heights-at(yRow+x) = alpha*oldVal - _sufMaskMaxDist*(1.0f-alpha); } else { heights-at(yRow+x) = -_sufMaskMaxDist; } } } } } Greetings, Oliver -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=47939#47939 Attachments: http://forum.openscenegraph.org//files/ocean_masked_157.png ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Conversion from 'GLsizeiptrARB' to 'const GLvoid *' of greater size
Hi, Sorry to bug you again with this topic, but I'm getting the very same warnings on my machine. I surrounded each troubling line with Code: #pragma warning(push) #pragma warning(disable : 4312) ...LINE WITH WARNING... #pragma warning(pop) but thats just cosmetics. The vertex buffer code now looks rather different from the 2.8.3 past. Can you give some insight into why this was changed (especially the Array mutable const GLvoid* _vboOffset versus BufferEntry unsigned int offset part)? I'm still not sure that the warning can be ignored. Of course compiling it for and using it on a 64bit machine works, but what happens when the code was compiled for 32 bit and is used on a 64 bit machine; wouldn't that mean that the cast of a negative int is wrongly cast to a positive 64bit pointer position (see http://msdn.microsoft.com/en-us/library/h97f4b9y%28v=vs.80%29.aspx)? I guess as the BufferEntry offset is always positive so thats not a problem here, thus the warnings can be ignored right? On the other hand the conversion from unsigned int to GLsizeiptrARB will make it signed again so I'm still not 100% sure. Cheers, Oliver -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=41314#41314 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] ReaderWriterTIFF seeking problem in libtiff when using stringstream
Hi, As part of a Bugfix for osgearth I found a problem within osg's tiff plugin (ReaderWriterTIFF.cpp): http://forum.osgearth.org/sqlite3-caching-with-TIFFs-Bugfix-td6049357.html#a6192153 In essence: When using the ReaderWriter on a std::stringstream the seeking operation should not seek over the end of existing data. The LibTiff code does this and that results in libtiffs internal fail bit to be set and thus not writing a correct TIFF file into the stringstream. The solution I used locally can be found at the URL above. I just pad the missing sections with zero before seeking. Is my solution feasible or is there a better solution? Thank you! Cheers, Oliver -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=37788#37788 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Visibility of point array
Hi Sergey, Thanks for the code example! I will try to get it to work but I might need some days, this is the first custom shader I'm using. Cheers, Oliver -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35914#35914 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Visibility of point array
Hi Sergey, ok, thanks, currently my approach is working ok, but I'm still looking for speed improvements, so your help is very appreciated. Cheers, Oliver -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35808#35808 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Visibility of point array
Hi Ulrich and Sergey, the problem I need to solve is this: for an arbitrary scene loadable through osg, detect which points in an array of points are visible (points are normally on model surface, but not necesserily part of the original model). Your solutions sound very complex. Currently I'm using the following approach (simplified): For each point x: 1.)check against the View + Projection Matrix to find out if point x is in frustum, 2.)use osgUtil::LineSegmentIntersector::Intersection to find first intersection between eyepoint and point - if intersection is more than delta away from x and nearer to eyepoint - x not visible This process works quiet good, but I always need to issue a viewer-frame() for each change of camera position before the calculation, or it produces wrong information (visibility is not correct) . It looks like culling must be performed to get this approach to work. As I need to test many views and many points, I am currently trying to remove the frame() call and do just the culling, but until now I only have partial success with it. I have overwritten the Renderer.cull() method to not increase the _drawQueue but the multithreaded viewer calls draw and it waits blocked in Renderer::ThreadSafeQueue::takeFront() forever. Strangly using setThreadingModel(osgViewer::Viewer::SingleThreaded) produces completly different results (also wrong visibility) but does not block. Is there an easier way to only do the culling without drawing or even don't cull at all? Thank you! Cheers, Oliver -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35768#35768 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Visibility of point array
Hi Sergey, Thanks for the quick reply. Do you have a sample code or some documentation on how to get transform feedback to work? Greetings, Oliver -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35772#35772 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Visibility of point array
Hi Ulrich, I need the information on vertix level, not bounding volumn level. How does the Render Engine know which vertices to draw. Is it all done in GPU using the Z Buffer (overwriting what is nearer)? I found the OcclusionQuery example that uses OcclusionQueryNode, but I can't quite make out how to use it. Its very confusing, I add the previous root node as a child of a new OcclusionQueryNode but I cannot find any occlusion information in it. How do I get the visibility information stuff here? Thank you! Cheers, Oliver -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35723#35723 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Visibility of point array
Hi, I am trying to detect which of a set of 3D points (e.g. vertices of a scene model) are currently visible. I tried to derive from osg::Geometry and overwrite the drawImplementation methode. The _vertexData.array contains all points specified (all points, also the occluded) and _vertexData.indices is NULL. I cannot find any information about which points are visible. Where is this information saved to? Thank you! Cheers, Oliver -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35707#35707 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] LineSegmentIntersector::Intersection contains no indexList
Hi Robert, thanks for the reply. I have used the ShapeDrawable as an example. My code uses nodes read from COLLADA models and it doesn't work there either (those nodes display just fine, with the texture on them, so I know uv mapping is also working). I can't understand why the code allows the calculation of the correct intersection point, but not the reference of the Nodes. It seems to be an artificial limitation. Greetings, Oliver -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35577#35577 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] LineSegmentIntersector::Intersection contains no indexList
Hi, I am trying to get uv coordinates and color of a point I found using the LineSegmentIntersector. My problem is that the found intersection has no indexList so I cannot use the code used in osgmovie. This short code example should boil down to the point: Code: osg::Box* b = new osg::Box( osg::Vec3d(0,0,0), 1.0f); osg::Geode* g = new osg::Geode(); g-addDrawable( new osg::ShapeDrawable( b ) ); osg::ref_ptr osgUtil::LineSegmentIntersector lineSeg = new osgUtil::LineSegmentIntersector(osg::Vec3d(0,-2,0), osg::Vec3d(0,0,0)); osgUtil::IntersectionVisitor findIntersections(lineSeg.get()); g-accept(findIntersections); osgUtil::LineSegmentIntersector::Intersection currHit = lineSeg-getFirstIntersection(); osg::Vec3d intersecPnt = currHit.getWorldIntersectPoint(); int vecArraySize = currHit.indexList.size(); int vecRatioSize = currHit.ratioList.size(); intersecPnt is correctly found, but vecArraySize and vecRatioSize is zero. I read through some layers of osg code and it seems my proble is the treatVertexDataAsTemporary variable. It prevents at the end of TriangleIntersector::operator () (part of LineSegmentIntersectorUtils in linesegmentintersector.cpp) that the found three vertices used to compute the intersection are inserted into the result as they are temporary. How do I get the correct uv coordinates in such a situation or how do I force the inclusion of the needed vertices? Cheers, Oliver -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35293#35293 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Hidden Viewer
Hello Jean-Sébastien, Thanks for your reply, Skylark wrote: Hello Oliver, Hmmm, seems you are tripping over something else on your hardware... I just remembered you had mentioned in another post that setting the threading model to SingleThreaded didn't work for you either, but in my case it did... So that indicates something else is going on for you. The code works for me as well if I set the threading model to SingleThreaded! I think it is the osg lib, as I have used the official build libs and no custom builds. I will update the nVidia driver but I think the difference between our two systems is the osg version. I will try to get the current osg trunk to work. In the mean time, could you test out your altered pbuffertest.cpp with the offical 2.8.3 libs (VS2005) to verify if this is the problem? You can find them here: http://www.openscenegraph.org/downloads/stable_releases/OpenSceneGraph-2.8.3/binaries/Windows/VisualStudio8/. @ Robert: If I get the dev build to work, I will check the two solutions you mentioned. Greetings, Oliver -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=34394#34394 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Hidden Viewer
Hi, I have successfully build the current svn trunk version: -Just before Robert checked in the Bugfix: As before with 2.8.3 I get Code: PixelBufferWin32::makeCurrentImplementation, wglMakeCurrent error: Die angeforde rte Ressource wird bereits verwendet. Frame : 0 Test completed!!! Now I think I understand that J-S meant with pbuffertest example works that the application is not crashing and terminates successfully. Sorry I think I misunderstood you, seeing the initial error was enough for my bug senses to cry out ;) After updating to the latest version (including the bug fix), the error message has vanished! I removed J-S bug fix in pbuffertest itself and lo and behold: The errors are gone too! For the time being I will build 2.8.3 with the single change to be compatible with the rest of my application and work with that. So thanks to you all for your great help, I really appreciate it! On small last thing (not related to the bugs but to the hidden viewer approach): With the pbuffer active, my WindowCaptureCallback is not called anymore. I used osgscreencapture to create an image grabber derived from WindowCaptureCallback but it looks like I have to use another approach with pbuffer (as done in the example code). I was curious if I could activate the WindowCaptureCallback even though using a pbuffer so that I use only one code for both cases? Greetings, Oliver Cheers, Oliver -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=34436#34436 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Hidden Viewer
Hi J-S, Great! You solved my problems before they appeared ;), I will try to get it to work in 2.8.3. Thank you! Cheers, Oliver -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=34442#34442 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Hidden Viewer [solved]
Hi Jean-Sebastien, I included the changes in my 2.8.3 build and it is now working as I had originally intended. I removed the mentioned one line in osgViewer::PixelBufferWin32 and changed the code of my own ScreenCaptureHandler derivative just like you did (use context and not windows). So thanks again to all of you, I changed the title to [solved]. Cheers, Oliver -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=34451#34451 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Hidden Viewer
Hi Juan, Thanks for your insight, As Robert already answered, it should be possible. The best explanation that I have for your problem is that some thread fails to do wglMakeCurrent (after that call fails anything that follows is just garbage) beacuse another thread is holding the context (according to http://www.opengl.org/sdk/docs/man/xhtml/glXMakeCurrent.xml, that's a programming error in GLX, so I guess the same applies in WGL). All OpenGL calls from that thread are going to fail after that. If the sample code that I sent you also complains with the error message: PixelBufferWin32::makeCurrentImplementation, wglMakeCurrent error: Die angeforderte Ressource wird bereits verwendet then, there is a threading error somewhere. However I can't spot it the code I sent you and I'm afraid that's beyond my knowledge of OSG's guts. Robert may be more insightful here. You can try commenting the line that changes the threading model and replacing frame() by run() to see if it also fails. It results in the same error if I comment out the setThreadingModel call, no matter if I use frame() or run(). Btw, I'm using osg v2.8.3. I compile Juan's code using the official libraries from http://www.openscenegraph.org/downloads/stable_releases/OpenSceneGraph-2.8.3/binaries/Windows/VisualStudio8/ and as Robert said, it's working thread safe in a standard graphics window. If Robert is still reading this thread, is this a known issue with a solution or do I have to write a bug report? Greetings, Oliver -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=34291#34291 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Hidden Viewer
Hi Juan and Robert, Thanks for the help, I compiled the pbuffertest code, I had to add this to the header section to make it work (i'm using osg 2.8.3) Code: #include osg/Notify #define OSG_NOTICE OSG_NOTIFY_1(osg::NOTICE) #define OSG_NOTIFY_1(level) if (osg::isNotifyEnabled(level)) osg::notify(level) pbuffertest -w works and makes 100 frames (the viewer window is shortly visible). pbuffertest -f 1 doesn't work and produces the known error: Code: Frame : PixelBufferWin32::makeCurrentImplementation, wglMakeCurrent error: 0Die angeforderte Ressource wird bereits verwendet. Test Ecrormoprl:e Otpeedn. GL version test failed, requires valid graphics context. (btw, exchanging the OSG_NOTICE with printf gives the correct Test completed.\nError: OpenGL version test failed, requires valid graphics context. instead of Test Ecrormoprl:e Otpeedn for pbuffertest.exe -f 1) I installed GPU-Z but couldn't find the OpenGL Extension Information. I installed the OpenGL Extensions Viewer (http://www.realtech-vr.com/glview/download.html). It confirms that among others WGL_ARB_pbuffer WGL_ARB_pixel_format WGL_ARB_pixel_format are supported by my nVidia Quadro FX 580 (see screenshot). Because it sounded like a possible fix, I defined the environment variable OSG_WIN32_NV_MULTIMON_MULTITHREAD_WORKAROUND to ON, but that changed nothing. As far as my little knowledge goes, I think that the bug is in the osg code. Cheers, Oliver -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=34308#34308 Attachments: http://forum.openscenegraph.org//files/clip1_203.jpg ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Hidden Viewer
Hi, Wow, you guys are great! Thanks for your help! Maybe we can solve this bug. @Jean-Sébastien: I had to additionally include the osgGA.lib to make it work in Win32. My nVidia driver version is 6.14.12.5849 which should be 258 in your nomenclature. Cheers, Oliver -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=34352#34352 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Hidden Viewer
Hi, I added to the pbuffertest.cpp directly after viewer.realize(); Code: viewer.stopThreading(); gc-releaseContext(); viewer.startThreading(); but I still have the same behaviour (-1 works, -f 1 gives the wglMakeCurrent error) Cheers, Oliver -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=34374#34374 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Hidden Viewer
Hi, I'm trying to render scenes into a buffer (e.g. an osg::Image). There are multiple demos and examples about this (e.g. example_osgscreencapture) but they all require some sort of visible viewer to work. I'd like a console application that does not display any windows. Is there a class/working example that allows this? I tried the osgViewer::setUpViewerAsEmbeddedInWindow method but calling viewer.frame() produces many errors. It seems as OpenGL is not initialized here at all. Thank you! Cheers, Oliver -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=34250#34250 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Hidden Viewer
Dear Juan and Robert, Thanks for the quick reply! I tried the code supplied by Juan but I'm still getting the Error: OpenGL version test failed, requires valid graphics context. and subsequent errors (many invalid operation). As a second test I copied the complete osgViewer::setUpViewInWindow and just added the line Code: traits-pbuffer = true; to the Traits creation part. Without the line the code works but displays a window, with the line I get the OpenGL errors. For the second case I get these Errors: Code: PixelBufferWin32::makeCurrentImplementation, wglMakeCurrent error: Die angeforderte Ressource wird bereits verwendet. Error: In Texture::Extensions::setupGLExtensions(..) OpenGL version test failed, requires valid graphics context. Scaling image from (256,256) to (0,0) (Die angeforderte Ressource wird bereits verwendet. is german for The Requested Resource Is in Use.) Is this a Win32 related problem or am I missing something? Cheers, Oliver[/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=34261#34261 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Hidden Viewer
Hi Juan, Thanks for the demo code. It runs without a problem. I found the critical line: viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded); If i comment it out, the demo code crashes with the same error text as above. Very weird... I tried to add this line to my code, but I still have some minor bugs to fix. Appart from that, is it possible to run a hidden viewer in a multithreaded fashion? Greetings, Oliver -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=34270#34270 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org