Re: [osg-users] osg::Geometry and GL_PRIMITVE_RESTART
Hi, I'm facing the same problem : I try to use Code: glPrimitiveRestartIndex(0x); glEnableClientState(GL_PRIMITIVE_RESTART); In my OSG 3.0 project. Is there any way to use these functions without a "big hack" of osg ? Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=41823#41823 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How to use different shader for different cameras ?
Thanks for your answers ! But the "special rendering-mode shader" is not the same for all the objects, so how can I : - tell to object A : "your special shader for special rendering mode is this one" - tell to object B : "your special shader for special rendering mode is this one" - tell to object C : "your special shader for special rendering mode is this one" etc... ? Regards, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42415#42415 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] OSG static linking for commercial application
Hi, This is a question about legal statement, not technical. I'm working on a commercial project based on OSG. I made a dynamic library "3dstuff.dll" with all my 3D stuff, this DLL uses OSG. Can I use static linking of OSG with my "3dstuff.dll" to distribute only this DLL with my executable file ? Or is it an OSG license violation and I have to distribute OSG as a set of dynamic librairies ? (osg.dll, osgGA.dll, osgXX.dll ) I ask this question here because I found this : "The OpenSceneGraph Public License is designed to be compatible with use of proprietary applications, such applications can statically and dynamically link to the OpenSceneGraph and can be redistributed with the libraries free of charge. Your applications can be distributed under any license, be it open source or proprietary." at http://www.openscenegraph.org/projects/osg/wiki/Legal which seems to say "ok, you can do that" But in the complete license text, here : http://www.openscenegraph.org/projects/osg/attachment/wiki/Legal/LICENSE.txt I didn't find anything about static linking. Thanks. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42765#42765 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] OSG static linking for commercial application
Thanks for all these clarifications ! About the plugins : where can I find specific plugin license ? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42786#42786 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Questions about render order
Hi, I want to understand the render order of the different objects in an OSG scene. For example, with this scene : [Image: http://img4.hostingpics.net/thumbs/mini_829034graph.png ] Is it true or false ? 1. Root is rendered before all other 2. A is rendered before A1 2. B is rendered before B1, B2 and B3 3. B1 is rendered before B2 and B3 4. C is rendered before C1, C2 and C3 5. C1 is rendered before C2 and C3 6. We cannot tell the rendering order between A, B and C Now, if I modify the RenderBins, using : A->setRenderBinDetails(1000, "RenderBin"); B->setRenderBinDetails(2000, "RenderBin"); C->setRenderBinDetails(3000, "RenderBin"); Is it true or false ? 1. Previous questions 1, 2, 3, 4 and 5 are true 2. A is rendered before B 3. A1 is rendered before B1, B2 and B3 4. B is rendered before C 5. B1 is rendered before B2 and B3 6. B1 is rendered before C1, C2 and C3 7. C1 is rendered before C2 and C3 Now, if I modify the RenderBins, using : A->setRenderBinDetails(1000, "RenderBin"); B->setRenderBinDetails(2000, "RenderBin"); B1->setRenderBinDetails(4000, "RenderBin"); C->setRenderBinDetails(3000, "RenderBin"); C1->setRenderBinDetails(5000, "RenderBin"); Is it true or false ? Render order is now : A => A1 => B => C => C1 => C2/C3 (cannot tell the order) => B1 => B2/B3 (cannot tell the order) Thanks ! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42842#42842 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] "hide" objects from manipulators
Hi, I'm working on an OSG based application, with user interaction (TranslateAxisDragger, RotateAxisDragger...) My scene is rendered as follow : - Depth and color buffer clear - Objects are rendered - Depth buffer clear - Manipulators are rendered So manipulators are always drawn in front of objects. My problem is : - an object is dranw - associated manipulator is drawn in front of it, but all its geometry is included in object geometry => user can't pick and use manipulators because the object's geometry "block" the mouse event. So the mouse event is transfered to camera manipulator. How can I "hide" all objects from picking (not on render) except the manipulators so they are always drawn in front AND always usable ? Don't sure if my question is really clear and sorry for my bad english ! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42944#42944 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] "hide" objects from manipulators
Hi, I already use 2 subgraphs, like his : Root | | Manipulators | | Objects But how can I tell to the TranslateAxisManipulator to visit only the "Manipulators" subgraph ? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42960#42960 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] "hide" objects from manipulators
Thanks for your help ! To be more specific, when my dragger is hidden by another geometry, the camera manipulator get the event. Any idea about this ? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42963#42963 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Draw a line from world to screen
Hi, I've made an Segment object which draw a segement from a point (x, y, z) to another (x, y, z) and working well. Now, I want to draw a "Connector line" from a point in space (x, y, z) to a point on screen (x, y). How can I transform my (x, y) screen point to find a equivalent (x, y, z) world point ? To convert from world to screen, this works well : Code: double width = pCamera->getViewport()->width(); double height = pCamera->getViewport()->height(); osg::Matrixd mv = pCamera->getViewMatrix(); osg::Matrixd mp = pCamera->getProjectionMatrix(); osg::Matrixd mw = pCamera->getViewport()->computeWindowMatrix(); osg::Matrixd worldToScreen = mv * mp * mw; osg::Vec4d position = osg::Vec4d(p_object->position(), 1.0) * worldToScreen; position = position / position.w(); double screenX = position.x(); double screenY = height - position.y(); But to convert from screen to world coordinate,I try this and it doesn't work : Code: osg::Vec4d screenPosition = osg::Vec4d(screenX, height - screenY, 0.5, 1.0); osg::Vec4d worldPosition = osg::Matrixd::inverse(worldToScreen) * screenPosition ; -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42995#42995 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Draw a line from world to screen
Thansk for pointing me to these topics. So, I found the solution : (be carefull, these function use WORLD coordinates, not local coordinates) worldToScreen : Code: osg::Vec2d worldToScreen(const osg::Vec3d& worldPosition, const osg::Camera* pCamera) { osg::Vec2d screenPosition; if (pCamera!= NULL) { osg::Matrixd MVPW = pCamera->getViewMatrix() * pCamera->getProjectionMatrix() * pCamera->getViewport()->computeWindowMatrix(); osg::Vec4d screenPosition4d = osg::Vec4d(worldPosition, 1.0) * MVPW; screenPosition4d = screenPosition4d / screenPosition4d.w(); screenPosition4d.y() = pCamera->getViewport()->height() - screenPosition4d.y(); screenPosition.set(screenPosition4d.x(), screenPosition4d.y()); } return screenPosition; } screenToWorld : Code: osg::Vec3d screenToWorld(const osg::Vec2d& screenPosition, const osg::Camera* pCamera) { osg::Vec3d worldPosition; if (pCamera!= NULL) { osg::Vec4 screenPositionNear(screenPosition.x(), pCamera->getViewport()->height() - screenPosition.y(), 0.0, 1.0); osg::Vec4 screenPositionFar(screenPosition.x(), pCamera->getViewport()->height() - screenPosition.y(), 1.0, 1.0); osg::Matrixd iMVPW = osg::Matrixd::inverse(pCamera->getViewMatrix() * pCamera->getProjectionMatrix() * pCamera->getViewport()->computeWindowMatrix()); osg::Vec4 worldPositionNear = screenPositionNear * iMVPW; osg::Vec4 worldPositionFar = screenPositionFar * iMVPW; worldPositionNear = worldPositionNear / worldPositionNear.w(); worldPositionFar = worldPositionFar / worldPositionFar.w(); worldPosition.set((worldPositionNear.x() + worldPositionFar.x())/2.0, (worldPositionNear.y() + worldPositionFar.y())/2.0, (worldPositionNear.z() + worldPositionFar.z())/2.0); } return worldPosition; } -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43039#43039 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [osgPPU] Very basic example ?
Hi, After 2 days playing with osgPPU exmaples, I stil did not succeed to do a very basic PPU unit... Is there any very basic example for osgPPU ? Something like : * create PPU * add PPU unit which use a shader for a very basic operation (like switch red and green color components) * attach PPU to camera So with that, anybody could start coding PPU units easily. Regards, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43151#43151 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPPU] Very basic example ?
Currently, I have this code. I try to do a simple operation : invert Red and Green color components, but I get only a black screen. Could anyone help me ? Thanks. Code: // Configure Camera p_osgCamera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT); p_osgCamera->setViewport(new osg::Viewport(0,0,800,600)); // Create render texture osg::Texture2D* textureColor = new osg::Texture2D(); textureColor->setDataVariance(osg::Object::DYNAMIC); textureColor->setNumMipmapLevels(0); textureColor->setUseHardwareMipMapGeneration(false); textureColor->setResizeNonPowerOfTwoHint(false); textureColor->setTextureSize(800, 600); textureColor->setInternalFormat(GL_RGBA); textureColor->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR); textureColor->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::LINEAR); textureColor->setInternalFormat(GL_RGBA16F_ARB); textureColor->setSourceFormat(GL_RGBA); textureColor->setSourceType(GL_FLOAT); // Attach the texture and use it as the color buffer. p_osgCamera->attach(osg::Camera::COLOR_BUFFER, textureColor); // Create PPU pipeline osgPPU::Processor* processor = new osgPPU::Processor(); processor->setCamera(p_osgCamera); // Create colorby pass osgPPU::UnitCameraAttachmentBypass* colorBypass = new osgPPU::UnitCameraAttachmentBypass; colorBypass->setBufferComponent(osg::Camera::COLOR_BUFFER); // Create test unit osgPPU::UnitInOut* testUnit = new osgPPU::UnitInOut; osg::Shader* fpShader = new osg::Shader(osg::Shader::FRAGMENT); fpShader->setShaderSource("uniform sampler2D colorTexture;\n" "void main() {\n" " vec4 color = texture2D(colorTexture, gl_TexCoord[0].xy);\n" " vec4 colorTmp = (color.x, color.y, color.z, color.w);\n" " gl_FragData[0] = colorTmp;\n" "}\n"); // create shader attribute and setup one input texture osgPPU::ShaderAttribute* shader = new osgPPU::ShaderAttribute; shader->addShader(fpShader); shader->add("colorTexture", osg::Uniform::SAMPLER_2D); shader->set("colorTexture", 0); // attach the shader testUnit->getOrCreateStateSet()->setAttributeAndModes(shader); // Create PPU output osgPPU::UnitOut* ppuout = new osgPPU::UnitOut; ppuout->setInputTextureIndexForViewportReference(-1); // Setup pipeline ("p_osgRoot" is the OSG node used as sceneData for the "p_osgCamera" camera) p_osgRoot->addChild(processor); processor->addChild(colorBypass); colorBypass->addChild(testUnit); testUnit->addChild(ppuout); -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43160#43160 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPPU] Very basic example ?
Ok, I found the solution... An error in my shader code :-* -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43164#43164 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] ComputeIntersections and traversal mask
Hi, I use the following graph : Code: Root | | Group_1 (node mask 0x7FFF) | | Group_2 (node mask 0x8000) Group_1 and Group_2 have childs, with node mask 0x : Code: Group_1 | | Child_11 (node mask 0x) | | Child_12 (node mask 0x) Code: Group_2 | | Child_21 (node mask 0x) | | Child_22 (node mask 0x) But when I use osgViewer::View::computeIntersections like this : pView->computeIntersections(x, y, intersections, 0x8000) Child objects of Group_1 are intersected... like if Group_1 children are traversed by the intersector Is there any reason ? or did I miss something ? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43204#43204 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] "hide" objects from manipulators
Hi, I found the problem : when handling event, the Dragger instance look for itself in the NodePath of the FIRST intersection : (from Dragger.cpp, line 320) Code: for (osg::NodePath::iterator itr = _pointer._hitList.front().first.begin(); itr != _pointer._hitList.front().first.end(); ++itr) So I made a modification to use a node mask when looking for intersections -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43210#43210 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Extend LineSegmentIntersector : where to start ?
Hi, I've implemented picking in my application using "pView->computeIntersection(...)" which use a LineSegmentIntersector In my scene, I have some custom geometry and one of these custom geometry is made of lines, like this : Code: p_geode = new osg::Geode() p_geometry = new osg::Geometry(); p_vertices = my vertices array; p_primitive = new osg::DrawArrays(); p_primitive->setMode(osg::PrimitiveSet::LINE_STRIP); p_primitive->setFirst(0); p_primitive->setCount(p_vertices->size()); p_geometry->setVertexArray(p_vertices); p_geometry->addPrimitiveSet(p_primitive); p_geode->addDrawable(p_geometry); This geode is never intersected by the LineSegmentIntersector. If I use a PolytopeIntersector, this geode can be picked. In my company, we have C++ code which compute segment-segment intersection, so, as a personal training, I would like to extend LineSegmentIntersector to intersect the lines geode with our code. Could someone show me where to start ? Regards, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43319#43319 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Extend LineSegmentIntersector : where to start ?
Hi, > You can't computationally intersect infinitely thin lines with with > infinitely thin line segments so what you are asking specifically > isn't possible. We use an algorithm with a "intersection distance" parameter : if minimum distance between the two lines (or segment, or line/segment) is below this minimum, we consider that the lines intersect. It acts like intersecting cylinders (infinite or not) with a little diameter. This algorithm is currently used by several scientific softwares developped by my company. > What exactly you trying to achieve will affect what approach you will want to > take. I'm trying to extends LineSegmentIntersector with new features. There are different goals : - personal training - test our algorithm in a OSG context (actually all rendering is done in pure OpenGL, all computation in standard C++) - use this algorithm on a standard OSG scene to do some computations (like in our actual software) - maybe use this algorithm for screen picking Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43329#43329 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Extend LineSegmentIntersector : where to start ?
> If it walks like a duck and quacks like a duck it's a duck :-) In my case, it walks like a dog but it quacks like a duck, so it's probably a dock... We compute line-geometry intersections, and the only special case is when geometry is made of lines : in this situation, we have to consider the lines as cylinder, but the result would be a line-line intersection if the cylinder hit the line. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43346#43346 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [osgCompute] Use an osgCuda::Texture2D in a shader
Hi, I'm working on the port of a OpenGL / Cuda application to OSG / osgCuda. (OSG 3.0.1 with osgCuda from trunk) One of our class use Cuda to compute a buffer and then : - copy this buffer to a texture buffer (using cudaMemcpy) - bind this texture to a texture unit (using glBindTexture) - use this texture unit in a shader I'm trying to do the same using OSG / osgCuda. I don't use Computation classes for the moment, because we need a lot of time to port our Cuda code architecture to osgCuda. So, we do : - create an osgCuda::Texture2D as follow (our computed Cuda buffer contains float3 data) : Code: osg::ref_ptr pCudaTexture = new osgCuda::Texture2D(); pCudaTexture->setDataVariance(osg::Object::DYNAMIC); pCudaTexture->setNumMipmapLevels(0); pCudaTexture->setUseHardwareMipMapGeneration(false); pCudaTexture->setFilter(osg::Texture::MIN_FILTER , osg::Texture::LINEAR); pCudaTexture->setFilter(osg::Texture::MAG_FILTER , osg::Texture::LINEAR); pCudaTexture->setResizeNonPowerOfTwoHint(false); pCudaTexture->setWrap(osg::Texture::WRAP_R, osg::Texture::REPEAT); pCudaTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT); pCudaTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT); pCudaTexture->setInternalFormat(GL_RGB32F_ARB); pCudaTexture->setSourceFormat(GL_RGB); pCudaTexture->setSourceType(GL_FLOAT); pCudaTexture->setTextureSize(m_width, m_height); pCudaTexture->setUsage(osgCompute::GL_TARGET_COMPUTE_TARGET); - use this texture as a StateAttribute : Code: pNode->getOrCreateStateSet()->setTextureAttribute(0, pCudaTexture, osg::StateAttribute::ON); Then before rendering each frame : - call our Cuda code, which fill a Cuda buffer => this part is working - copy this buffer to the osgCuda::Texture2D : (dSourceCuda is a pointer to our computed Cuda buffer) Code: osgCompute::Memory* pMemory = pCudaTexture->getMemory(); void* dDestCuda = pMemory->map(); CUDA_SAFE_CALL( cudaMemcpy(dDestCuda, dSourceCuda, size, cudaMemcpyDeviceToDevice) ); pMemory->unmap(); This part seems to work : if we write the content of "dSourceCuda" buffer and "dDestCuda" buffer to a file, the data are identical and computed correctly by our Cuda code. But the texture unit seems to always have 0.0 values : when we have a look to our textureUnit with GDebugger, it always contains only 0.0 values. Is there any way to use the content of our computed Cuda buffer into a texture unit ? Regards, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43419#43419 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgCompute] Use an osgCuda::Texture2D in a shader
Hi, The Shader is executed as a "normal" osg shader program : by setting it on the node stateset. The Cuda code is executed before any rendering (before the pViewer->frame() call) By diggging in the osgCuda code source, it seems like "cudaGraphicsMapResources" and "cudaGraphicsGLRegisterImage" functions are never called... -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43432#43432 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgCompute] Use an osgCuda::Texture2D in a shader
To be more specific, I just need one function : "copyCudaBufferToOsgTexture" I thought osgCuda provide it, and I hope this is the first step for me before a complete migration from "hand-made" Cuda to osgCuda code. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43434#43434 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] readNodeFile() with OBJ files is extremely slow when used in Qt4 app
Hi, I'm facing the same problem... Have you found a solution ? Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43552#43552 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] OSG + Qt + threading.
Hi Nico, I'm also working with Qt as UI framework with OSG as a 3d renderer. Have you successed to use another threading model than SingleThreaded ? Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43664#43664 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPPU] delay in glow FX
Hi, I'm facing the same problem. Have you found a cause / solution to this issue ? Thanks, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43691#43691 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Shader and attributes binding
Hi, I'm writing some shaders to use with OSG and some use extra vertex attribute (such as tangent for a bump shader) I think the OpenGL way of vertex attribute binding is : - compile and link the shader program - get the attribute location by calling glGetAttribLocationARB(program, "attributeName") - bind the data buffer to this location So, this way, you always use a "free" attribute location In OSG, it seems that I have to do : - compile and link the shader program - bind the data buffer to a chosen location - set the attribute location by calling program->addBindAttribLocation("attributeName", location) What is the correct way to do this ? How can I be sure to not overwrite an attribute location in OSG (for example, attribute locations 0, 2, 3, and 8 are often reserved for vertex, normals, colors, and texture coordinates by video drivers) ? Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43842#43842 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Finding whether a geode was culled
Hi, Perhaps you should try : Code: class CullCallback : public osg::NodeCallback { virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) { osgUtil::CullVisitor* cullVisitor = dynamic_cast(nv); bool wasCulled = cullVisitor->isCulled(*geode); printf("Was my geode culled? %d\n", wasCulled); // traverse after getting the value to get previous value traverse(geode, nv); } }; I've dug around all over the forums and still can't seem to figure this out. Any help would be greatly appreciated. Thanks for the help! -- Christian[/quote] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43845#43845 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Finding whether a geode was culled
Perhaps the cull traversal is done every frame with a new instance of the cullvisitor ? So you can't get the previous value... To check it, print the "nv" pointer value : if it's always different from a traversal to another, there is probably no chance to get the "was culled" value by using your method. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43847#43847 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Vertex picker - multiple selection
Hi, That's naive, but it's also a good idea, I'll try that Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44038#44038 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Vertex picker - multiple selection
Hum... there's still a problem... how can I retrieve intersected vertices from polytope intersection ? >From a LineSegmentIntersector, I use this code : Code: intersection is a osgUtil::LineSegmentIntersector::Intersection instance from LineSegmentIntersector osg::Geometry* pGeometry = dynamic_cast(intersection.drawable.get()); if (pGeometry != NULL) { osg::ref_ptr pVertexArray = dynamic_cast(pGeometry->getVertexArray()); if (pVertexArray != NULL) { for (unsigned int i=0; i= 0) && (nearestVertexIndex < (int) pVertexArray->size()) ) { addVertexToSelection(pGeometry, nearestVertexIndex); } } } } -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44043#44043 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Single scene, multiple viewers : problem with texture
Hi, I've got a problem when viewing the same scene from two different viewers : - Viewer A with Camera A - Viewer B with Camera B I load a node with : Code: osg::ref_ptr pNode = osgDB::readNodeFile("..."); Then I do : Code: p_viewerA->setCamera(p_cameraA); p_viewerA->setSceneData(pNode); p_viewerB->setCamera(p_cameraB); p_viewerB->setSceneData(pNode); Everything works fine, but when viewer B is deleted, pNode's textures are no more rendered in viewer A (geometry is still rendered correctly). Is there anything special to do to share data between two viewer ? Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44072#44072 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Single scene, multiple viewers : problem with texture
Hi, Can you explain what you mean by "dynamically linking the node" ? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44088#44088 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Single scene, multiple viewers : problem with texture
I found the solution : Using the osgUtil::Optimizer::TextureVisitor to set all textures to "UnrefImageAfterApply = false" -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44104#44104 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Single scene, multiple viewers : problem with texture
Hi Robert, In my application, there is a "main viewer" to edit the scene, and the user can open/close secondary viewer windows. These secondary viewer windows are not limited in number (sure, there is hardware limits...) and the camera is independant from the other viewers (to see different point of view). So when user open a new secondary viewer window, I create a new viewer instance, a new camera, and the context is shared with the main window. When user close a secondary window, I delete the associated viewer to release some resources. The secondary windows can also be resized, so the viewport is also independant. Each viewer (main and secondary) are embeded in a Qt widget. Is there any way to do this with a composite viewer ? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44119#44119 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Structure in a Uniform Block
Hi, I would send parameters to my shaders using a structure, for example : Code: struct LightParameters { vec4 position; int type; vec4 color; float someParameter; float someMoreParameter; ... } So I'm having a look at Uniform blocks and Uniform Buffer Object... I've read this post : http://forum.openscenegraph.org/viewtopic.php?t=6775 and I've try the "osguniformbuffer" example, but I have some questions : In the "osguniformbuffer", the block size is set to : Code: const unsigned blockSize = 20 * sizeof(GLfloat); but in the GLSL code, the block is : Code: layout(std140) uniform colors0 { float DiffuseCool; float DiffuseWarm; vec3 SurfaceColor; vec3 WarmColor; vec3 CoolColor; }; So I don't understand the "20 * sizeof(GLfloat)" in the computation of the block size. How can I bind a C++ structure which mix vec4, float, int and other types to the Uniform Buffer Object ? Thank you! Cheers, Aurelien[/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44688#44688 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Vertex index from primitive index
Hi, I'm using PolytopeIntersector to handle some picking functionnality. The resturned intersection list contains primitives index, but I need to retrieve corresponding vertices. Is ther any OSG function to get vertices informations (drawable, index...) from a primitive index ? Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44961#44961 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector "distance" and Transform
Hi, Yes, I'm facing the same problem. I found a workaround by resorting intersections in a new container : for each intersection : - I compute the worldIntersectionPoint by transfoming the localIntersectionPoint in world coordinates - I compute the camera world position <-> worldIntersectionPoin distance It's a little slow, and it's only a workaround, but it works. Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44973#44973 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Render to FBO and multiSamples
Hi, I use a camera to render my main graph to an FBO. Then I render this FBO to screen with another camera and a quad. Like this : Code: Main camera (render to FBO) | |-- Main graph | |--- Camera (render to screen) | |- Quad I try to setup multisampling for the main camera : Code: p_camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT); p_camera->attach(osg::Camera::COLOR_BUFFER, p_renderTextureColor, 0, 0, false, 4, 4); p_camera->attach(osg::Camera::DEPTH_BUFFER, p_renderTextureDepth, 0, 0, false, 4, 4); I also try to set "sampleBuffers" and "samples" on the traits before creating context, but all I get is a black screen. When I render to screen, MSAA works great, but how to configure it for a FBO target ? My textures are created as follow : Code: // Main color texture p_renderTextureColor = new osg::Texture2D(); p_renderTextureColor->setTextureSize(p_osgViewport->width(), p_osgViewport->height()); p_renderTextureColor->setInternalFormat(GL_RGBA32F_ARB); p_renderTextureColor->setSourceFormat(GL_RGBA); p_renderTextureColor->setSourceType(GL_FLOAT); p_renderTextureColor->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::NEAREST); p_renderTextureColor->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::NEAREST); p_renderTextureDepth->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); p_renderTextureDepth->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); // Main depth texture p_renderTextureDepth = new osg::Texture2D(); p_renderTextureDepth->setTextureSize(p_osgViewport->width(), p_osgViewport->height()); p_renderTextureDepth->setSourceFormat(GL_DEPTH_COMPONENT); p_renderTextureDepth->setSourceType(GL_FLOAT); p_renderTextureDepth->setInternalFormat(GL_DEPTH_COMPONENT32F); p_renderTextureDepth->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::NEAREST); p_renderTextureDepth->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::NEAREST); p_renderTextureDepth->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); p_renderTextureDepth->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); Any help would be greatly appreciated. Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45024#45024 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Render to FBO and multiSamples
Hi Robert, I've try with : p_camera->attach(osg::Camera::COLOR_BUFFER, p_renderTextureColor, 0, 0, false, 2, 2); p_camera->attach(osg::Camera::DEPTH_BUFFER, p_renderTextureDepth, 0, 0, false, 2, 2); and 0 for "sampleBuffers" and "samples" on the traits, but the problem is still there. (My video card is a Quadro FX 4800) Is there anything else to configure ? What is the difference between the parameters "sampleBuffers" and "samples" ? Thanks, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45033#45033 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Render to FBO and multiSamples
Hi, I've done all the tests, and they are all ok. May the problem comes from the depth buffer attachment ? When I use : Code: p_camera->attach(osg::Camera::COLOR_BUFFER, p_renderTextureColor, 0, 0, false, 4, 4); p_camera->attach(osg::Camera::DEPTH_BUFFER, p_renderTextureDepth, 0, 0, false, 4, 4); or : p_camera->attach(osg::Camera::COLOR_BUFFER, p_renderTextureColor, 0, 0, false, 4, 4); p_camera->attach(osg::Camera::DEPTH_BUFFER, p_renderTextureDepth); There is black screen, but if I don't attach depth buffer, I got something rendered and no "Warning: detected OpenGL error 'invalid operation' at after RenderBin::draw(..)" errors in the console. Here is how I create my textures : Code: // Main color texture p_renderTextureColor = new osg::Texture2D(); p_renderTextureColor->setTextureSize(p_osgViewport->width(), p_osgViewport->height()); p_renderTextureColor->setInternalFormat(GL_RGBA32F_ARB); p_renderTextureColor->setSourceFormat(GL_RGBA); p_renderTextureColor->setSourceType(GL_FLOAT); p_renderTextureColor->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR); p_renderTextureColor->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::LINEAR); p_renderTextureColor->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); p_renderTextureColor->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); p_renderTextureColor->setDataVariance(osg::Object::DYNAMIC); p_renderTextureColor->setUseHardwareMipMapGeneration(false); p_renderTextureColor->setResizeNonPowerOfTwoHint(false); // Main depth texture p_renderTextureDepth = new osg::Texture2D(); p_renderTextureDepth->setTextureSize(p_osgViewport->width(), p_osgViewport->height()); p_renderTextureDepth->setSourceFormat(GL_DEPTH_COMPONENT); p_renderTextureDepth->setSourceType(GL_FLOAT); p_renderTextureDepth->setInternalFormat(GL_DEPTH_COMPONENT32F); p_renderTextureDepth->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR); p_renderTextureDepth->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::LINEAR); p_renderTextureDepth->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); p_renderTextureDepth->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); p_renderTextureDepth->setDataVariance(osg::Object::DYNAMIC); p_renderTextureDepth->setUseHardwareMipMapGeneration(false); p_renderTextureDepth->setResizeNonPowerOfTwoHint(false); Thank you! Cheers, Aurelien[/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45036#45036 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Render to FBO and multiSamples
I'm still investigating on it, and it's really weird : the depth buffer seems to be drawn over the color buffer : when I come close to my model, the image because darker... This doesn't appear with FRAME_BUFFER render target. Is that possible ? I saw some messages on the forum about implicit attachment... is there any link with my problem ? My full render graph is below (the problem seems to be in the post process camera) : Code: - Main camera (color / depth render to FBO) | |--- main scene | |--- Post process camera (render a quad using main camera color texture to a new FBO) | | | |-- Quad | |--- No post process camera (color / depth render to FBO, color FBO is shared with post process camera, depth FBO is shared with main camera) | | | |-- Objects without post processing | | |--- Render to screen camera (render a quad to screen using post process camera color texture) | | | |-- Quad Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45040#45040 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Render to FBO and multiSamples
Hi, I solved my problem, but I don't really understand how. What I did : 1. attach the same depth buffer FBO to all cameras 2. configure multisamples only on the first camera color buffer attachment 3. always use a shader program to render post processing, even if there is no post processing Point 1 : I really don't understand what difference it makes Point 2 : I use a color buffer shared between 2 cameras, it seems I can only configure multisamples for the firs one Point 3 : really strange : if I render the textured quad to screen whitout any shader, all screen become darker when the camera is very close to an object Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45047#45047 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] FBO and mipmaps
Hi, I'm using FRAME_BUFFER_OBJECT as render target to render into an FBO. I would like to generate mipmaps for this FBO... How can I do this ? Is there any function like "myFBOTexture->buildMipMaps()" that I can call in my FBO camera's post-render callback ? Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45163#45163 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] FBO and mipmaps
Does that mean mipmap generation is fully automated ? If I try to access to FBO's mipmaps from a shader program, mipmaps will be available ? Are the mipmaps always generated (even if not used) or are they only generated "on demand" when they are used ? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45165#45165 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Render to VBO?
Hi, I'm also interested by render-to-VBO, have you found any correct way to implement this with OSG ? Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45249#45249 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Binding of a Texture2DArray
Hi, I use a Texture2DArray in my application. All objects are rendered using shaders, and most of them use the TextureSampler2DArray data. So I made a top object in my scene graph, and I assign to its StateSet : - a uniform (SAMPLER2DArray) with the Texture2DArray unit number - the Texture2DArray This top object doesn't have any geometry, it's only to store a "common" stateset. And, thanks to stateset inheritance, all my objects shaders receive the uniform and the Texture2dArray binding. Everything works well if I bind the Texture2DArray to unit 0 or unit 1, but if I bind it to unit 2, 3, 4... the texture data are not binded (I saw that in gDebugger : texture unit is not binded) I need to bind it to unit 2 because some of my objects models use unit 0 and unit 1 for regular textures. Is there any reason for this problem ? How can I fix it ? My hardware : Quadro 4800 FX - Windows 7 My code : Code: p_root->getOrCreateStateSet()->setTextureAttribute(2, p_textureArray, osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE); (I tried with "setTextureAttributeAndModes", it doesn't work, and according to this post : http://forum.openscenegraph.org/viewtopic.php?t=5237&highlight= I think I should use "setTextureAttribute") Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45308#45308 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] compileGLObjects problem
Hi, I use a "hand-made" geometry class, derived from "osg::Geometry" (osg 3.0.1, Win 7 64bits) My geometry is filled with vertices and indices, and configured as follow : Code: p_myGeometry->setUseDisplayList(false); p_myGeometry->setUseVertexBufferObjects(true); p_myGeometry->setDataVariance(osg::Object::STATIC); p_myGeometry->setVertexArray(p_myVertices); p_myGeometry->addPrimitiveSet(p_myPrimitiveEBO); p_myGeometry->setComputeBoundingBoxCallback(new SeaBoundingBoxCallBack()); There are 3 methods re-implemented : Code: void MyGeometry::compileGLObjects(osg::RenderInfo& renderInfo) const { // Do special stuff allocation on Cuda / OpenCl... and bind to openGL objects osg::Geometry::compileGLObjects(renderInfo); } // void MyGeometry::drawImplementation(osg::RenderInfo& renderInfo) const { // Retrieve data from Cuda / OpenCL special stuff allocated in "compileGLObjects" osg::Geometry::drawImplementation(renderInfo); } // voidMyGeometry::releaseGLObjects(osg::State* pState) const { // Do special stuff release osg::Geometry::releaseGLObjects(pState); } Everything works fine if I create the Scene Graph, then setup a viewer and display the scene graph. But if I create a scene graph without this "MyGeometry" object, setup the viewer, display the scene graph, and THEN insert a new "MyGeometry", neither "compileGLObjects" or "releaseGLObjects" are called... Is there any reason ? I saw in "compileGLObjects" documentation : > Note: > Operation is ignored if _useDisplayList is false or VertexBufferObjects are > not used. > but I use : Code: p_myGeometry->setUseVertexBufferObjects(true); p_myGeometry->setVertexArray(p_myVertices); Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45453#45453 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] compileGLObjects problem
I found a workaround : 1/ In MyGeometry::drawImplementation : => check if objects are compiled for this context, if not, call "compileGLObjects" 2/ In MyGeometry::~MyGeometry : => call releaseGLObjects(NULL) But I'm surprised that I have to do this "by hands".. did I miss something ? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45464#45464 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] compileGLObjects problem
Thanks for all these clarifications ! Is it the same mechanism for StateAttribute ? For example, if I create a subclass "MyTexture" of osg::Texture, will compileGLObjects/releaseGLObjects methods of "MyTexture" be automatically called when needed ? > If you subgraphs aren't attached to the viewer's scene graph it won't be able > to call your detached subgraphs > though, so in these instances you'll need to call the methods explicitly. Does that mean I should call "releaseGLObjects" every time I remove a subgraph from the main viewer graph ? Is it enough to call it on the subgraph top object or should I call it recursively ? Thanks Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45477#45477 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Disable all antialiasing
Hi, In my application, I need to render 2 buffers : - color buffer - "object-code" buffer I obtain the color-buffer by normal rendering to an FBO. For some algorithms purpose (object tracking, objects statisitics, etc...) I need also an "object-code" buffer with, for each pixel, an int value corresponding to the object. I can do this with a shader in another FBO, but I need this buffer to be not antialiased at all. For example, if the background code is "0", and there are 2 objects in the scene (codes "10" and "20") the final "object-code" buffer must be filled with "0", "10" and "20" but no other value. How can I configure my rendering to do so ? Maybe using the stencil buffer as a object-code buffer (I don't know if antialiasing such as MSAA affect stencil buffer) ? Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45619#45619 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Disable all antialiasing
Hi, I'm facing a problem when creating my FBO : Code: Warning: detected OpenGL error 'invalid operation' at After Renderer::compile RenderStage::runCameraSetUp(), FBO setup failed, FBO status= 0x8cd6 Warning: FrameBufferObject: could not create the FBO RenderStage::runCameraSetUp(), FBO setup failed, FBO status= 0x0 Warning: detected OpenGL error 'invalid value' at after RenderBin::draw(..) Warning: FrameBufferObject: could not create the FBO RenderStage::runCameraSetUp(), FBO setup failed, FBO status= 0x0 PixelBufferWin32::bindPBufferToTextureImplementation, wglBindTexImageARB error: LÆopÚration a rÚussi. Warning: detected OpenGL error 'invalid operation' at after RenderBin::draw(..) Warning: detected OpenGL error 'invalid operation' at end of SceneView::draw() Warning: detected OpenGL error 'invalid operation' at start of State::apply(StateSet*) Warning: detected OpenGL error 'invalid operation' at end of State::apply(StateSet*) My code : Code: p_renderTexture = new osg::Texture2D(); p_renderTexture->setTextureSize(200, 200); p_renderTexture->setInternalFormat(GL_RGBA_INTEGER_EXT); p_renderTexture->setSourceFormat(GL_RGBA32I_EXT); p_renderTexture->setSourceType(GL_BYTE); p_renderTexture->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::NEAREST); p_renderTexture->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::NEAREST); p_renderTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); p_renderTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); p_renderTexture->setDataVariance(osg::Object::DYNAMIC); p_renderTexture->setUseHardwareMipMapGeneration(false); p_renderTexture->setResizeNonPowerOfTwoHint(false); I think there is something wrong with that : Code: p_renderTexture->setInternalFormat(GL_RGBA_INTEGER_EXT); p_renderTexture->setSourceFormat(GL_RGBA32I_EXT); p_renderTexture->setSourceType(GL_BYTE); For another application, I use : Code: p_renderTexture->setInternalFormat(GL_RGBA32F_ARB); p_renderTexture->setSourceFormat(GL_RGBA); p_renderTexture->setSourceType(GL_FLOAT); which works well to render to a "floating point" FBO Thanks for your help ! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45677#45677 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Disable all antialiasing
Hum... I think I'm swapped two parameters. The following seems to work : Code: p_renderTexture->setInternalFormat(GL_RGBA32I_EXT); p_renderTexture->setSourceFormat(GL_RGBA_INTEGER_EXT); p_renderTexture->setSourceType(GL_BYTE); Could you explain me the difference between these 3 parameters ? setInternalFormat => is it the data storage format ? so here, R, G, B and A components stored as a single 32 bit integer ? setSourceFormat=> I don't really understand this parameter... setSourceType=> I don't really understand this parameter... -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45678#45678 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Intersection visitor and osg::Viewport
Hi, I'm experiencing some problems to get correct intersections in following situation : I have a group in my scene graph which have a Viewport StateAttribute to modify its rendering frame on screen. All is works well for render, but intersector seems lost wih nodes below my group. Is there any viewport change management in osg::Intersector ? I didn't find any (except when traversing camera). Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=55808#55808 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Intersection visitor and osg::Viewport
Hi, I've tried the following and it seems to solve my problem : Code: void IntersectionVisitor::apply(osg::Group& group) { if (!enter(group)) return; osg::Viewport* pViewport = NULL; if (group.getStateSet() != NULL) { pViewport = dynamic_cast(group.getStateSet()->getAttribute(osg::StateAttribute::VIEWPORT)); } if (pViewport != NULL) { pushWindowMatrix(pViewport); push_clone(); traverse(group); pop_clone(); popWindowMatrix(); } else { traverse(group); } leave(); } This modification was just a test, but I wonder if this should not be in every "apply" method of IntersectionVisitor, maybe with these modifications : - take care of the override value (do not push window matrix if the attribute is overriden) - push the window matrix and the intersector clone BEFORE the "enter" test to ensure the "enter" test is done with correct coordinates frame Or am I wrong with that and I've missed something ? Thanks. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=55809#55809 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Performance of Uniform-Buffer-Objects and question to the software design of osg::BufferObject
Hi, UBO are not designed for random access from shader, but for block access. For hardware instancing, you should get best performances using vertex attribute divisor. Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56020#56020 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Performance of Uniform-Buffer-Objects and question to the software design of osg::BufferObject
Hi, If you change data often, you can declare the vertex attribute array usage as "STREAM_DRAW". And to pass 4x4 matrices, you can do this : - declare 4 vertex attributes array in OSG - fill them with the 4 colums of your matrices - bind them to attributes units 4, 5, 6, 7 (for example) - in your shader, you can read "mat4" type attribute on unit 4 But sometimes, passing full mat4 to shader can be slower than passing less data (only a vec3 for a position) and compute the matrix in the shader. Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56038#56038 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] LineSegmentIntersector numerical imprecisions
Hi Robert, This is perhaps un-related, but in a previous project, I've experienced intersections numerical precision problems with "big" scenes, and I've switched to the "double precision" line segment intersector taken fomr osgEarth source code. Maybe swiching from float precision to double precision could also help dealing wih the problem described in this thread ? Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56057#56057 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] OSG errors when running on a virtual machine
Hi, I've got some bad experience with virtual machines. > The 3D hardware acceleration in a virtual machine is generally not that good. In fact, hardware acceleration is usualy not available at all on a Virtual Machine. Because this is a virtual machine. Just like a remote session on windows : you can't access directly to the hardware. There is 2 potential solutions : - try finding a virtual macine system which allow direct access to the hardware (don't know the status, but NVidia made a lot of efforts on this since last year) - try a "full software" openGL implementation, like MESA Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56129#56129 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Possible bug in osg::State::applyShaderCompositionUniform
Hi Robert, A few month ago, you solved one of my issues : http://forum.openscenegraph.org/viewtopic.php?t=11769&postdays=0&postorder=asc&start=14 Today I've discovered some problems with this approach (I use it for materials, as you suggested in your post) : the shader composition uniforms seems to not been inherited correctly. I've spotted the problem source : in void State::apply(const StateSet* dstate), there is this line : _currentShaderCompositionUniformList.clear(); So all shader composition uniforms are cleared at each StateSet apply. I've tried to comment this line and everything seems to work. Since I don't really understand the shader cmoposition uniforms system, can you give me some advices on this issue ? Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56433#56433 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Possible bug in osg::State::applyShaderCompositionUniform
Hi rmilh, > If there is some interest I could send all the stuff to the submissions at > the end of this week Thanks for the sharing offer, I'm interested ! I think I've made some progress in the analysis of my problem, could you just test the following inside your experimental "shader composition" project ? (I would like to know if you have any side effects.) in osg/State.cpp : in the method : State::apply(const StateSet* dstate) comment the following line : _currentShaderCompositionUniformList.clear(); Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56446#56446 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Possible bug in osg::State::applyShaderCompositionUniform
Hi, Thanks for testing ! I've already seen the problem of the growing list... But I don't know how to avoid this, because if I left the call to "currentShaderCompositionUniformList.clear()", some uniforms are not properly applied. For example : - Node A : Shader Program + Shader Composition Uniforms Child node B : nothing Child node C : Shader Program In this case, Shader Composition Uniforms are properly applied on the Shader Program from node A, but not on shader program from node C Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56450#56450 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Possible bug in osg::State::applyShaderCompositionUniform
Hi, Have a look here to see why I use this (on Robert's advice) : http://forum.openscenegraph.org/viewtopic.php?t=11769 I know this is more like a "workaround", but it is really usefull to be able to write StateAttributes classes which manage and apply their own uniforms. To solve my problem described in this post, my guess is I have to replace the "_currentShaderCompositionUniformList" with a stack in which we can "push" and "pop" uniforms when StateAttributes are "pushed" and "poped". Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56452#56452 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Possible bug in osg::State::applyShaderCompositionUniform
Hi, > If you do change the list to stack so you can push/pop uniforms you will end > up redoing standard uniform handling but this time with a parallel uniform > list. Yes, and I think this is what I need : - a standard uniform list, which contains uniforms setted from regular osg::Uniform instances - a "comes-from-stateAttribute" uniform list, in the same way there is "associated modes" with some StateAttributes In my opinion, theses uniforms are not really linked to the ShaderComposition system, but complementary : sometimes you just want to push some "StateAttribute-associated" uniforms in the state. Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56461#56461 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Possible bug in osg::State::applyShaderCompositionUniform
For example, push uniforms with ambient, diffuse, specular and shininess values from osg::Material, for OpenGL 3.3 It could also be used for application-specific StateAttribute classes, for example an "ObjectData" StateAttribute which push several uniforms on the state. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56465#56465 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Proposal for uniforms applied from within a StateAttribute
Hi, As discuted multiple times with Robert and others, sometimes it's really usefull to have a StateAttribute which also provide its own uniforms. For example, I use it in a modified osg::Material class to apply maerial values as uniform or to handle specific "ObjectData" StateAttribute classes which apply one or several uniform. By now, I do this using state.applyShaderCompositionUniform(_myUniform); from the "apply" StateAttribute method. It perfectly fit my needs, but I discovered a bug : these uniforms are not part of the State uniform map, so they are not applied to osg::Programs below it. Here is a proposal to handle this properly : 1/ add a "getBuiltInUniformList()" in the StateAttribute class => this method is const, inline and should be very fast, and return an empty list by default 2/ Each StateAttribute subclass can populate this list with desired uniforms, and change their values when needed 3/ handle this list in osg::State when attributes are applied => something is really done only if the list is not empty, which should not happen really often 4/ Maybe add a compilation DEFINE to use this feature or not (very usefull, but very application-specific or if you want to handle standard osg StateAttributes in OpenGL > 3.2) 5/ Or add a test, like already done for the "_shaderCompositionEnabled" flag Here is a piece of code to show what I have in mind (code not tested...) : Code: / // New typedef : / typedef std::map< std::string,ref_ptr< Uniform > > BuiltInUniformList; / // New method on StateAttribute : / inline const BuiltInUniformList& getBuiltInUniformList() const { return _builtInUniformList; } / // Modified method on State : / inline void State::pushAttributeList(AttributeMap& attributeMap,const StateSet::AttributeList& attributeList) { for(StateSet::AttributeList::const_iterator aitr=attributeList.begin(); aitr!=attributeList.end(); ++aitr) { // get the attribute stack for incoming type {aitr->first}. AttributeStack& as = attributeMap[aitr->first]; if (as.attributeVec.empty()) { // first pair so simply push incoming pair to back. as.attributeVec.push_back( AttributePair(aitr->second.first.get(),aitr->second.second)); // Push built-in uniforms from the StateAttribute pushUniformList(_uniformMap, aitr->second.first->getBuiltInUniformList(), aitr->second.second); } else if ((as.attributeVec.back().second & StateAttribute::OVERRIDE) && !(aitr->second.second & StateAttribute::PROTECTED)) // check the existing override flag { // push existing back since override keeps the previous value. as.attributeVec.push_back(as.attributeVec.back()); // Push built-in uniforms from existing back since override keeps the previous value. pushUniformList(_uniformMap, as.attributeVec.back().first->getBuiltInUniformList(), as.attributeVec.back().second); } else { // no override on so simply push incoming pair to back. as.attributeVec.push_back( AttributePair(aitr->second.first.get(),aitr->second.second)); // No override on so simply push incoming built-in uniforms to back. pushUniformList(_uniformMap, aitr->second.first->getBuiltInUniformList(), aitr->second.second); } as.changed = true; } } / // New method on State : / inline void State::pushBuiltInUniformList(UniformMap& uniformMap,const StateSet::BuiltInUniformList& uniformList, StateAttribute::OverrideValue value) { for(StateSet::BuiltInUniformList::const_iterator aitr=uniformList.begin(); aitr!=uniformList.end(); ++aitr) { // get the uniform stack for incoming uniform {aitr->first}. UniformStack& us = uniformMap[aitr->first]; if (us.uniformVec.empty()) { // first pair so simply push incoming pair to back. us.uniformVec.push_back( UniformStack::UniformPair(aitr->get(),value)); } else if ((us.uniformVec.back().second & StateAttribute::OVERRIDE) && !(value & StateAttribute::PROTECTED)) // check the existing override flag { // push existing back since override keeps the previous value. us.uniformVec.push_back(us.uniformVec.back()); } else { // no override on so simply push incoming pair to back. us.uniformVec.push_back( UniformStack::UniformPair(aitr->get(),value)); } } } / // Modified method on State : / inline void State::popAttributeList(AttributeMap& attributeMap,const StateSet::AttributeList& attributeList) { for(StateSet::AttributeList::const_iterato
Re: [osg-users] Proposal for uniforms applied from within a StateAttribute
Hi Robert, No problem, script support in OSG will be great ! I'll try to make an optimized implementation and submit it. Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56472#56472 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Picking implementation
Hi, I've got the same picking problem with several mesh (which use vertex displacement or tesselation). To solve that, I always render my scene in a FBO, with 2 color attachements : - first draw buffer is a regular color texture - second draw buffer is a texture with only 1 channel, in "int" format My shaders always write an "objectId" value in the second buffer. Then I can pick a pixel at anytime. You can also get the 3D world position of the pixel using its window coordinates, its depth value and the camera matrices. This not ideal picking, it consume a lot of GPU memory bandwitdh (but on modern GPUs it's not a problem), but it's easy to setup and for applications which need exact picking it may be the best solution. Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56528#56528 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Picking implementation
Hi, > but I can't really afford the per-frame cost On modern GPU, the per-frame cost is near zero with reasonable scenes. (not a full 3d scene of 1+ objects like in video games). The heavy cost is paid when you actually download some data from GPU to read back, but you can do that only on picking request. Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56535#56535 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] mixing OpenGL with OSG - textures
Hi, I've done the same a few weeks ago : - a customer low-level OpenGL API is creating some ressources (like textures) - my OSG applicatino have to use these ressources So I created a "MyTexture" class : Code: class MyTexture : public osg::StateAttribute { private: CustomerGL::Texture p_CustomerTexture; public: Texture(); Texture(CustomerGL::Texture* p_CustomerTexture); Texture(const MyTexture& texture,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); virtual osg::Object* cloneType() const; virtual osg::Object* clone(const osg::CopyOp& copyop) const; virtual bool isSameKindAs(const osg::Object* pObj) const; virtual const char* libraryName() const; virtual const char* className() const; private: Texture &operator=(constMyTexture& other); // No copy protected: virtual ~Texture(); public: CustomerGL::Texture* CustomerGLTexture() const; void setCustomerGLTexture(CustomerGL* pGLBoxTexture); virtual osg::StateAttribute::Type getType() const; virtual bool isTextureAttribute() const; virtual int compare(const osg::StateAttribute& stateAttribute) const; virtual bool getModeUsage(osg::StateAttribute::ModeUsage& modeUsage) const; virtual void apply(osg::State& state) const; virtual void compileGLObjects(osg::State& state) const; virtual void resizeGLObjectBuffers(unsigned int maxSize); virtual void releaseGLObjects(osg::State* pState=NULL) const; }; The virtual methods are pretty simple to implement : have a look to osg::Texture2D implementations. By subclassing "osg::StateAttribute" and not "osg::Texture", I'm sure that all OSG algorithms (such as texture resizing) will not be applied to MyTexture class. Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56673#56673 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] mixing OpenGL with OSG - textures
Hi, At first, I was playing with Texture::TextureObject, but I found difficult to make OSG to delegate the control on ressource allocation / release (which are managed by my customer's library) so I've switched to a subclass. Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56679#56679 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] mixing OpenGL with OSG - textures
Hi, Here it is : Code: #include #include // MyTexture::MyTexture() : osg::StateAttribute () , p_CustomerTexture (NULL) { } // MyTexture::MyTexture(CustomerTexture* pCustomerTexture) : osg::StateAttribute () , p_CustomerTexture (NULL) { setCustomerTexture(pCustomerTexture); } // MyTexture::MyTexture(const MyTexture& texture, const osg::CopyOp& copyop) : osg::StateAttribute (texture, copyop) , p_CustomerTexture (NULL) { setCustomerTexture(texture.customerTexture()); } // osg::Object* MyTexture::cloneType() const { return new MyTexture (); } // osg::Object* MyTexture::clone(const osg::CopyOp& copyop) const { return new MyTexture (*this, copyop); } // bool MyTexture::isSameKindAs(const osg::Object* pObj) const { return dynamic_cast(pObj)!=NULL; } // const char* MyTexture::libraryName() const { return "MyLibrary"; } // const char* MyTexture::className() const { return "MyTexture"; } // MyTexture::~Texture() { } // CustomerTexture* MyTexture::customerTexture() const { return p_CustomerTexture; } // void MyTexture::setCustomerTexture(CustomerTexture* pCustomerTexture) { p_CustomerTexture = pCustomerTexture; } // osg::StateAttribute::Type MyTexture::getType() const { return osg::StateAttribute::TEXTURE; } // bool MyTexture::isTextureAttribute() const { return true; } // int MyTexture::compare(const osg::StateAttribute& stateAttribute) const { MyTexture const* pOther = dynamic_cast(&stateAttribute); if (pOther != NULL) { if (p_CustomerTexture == pOther->GLBoxTexture()) { return 0; } return 1; } return -1; } // bool MyTexture::getModeUsage(osg::StateAttribute::ModeUsage& modeUsage) const { if (p_CustomerTexture != NULL) { modeUsage.usesTextureMode(p_CustomerTexture->target()); return true; } return false; } // void MyTexture::apply(osg::State& /*state*/) const { if (p_CustomerTexture != NULL) { // Execute a "glBind" using the pre-allocated customer texure id // Take care of mulitple context/sharing contexts p_CustomerTexture->bindYourCustomerTexture(); } } // void MyTexture::compileGLObjects(osg::State& /*state*/) const { // Nothing to do : the OpenGL texture should be managed by the "CustomerTexture" class } // void MyTexture::resizeGLObjectBuffers(unsigned int /*maxSize*/) { // Nothing to do : the OpenGL texture should be managed by the "CustomerTexture" class } // void MyTexture::releaseGLObjects(osg::State* /*pState*/) const { // Nothing to do : the OpenGL texture should be managed by the "CustomerTexture" class } Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56708#56708 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] IncrementalCompileOperation OnDemandMode
Hi, I used to do something like that... from my memories, all that I can say is I used the "osgUtil::GLObjectsVisitor" to do a "on-demand-compile-traversal" right after loading an object. Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56716#56716 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] IncrementalCompileOperation OnDemandMode
Hi, Sorry, I wasn't able to retrieve this old piec of code... The state can be obtained from the viewer's graphics context, and the RenderInfo can be created using the state and the viewer. Before running the visitor, you should make sure that the viewer's OpenGL context is current (makeCurrent). Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56744#56744 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Preferred method for per-context uniforms
Hi, > If you have just a single uniform value per context then I'd simply place the > Uniform on the each if the viiewer's osg::Camera's StateSet, such that each > Camera assigned to each Context gets it's own state inherited down including > the Uniform. > Some nodes have a cull callback. During the cull traversal, the callback > identify the current view/context > and push the corresponding state set in the render graph, traverse the > children and pop the state set. I have exactly the same needs, and I use the same solutions ! - Some of my "per-view" uniforms are "static" : their value never change => those are added on viewer's camera's stateset - Some of my "per-view" uniforms are "dynamic" : their value change at each frame (based on camera position, user settings, a specific object position...) => those are pushed at cull traversal : the view is identified from the cullvisitor, specific value computation is done there and the uniform is pushed. Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56954#56954 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Preferred method for per-context uniforms
Hi, At cull traversal, I do the following (this is pseudo-code!) : Code: cullTraversal(pCullVisitor) { // Get per-view-data perViewData = getOrCreatePerViewData(pCullVisitor); // Compute "dynamic" uniforms perViewData.pDynamicUniform_1->set(value); perViewData.pDynamicUniform_2->set(value); perViewData.pDynamicUniform_3->set(value); // Push per-view data pCullVisitor->pushStateSet(perViewData.pStateSet); // Traverse node traverse() // Pop per-view data pCullVisitor->popStateSet(); } The "getOrCreatePerViewData" method returns a "PerViewData" struct : Code: struct PerViewData { osg::ref_ptr pStateSet; osg::ref_ptr pDynamicUniform_1; osg::ref_ptr pDynamicUniform_2; osg::ref_ptr pDynamicUniform_3; PerViewData() { pStateSet = new osg::StateSet(); pDynamicUniform_1 = osg::Uniform(); pDynamicUniform_2 = osg::Uniform(); pDynamicUniform_3 = osg::Uniform(); pStateSet->addUniform(pDynamicUniform_1); pStateSet->addUniform(pDynamicUniform_2); pStateSet->addUniform(pDynamicUniform_3); } } PerViewData getOrCreatePerViewData(pCullVisitor) { return m_perViewDataMap[pCullVisitor]; } Just be carrefull to : - remove "PerViewData" instance from the "m_perViewDataMap" when the corresponding "pCullVisitor" instance is destroyed. (use an osg::Observer here) - add any necessary mutex in multithreading mode Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56957#56957 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Preferred method for per-context uniforms
Hi, > And then index that by the GC ID if it's available through the > cv->getCurrentCamera(). That's a bit different for my solution : - in my idea, you get "per-view" uniforms : even if multiple views runs with the same graphics context, you still have different uniforms - in your idea, you get "per-context" uniforms This can be really usefull too, but this is really different in some situations ! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56963#56963 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Preferred method for per-context uniforms
Hi Robert, > The CullVisitor::getRenderInfo() method could be used to access to the > osg::State object and hence ContextID that is relevant to the current cull > traversal. Will this works with shared contexts ? Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56966#56966 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgDEM] calculate height above ellipsoid in vertex shader
Hi, I'm facing the same problem, and I can't pre-compute vertex attributes on CPU because my vertex are moved by the shader him-self (displacement mapping). I've tried to use double matrices, but these leads to a lot of compatibility problem. Since the precision problem is in the "temporary computation" and not in the final result (result values are small and fit well in a 32 bits float) I precompute (on CPU) lot of values in a 2048 (or 4096) pixels wide Texture1D. In the shader I have only to read in this look-up-table. There are some limitations (linear sampling, max input value in look up table...) but for my problem, it works very well. Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=57581#57581 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Pop Buffers with OpenSceneGraph
Hi, > 5. Because the technique depends on the usage of a vertex shader I would add > two static methods one returns a basic osg::Program with phong shading and > another one only returns the shader code with the necessary uniforms and a > vertex quantization function that should be used in the shader. Maybe there's an interesting idea in osgEarth : the use pseudo-loaders to create library-specific objects. It's possible to write a plugin which create shaders in the following way, by mapping "popgeometry" file extension to a pseudo-loader. The file name let you know the shader type : Code: osg::Shader* vertexShader = osgDB:readShaderFile("vertexShader.popgeometry") osg::Shader* fragmentShader = osgDB:readShaderFile("fragmentShader.popgeometry") You can create osg::Node, osg::Shader or any osg::Object subclass with a plugin, and even add parameters, in the filename or in the "options" parameters : Code: osg::Shader* vertexShader = osgDB:readShaderFile("vertexShader.lod1.popgeometry") osg::Shader* vertexShader = osgDB:readShaderFile("vertexShader.lod2.popgeometry") osg::Shader* vertexShader = osgDB:readShaderFile("vertexShader.lod3.popgeometry") osg::Shader* fragmentShader = osgDB:readShaderFile("fragmentShader.phong.popgeometry", options) osg::Shader* fragmentShader = osgDB:readShaderFile("fragmentShader.flat.popgeometry", options) osg::Shader* fragmentShader = osgDB:readShaderFile("fragmentShader.debug.popgeometry", options) Have a look here, there is a list of all "factory" methods available to plugins : http://trac.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a01311.html#a78e08a10faa6c81a5c255d14f7c30cd7 And the base class for the plugins : http://trac.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a00658.html To write a new plugin, an easy way is copy/paste the "ReaderWriterOBJ.cpp" file from the "obj" plugin, in "ReaderWriterPopGeometry.cpp" and replace all the code/parameters related to "obj" file format by code to handle "PopGeometry" objects creation (not from actually files, but using "options" parameters and your algorithms) Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=59104#59104 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] New primitive restart mode "leaking" into other nodes
Hi, About the "leaking" problem : it is because the GL_PRIMITIVE_RESTART mode has no defaut value in OSG. So if you set anywhere in your scene graph, its value (ON or OFF) will not go back to a default "OFF" value (which is not set anywhere) It's probably possible to add this default "OFF" value in the OSG source code, but since GL_PRIMITIVE_RESTART is not available on all hardwares/profile, it's probably better to set it by yourself, for example, use this on your main camera : camera->getOrCreateStateSet()->setMode(GL_PRIMITIVE_RESTART, osg::StateAtribute::OFF) About using this feature : primitive restart is a "low-level" OpenGL feature, very difficult to integrate in a generic high-level framework like OSG. It can break ray-intersections code, introduce error in statistics, and a lot of other problems. To get a full integration, it needs a lot of work, and the benefit is very little : on modern hardward, using primitive restart does not really make faster performances, it's much more efficient to use "indexed arrays" and optimize the index order to use the GPU post-transform cache at its maximum. The osg::PrimitiveRestartIndex class is only a "helper" state attribute for defining the restart index, not for "use it as an integrated feature, ready out-of-the-box" If you really need to use primitive restart, you can read this : http://forum.openscenegraph.org/viewtopic.php?t=11817&highlight=gl_primitive_restart But trust me, I avoid primitive restart every time I can (in fact, I only use it if my client really wants this, a good mesh indexing with a GPU post-transform cache optimization algorithm is more efficient) About post-transform cache : https://www.opengl.org/wiki/Post_Transform_Cache And keep in mind the following : even with a very efficient use of the post-transform cache it will only speed up (a little...) the vertex stage of your shader. So if your vertex shader consume only 20% of the rendering time (80% dispatched between texture memory access, rasterization, fragment operations...) you better should use your developpement time to optimize your scene graph hierarchy, the number of switch between StateSet, manually optimize your models (reduce vertex count, reduce drawables count, use texture atlas...) etc... Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=59128#59128 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] New primitive restart mode "leaking" into other nodes
Hi, > But I am a little confused, why you judge the good old primitive restart > functionality Because triangle strips are no longer faster than triangles. Using triangles with an optimized idexing (see post-transform cache optimization) is very performant. I also use GPU computing CUDA / OpenCL) to generate mesh in real time, and since I've switched to triangle instead of triangle strip, the performances are better : the code is simpler so I can use my time to optimize the bottlenecks (which are not the vertex shader, the only step optimized by primitive restart) > Nevertheless I have to use PrimitiveRestart either way, because my primitives > are created interactivly by a OSG-Compute and otherwise I had to have > numerous buffers, one for each primitive. You can simply use indexed triangles, not triangles strips. So you don't need primitive restart, you just need a little more space for storing indexes, but this is no problem on modern hardware. > If I got it right, your plugin makes it possible to set a > PrimitiveRestartIndex. But how do I afterwards activate the mode for only > some Geodes. Your proposal with the camera ( > camera->getOrCreateStateSet()->setMode(GL_PRIMITIVE_RESTART, > osg::StateAtribute::OFF) ) would affect all nodes, wouldn't it? Use camera->getOrCreateStateSet()->setMode(GL_PRIMITIVE_RESTART, osg::StateAtribute::OFF) on camera to set a default "OFF" value. Then of course, use node->getOrCreateStateSet()->setMode(GL_PRIMITIVE_RESTART, osg::StateAtribute::ON) on all nodes where you want to activate it. > I already came across your post before. I did not concentrate on it, because > you wrote it, when OSG 3.2 was not out yet. And as the release notes of OSG > 3.2 mention PrimitiveRestart should be natively included now and I thought > your implementation is therefore deprecated!? This post was a contribution to add "PrimitiveRestart" functionnality. So it's not outdated, it's whats new in 3.2 Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=59136#59136 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] New primitive restart mode "leaking" into other nodes
> Instead of calling many "singleDraws" or a "multiDraw with all its offsets > you have to remember" I think you're talking about draw-instanced feature here, which is completely different, but very efficient. Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=59137#59137 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] New primitive restart mode "leaking" into other nodes
Hi, > drawing 10 lines, needs 10*4=40 indices using LINES_ADJACENCY but only 12 > indices using GL_LINESTRIP_ADJACENCY. So when you need adjacency, the > PrimitiveRestart mode may still have some advantages. I didn't think about adjacency. In this case, it may still make sense to use primitive restart. But if you have 100.000 lines, and use "unsigned int" vertex index, you've got 100.000 * 4 = 400.000 = about 400 ko of indices data stored on GPU. This amount of data can be processed without any problem by a modern GPU. The bottlenecks are rarely on vertex shader stage, but often in fragment shader stage, sometimes in geometry / tesselation shader stages (especially if you use barriers). Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=59154#59154 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Promoting Drawable from being subclassed from osg::Object to osg::Node
Hi, Pjotr wrote: > Also whats the point of a Drawable::Update/Event/CullCallback now, should't > they be deprecated now that a Drawable is a Node and can use the Node's > callbacks? I think Pjotr is right there. Maybe there's a way to solve this using C++ "type erasure" : create an "osg::AbstractCallback" class as nearly an empty shell, and all rewrite all current callbacks classes/structures as child of "osg::AbstractCallback". All callbacks management methods (get/set/...) should also use (internally) "osg::AbstractCallback" interface. Maybe it would be easier to keep compatibility with exisiting code. Then if you set the use of "osg::CallbackObject" (which is also derived from "osg::AbstractCallback") as the standard way in new code, it's possible to clean code and break API compatibility in a future OSG version simply by removing the "osg::AbstractCallback" class and keep only "osg::CallbackObject" as entry point in callbacks system. Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=59634#59634 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Using osga archive bigger than 2Go
Hi, I'm using osga archive to store a lot of small files inside a single big one. I'm compiling a 32-bit windows executable with MSVC-2008. All librairies (osg 3.3.1 and dependencies) are compiled with the same compiler. Under this configuratin, I have no problem reading/writing files > 2Go (or even 4Go) with GDAL or libTiff libraries, for example. But creating a big osga archive always fails when 2Go limit is execeed (32 bit signed integer max value) I'm currently looking inside osga source code, but I don't find any reason why the current code should not work. Is there any body here who experienced the same problems ? Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=59725#59725 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Using osga archive bigger than 2Go
When using .ive files, I can export archive bigger than 4 Go... So I think the problem is in osgb serializer... -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=59729#59729 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Using osga archive bigger than 2Go
Hi, I've found the problem : In file "osgPlugins\osg\BinaryStreamOperator.h", there is call to "seekp" / "teelp" to get current stream position, using int variables, which leads to problems if the stream size exceed 32-bits signed integer maximum limit. I've sent a submission to solve this here : http://forum.openscenegraph.org/viewtopic.php?t=13928 Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=59751#59751 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] OpenSceneGraph 3.2.1 release candidate 5 tagged, please test
Hi, I've just seen that I left a "std::cout" in my last 3DS plugin submission, In file "osgPlugins/3ds/WriterNodeVisitor.cpp" At line 772 Maybe you can remove this debug trace before tagging official 3.2.1 Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60066#60066 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] OpenSceneGraph 3.2.1 release candidate 5 tagged, please test
Hi Robert, Line 772, I left an unconditonnal "std::cout" ! This is an error from me and I think it should be converted to "OSG_DEBUG" or removed. Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60074#60074 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] OpenSceneGraph 3.2.1 release candidate 5 tagged, please test
Ok, sorry for the confusion ! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60076#60076 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [vpb] Multiple terrain layers and relative altitude heightmap
Hi, I'm starting a new project that will use VPB databases, but I have some questions about data manipulation : (all data are re-projected to the same coordinate system before any processing) 1. I need to manage multiple "terrain layers". A layer is made of elevation data and texture data. So I think to build a terrain database for each "terrain layer" and then add all these database in the same scene graph. This allow the user to rebuild / show / hide only selected "terrain layers" Is there any technical / performance problems to use multiple terrain database nodes in the same scene graph ? I know there will be some rendering artifacts because a (X;Y) point can have different altitudes (one from each "terrain layer") but this is not my question, I wondering about TileID management for example. 2. Some "terrain layers" have elevation data relative to another one. Is there anyway to manage that using osgTerrain ? I think I can "add" the 2 elevation data using GDAL before database creation, but I would prefer to do that at runtime. 3. Is there any "invalid elevation value" management to "cut holes" in source elevation data and then build a database with holes inside ? (not simple shape holes as square) 4. Is there any way to build a "texture only database" (no elevation data) and then add / remove it (as a colorlayer on pre-loaded terrain database) at runtime ? Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46268#46268 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [vpb] Multiple terrain layers and relative altitude heightmap
Thanks for your quick answers ! I'm considering using VPB instead of osgEarth for performance issue : we need to provide a smooth user experience at 30-60 fps on midrange hardware. And since a lot of data are static, I think VPB should give us better performance, but maybe am I wrong ? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46282#46282 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [vpb] Multiple terrain layers and relative altitude heightmap
> Have you TRIED osgEarth? Yes, in the past I've been working about 8 month on a osgEarth based project. We used a 2 GB dataset, and performance was really bad until the cache is filled. The new project I'm starting will use dataset about to 5-20 GB, in local storage (with some single files up to 4 GB). So I'm a little afraid about performance using osgEarth, and the resulting cache size. Also, a have a restriction : the dataset coordinate system is selected by the end-user, and not necessary a geoid. If I remember well, osgEarth can work only with a geoid. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46291#46291 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [vpb] Multiple terrain layers and relative altitude heightmap
> You can use VPB-built static terrin baselayers in osgEarth, and use > osgEarth's dynamic terrain layers only where needed. You can also use > osgEarth to apply dynamic imagery sources onto static VPB terrain layers. Hum, I've missed that in my previous project... you are probably right, it might be the best idea. I'll check coordinates system mangement in osgEarth to see if it fits our requirements. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46295#46295 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Global state attribute (uniform)
Hi, I would like to add a global uniform to my scene graph (OSG 3.0.1). By "global", I mean that "all shaders can access to its value, anywhere in the graph" So, first I've binded this uniform on my scene graph root object, it works well. But now, the project has evolved and I need a modification : the global uniform is not anymore a part of the scene graph root object stateset, but added to a leaf node stateset. Is there anyway to make this uniform accessible by every shader in the scene graph ? I'm thinking about the "gl_light" stateattribute which affect the whole scene even if it's not set on the top object. Is there anyway to get this behavious for a uniform ? I've also read this topic : http://forum.openscenegraph.org/viewtopic.php?t=4755 : use cull callback to edit a uniform value, but I need to add a uniform And I found this : "osgUtil::SceneView::getGlobalStateSet()" which is maybe usefull, but the "osgUtil::SceneView" is deprecated, so I don't know if I really can use it. Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46455#46455 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Global state attribute (uniform)
Hi robert, I've tested the solution based on the camera stateset, but it's not fuly satisfying because when the leaf node object is remove from the graph, the uniform and the stateset are still affected to the camera. So I'm interested by the positional state special case : how can I add a stateattribute (uniform) to the positional state from a leaf node ? Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46469#46469 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Global state attribute (uniform)
> Could you just remove the uniform when you remove the leaf node? Or reset the > uniforms value? No, I can't because it is part of a generic management system and the leaf node may be removed by many ways. Since this application is single-threaded, use multiple viewer instance (no composite viewer) and use a camera instance per viewer, I think he following workaround is safe : (I know this is not the best way to build an osg application...) 1. subclass the osgViewer::Viewer class and reimplement the frame method : Code: void OsgViewer::frame(double simulationTime) { if (_done) return; if (_firstFrame) { viewerInit(); if (!isRealized()) { realize(); } _firstFrame = false; } advance(simulationTime); eventTraversal(); updateTraversal(); // Store the camera stateset osg::ref_ptr pOriginalCameraStateSet = p_osgCamera->getOrCreateStateSet(); osg::ref_ptr pCameraStateSet = dynamic_cast(pOriginalCameraStateSet->clone(osg::CopyOp())); renderingTraversals(); // Reset the camera stateset p_osgCamera->setStateSet(pCameraStateSet); } 2. In my leaf node cull callback, I add my global stateset to the camera stateset : Code: osg::Camera* pCamera = pCullVisitor->getCurrentCamera(); if (pCamera != NULL) { osg::StateSet* pCameraStateSet = pCamera->getStateSet(); pCameraStateSet->merge(*myGlobalStateSet()); } > One might also want a more general way of doing global uniforms as > well, where the modelview matrix isn't required, so it's isn't a > positional state. Yes, this is exactly my issue here, if you can give me some guidelines on how to implement this I may have some free time in a near future to work on it. Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46483#46483 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] OSG + Qt + threading.
Hi, > Now I can update render frame in another frame than GUI main frame! I don't think so. Because when you do that : Code: connect(this,SIGNAL(updateFrame()),_qtViewer,SLOT(updateGL())); If the "this" object and "_qtViewer" belongs to different thread, the connection will be established as a "Qt::QueuedConnection" and so the "updateGL()" slot will be executed in the "_qtViewer" owner thread which is the main thread. I think you can check that by settings breakpoints in "updateGL()" and check which thread is the current thread within the debugger. Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46520#46520 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] OSG + Qt + threading.
Have a look to this article : http://labs.qt.nokia.com/2011/06/03/threaded-opengl-in-4-8/ I think it's maybe not possible with qt previous 4.8 version, but maybe under some conditions. Basically, you need to call the updateGL() method from the worker thread. Have also a look to this article about threading in Qt : http://labs.qt.nokia.com/2010/06/17/youre-doing-it-wrong/ Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46523#46523 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] OSG + Qt + threading.
Hi, > when I call glWidget->frame() dont refresh the osg May be the OSG OpenGL context is not the current one. And maybe the OSG OpenGL context is not the same as created by Qt. Have a look at "makeCurrent" methods in Qt and in OSG : http://qt-project.org/doc/qt-4.8/qglcontext.html#makeCurrent http://www.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a00275.html#f9570786bab5518aab85737498af3a30 You can also check a lot of OpenGL context related stuff with gDebugger. > if I put a connection between timer and updateGL() fails to call paintGL(). It's probably because in this case, paintGL is called within another thread than main thread, which is not alowed by Qt. Could you post a minimal complete source code ? Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46575#46575 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Set object attitude using a normal and a heading
Hi, I want to set an object attitude (represented by a quaternion) using two parameters : - a normal vector (to set rotation around X and Y axis) - a heading angle (rotation around non-transformed Z axis) I tried to set the attitude quaternion : 1/ using the normal vector : Code: osg::Vec3d myNormal(0.0, 1.0, 1.0); myNormal.normalize(); osg::Quat attitudeNormal; attitudeNormal.makeRotate(osg::Vec3d(0.0, 0.0, 1.0), myNormal) 2/ using the heading angle : Code: double heading = osg::PI_2; osg::Quat attitudeHeading; attitudeHeading.makeRotate(heading, osg::Vec3d(0.0, 0.0, 1.0)) But how can I combine the two parameters ? If I do : Code: attitude = attitudeHeading*attitudeNormal the normal constraint is no more valid because X and Y axis are transformed by the attitudeHeading and affect attitudeNormal If I do : Code: attitude = attitudeNormal*attitudeHeading the heading constraint s no more valid because Z is transformed by the attitudeNormal and affect attitudeHeading Did I miss something ? Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46598#46598 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org