Re: [osg-users] osgconv won't downsize my textures and save power of 2 size?
Hi Christian, On Fri, Sep 23, 2011 at 11:00 PM, Christian Buchner christian.buch...@gmail.com wrote: This resizes the images to power of 2, up to OSG_MAX_TEXTURE_SIZE on each 2D dimension. Because it only works in conjunction with the --compressed switch, it is not a generic solution and it does not currently deal with 3D textures at all. Might I suggest that a more general approach to this be implemented in osgconv? osgconv is a convenience tool that covers a few of the types of pre processing that you might want to apply to database. It's not meant to be an all encompassing tool for all types of pre processing on all types of databases. If there is something specific you want to do with processing your own databases then it may well be easiest to just write a specific application to the do the exactly what you want. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] tiled terrain and batch vertexs ?
Hi John, Modern hardware generally is best driven with a modest number of quite large batches of geometry, rather than a large number of small batches of geometry. Exactly where the balance will lie with your database will depend upon your hardware and drivers, and also how efficiently you are setting up your scene graph and passing of geometry to OpenGL. Some general notes, try for a quad tree structure to your scene graph, a single flat osg::Geode containing all your geometry is BAD for performance as the OSG isn't able to cull efficiently. Also use large tiles, 17x17 vertices is smaller than what is likely to be most efficient. I can't say too much more as I really don't know enough about your terrain engine. I would also add that the OSG has tools for doing paged databases that are well balanced for modern hardware and can happily scale up to handling whole earth terrabyte databases at 60Hz. It may well be that you don't need your own terrain engine as the OSG already has very scalable support already built in. Robert. On Sat, Sep 24, 2011 at 8:16 AM, John Water akin...@hotmail.com wrote: Hi, all maybe this is a old topic , but I can't find answer in lots of forum, so I have to ask for help . I write a terrain engine mostly like interlocking terrain; there are 32x32 tiles for whole terrain, and 17x17 vertexs for one tile. every tile has one vertexarray, I use osg to realize it. all terrain is treated as one geode. and one drawable represents one tile.so I have one geode, and 1024 drawables.( I'm not sure if the structure is good ). but I met problem now: when see terrain on the fly,(all tiles are show in eye-views), the draw time is much more than on the ground(a few tiles are show); ofcourse, it should be certainly because of culling. now I want to reduce draw time on the fly. I think that maybe more draw calls make draw time high because one tile represent one drawable(one draw call, is that right?). and more worse: tile is dealed by LOD. when tile' lod level is lowest, it only has few vertices and indices, it could be very inefficient when one draw call only for the tile under the situation. should I batch several tile' vertexs into vertexarray?? but what to do this in osg-node-system, and it should be influence to culling?? anyone can explain how to do banlance between batch and cull in tiled terrain system ? thianks in advance. of course, it 's my thought about high draw time on the fly is because more draw calls( i'm not sure if 32x32=1024 draw calls are high?). my another thought about bad performance on the fly is that my lod tile'vertexarry is big. I don't design: lod3 vertexarray3 indicearray3 lod2 vertexarray2 indicearray2 lod1 vertexarray1 indicearray1 ( numbers of vertexarray: vertexarray3vertexarray2vertexarry1, decrease by lod level), I design simply: lod3 vertexarry indicearry3 lod2 vertexarry indicearry2 lod1 vertexarry indicearry1 every tile in different lod level has same vertexarray( most high vertex varry), it make me only dirty inidices varray every frame, but even if in lowest lod level, draw call still send lots of vertices(is that right?). now I'm not sure what real reason make high draw time on the fly view? 1: more draw calls in one frame 2. more vertices transfer in one frame anybody help, very appreciate! thanks again. Thank you! Cheers, John -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42990#42990 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgconv won't downsize my textures and save power of 2 size?
Might I suggest that a more general approach to this be implemented in osgconv? osgconv is a convenience tool that covers a few of the types of pre processing that you might want to apply to database. It's not meant to be an all encompassing tool for all types of pre processing on all types of databases. If there is something specific you want to do with processing your own databases then it may well be easiest to just write a specific application to the do the exactly what you want. I was just puzzled because the documentation to osgconv states (if the compressed switch is used) that the image data gets converted to a texture, then read back and saved. This would usually imply that also the the texture size is determined by OpenGL, which often is a power of 2 (depending on the capabilities of the hardware). It seemed unexpected that the saved textures still retained their original sizes, even though osgconv had printed to the console that they were resized (for upload to OpenGL). Fortunately hacking osgconv was rather easy, as my code snipped shows. So case closed. Christian ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Switch node, and multiple views
Hi all, I have a scene graph containing a switch node (osg::Switch) having 4 children. What would be the best way to render this scene graph in 4 different views/viewports, with each child (attached under the osg::Switch) rendered in its own view? Thanks! ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgconv won't downsize my textures and save power of 2 size?
Hi Christian, On Mon, Sep 26, 2011 at 9:10 AM, Christian Buchner christian.buch...@gmail.com wrote: I was just puzzled because the documentation to osgconv states (if the compressed switch is used) that the image data gets converted to a texture, then read back and saved. This would usually imply that also the the texture size is determined by OpenGL, which often is a power of 2 (depending on the capabilities of the hardware). It seemed unexpected that the saved textures still retained their original sizes, even though osgconv had printed to the console that they were resized (for upload to OpenGL). OpenGL is used to do the compression. If the textures are resized and compressed they won't have the original image size. Perhaps you are seeing a bug, perhaps you are mis-interpreting things. From your posts I can't work out exactly what is happening. Fortunately hacking osgconv was rather easy, as my code snipped shows. So case closed. I couldn't work out what you snippet did. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Switch node, and multiple views
H Lars, On Mon, Sep 26, 2011 at 9:16 AM, Lars Karlsson klars3...@yahoo.com wrote: Hi all, I have a scene graph containing a switch node (osg::Switch) having 4 children. What would be the best way to render this scene graph in 4 different views/viewports, with each child (attached under the osg::Switch) rendered in its own view? Thanks! Is it just one subgraph within the whole subgraph that you want to appear differently on each viewport or do you have four entirely different subgraphs for each view? If the former then the best way to handle this is to use a TraversalMask on the Camera matched to a NodeMask's in the scene graph, see osgstereoimage example, if the later use a osgViewer::CompositeViewer see osgcompositeviewer. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgconv won't downsize my textures and save power of 2 size?
OpenGL is used to do the compression. If the textures are resized and compressed they won't have the original image size. Perhaps you are seeing a bug, perhaps you are mis-interpreting things. From your posts I can't work out exactly what is happening. The issue seems to be that the osg::image object seems to retain its original size, even when sending the texture to OpenGL and when reading it back. How compressed texture data would survive this scaling step, I don't know. I couldn't work out what you snippet did. The code would resize the osg::image to a power of 2, bounded by OSG_MAX_TEXTURE_SIZE before doing the compression step. A proper way to do it might be to query the OpenGL texture for its size, and adjusting the osg::image accordingly. Christian ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgconv won't downsize my textures and save power of 2 size?
Hi Christian, On Mon, Sep 26, 2011 at 9:47 AM, Christian Buchner christian.buch...@gmail.com wrote: OpenGL is used to do the compression. If the textures are resized and compressed they won't have the original image size. Perhaps you are seeing a bug, perhaps you are mis-interpreting things. From your posts I can't work out exactly what is happening. The issue seems to be that the osg::image object seems to retain its original size, even when sending the texture to OpenGL and when reading it back. How compressed texture data would survive this scaling step, I don't know. Seems to, doesn't really tell me much. Any chance you could post a model that illustrates what you see as a problem. I couldn't work out what you snippet did. The code would resize the osg::image to a power of 2, bounded by OSG_MAX_TEXTURE_SIZE before doing the compression step. A proper way to do it might be to query the OpenGL texture for its size, and adjusting the osg::image accordingly. The OSG sets up the max texture size by checking OpenGL, unless you've set the value with the env var OSG_MAX_TEXTURE_SIZE if which case this value is taken. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgconv won't downsize my textures and save power of 2 size?
Repro step: Download and unzip this model (in fact any model with non power of 2 textures will do) http://sketchup.google.com/3dwarehouse/download?mid=59cc35a574aca8e4a516a23b781f0facrtyp=zsfn=Hofgarten_Dianatempelctyp=otherprevstart=0ts=1220656167000 using OSG 3.0.1 (on Windows, in the model's folder). I am running osgconv followed by osgviewer to illustrate the problem: osgconv --compressed models/model.dae model.osg processTexture(./material_0_15_0-image-sampler) processTexture(./material_1_4_0-image-sampler) ... Realized pbuffer for OpenGL operations. Scaling image 'C:\osgtest\images\texture0.png' from (47,53) to (64,64) Scaling image 'C:\osgtest\images\texture0.jpg' from (323,320) to (256,256) Scaling image 'C:\osgtest\images\texture1.png' from (50,67) to (64,64) ... Image written to 'texture0.dds' Image written to 'texture0.dds' Image written to 'texture1.dds' ... Data written to 'model.osg' osgviewer model.osg Scaling image 'texture3.dds' from (307,29) to (256,32) -- unexpected Scaling image 'texture4.dds' from (307,29) to (256,32) -- unexpected ... Scaling image 'texture12.dds' from (31,20) to (32,16) -- unexpected Scaling image 'texture13.dds' from (11,10) to (16,16) -- expected, as no compression done below 16x16 pixels I think. ... Either osgconv --compressed is not compressing and scaling all textures, or it's not always saving them in the scaled size. And another possible bug: It's writing texture0.dds twice, as it found a texture0.jpg and texture0.png in the source file. Christian ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Switch node, and multiple views
Hi Robert, Hi all, I have a scene graph containing a switch node (osg::Switch) having 4 children. What would be the best way to render this scene graph in 4 different views/viewports, with each child (attached under the osg::Switch) rendered in its own view? Thanks! Is it just one subgraph within the whole subgraph that you want to appear differently on each viewport or do you have four entirely different subgraphs for each view? If the former then the best way to handle this is to use a TraversalMask on the Camera matched to a NodeMask's in the scene graph, see osgstereoimage example, if the later use a osgViewer::CompositeViewer see osgcompositeviewer. Robert. Yes, I'd like to render one single scenegraph, however four times DIFFERENTLY (i.e. in four different views), and of course simultaneously. Basically, my first idea was to have one master scenegraph, and then somehow replicate this master to four slave subgraphs on each frame. However this would quickly become cumbersome, so naturally I thought there should be a better way I looked quickly into TraversalMask... Is my hunch correct when I say that: - I make all four subgraphs (under Switch ) active - I set their masks to 1, 2, 4, and 8 respectively - I take cameras of each of the four views in CompositeViewer, and set their masks to 1, 2, 4 and 8 respectively - now the CULL traversals for all four views will cull respective subgraphs: - CULL for view 1 culls subgraphs 2, 3, and 4 - CULL for view 2 culls subgraphs 1, 3, and 4 - CULL for view 3 culls subgraphs 1, 2, and 4 - CULL for view 4 culls subgraphs 1, 2, and 3 Am I on the right track? Thanks! ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Switch node, and multiple views
Hi Lars, On 26/09/11 11:30 , Lars Karlsson wrote: Yes, I'd like to render one single scenegraph, however four times DIFFERENTLY (i.e. in four different views), and of course simultaneously. ... I looked quickly into TraversalMask... Is my hunch correct when I say that: - I make all four subgraphs (under Switch) active - I set their masks to 1, 2, 4, and 8 respectively - I take cameras of each of the four views in CompositeViewer, and set their masks to 1, 2, 4 and 8 respectively - now the CULL traversals for all four views will cull respective subgraphs: - CULL for view 1 culls subgraphs 2, 3, and 4 - CULL for view 2 culls subgraphs 1, 3, and 4 - CULL for view 3 culls subgraphs 1, 2, and 4 - CULL for view 4 culls subgraphs 1, 2, and 3 Am I on the right track? Thanks! Yes, except instead of a Switch you would probably just use a Group for this, unless you want to disable/switch the subgraphs as well. Cheers, /ulrich ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] TextureArray
Where can I find an example on how to use a TextureArray with OSG? I'm trying to setup a uniform to send this TextureArray to my fragment shader and I'm confused on how to do this. Usually, you'd send a texture to the shader by setting the texture uniform to the texture number so I thought I would need to do this for a TextureArray: geometry-getOrCreateStateSet()-setTextureAttribute(BASE_TEX_ID, textureArray, osg::StateAttribute::ON); sset-addUniform( new osg::Uniform(osg::Uniform::SAMPLER_2D_ARRAY, textureArray, BASE_TEX_ID)); However, when I assign BASE_TEX_ID to 0, I'm getting: Uniform numElements 1 is invalid from this call: Uniform::Uniform( Type type, const std::string name, int numElements ) : This seems to imply that the third argument to the Uniform constructor isn't the texture number but the TextureArray size (?). Then how do you set this TextureArray to a particular texture number? I'm confused... Is there an example out there that shows how to use a TextureArray? Paul P. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43014#43014 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Changing DrawBuffer for FBO
Hmmm... okay.. some additional info on this topic: - I tried with a new StateAttribute osg::DrawBuffer, but this doen'st work :-( the situation is: I have the top pre_render camera, I attach both texture2dArrays on slot 1 and slot 2 (slot 0 is already used by a needed sampler, also, those too textures are attached on COLOR_BUFFER0 and COLOR_BUFFER1); then I add child quads with the osg::DrawBuffer state attribute properly configured, and an uniform properly configured to access the source texture (as opposed to the texture being rendered on that quad, which is supposed to be determined by the DrawBuffer state attribute...) = If I perform a single pass (rendering texture B from texture A) then both texture A and B are properly rendered. = As soon as I try to render two passes (rendering texture B from texture A then rendering texture A from Texture B) then texture B is still OK but texture A is completely black :-( - So I assumed the osg::DrawBuffer stateAttribute was not working as expected (but here I really don't understand why...) and started creating a special PingPongDrawable. The idea with this ping pong drawable is to place is just under the camera previously defined (so I assume the FBO is applied, the textures are applied, the shader program is applied and the color buffers are attached: I attached the source of that PingPongDrawable if someone wants to have a look... it's main part is to render all the passes in one cycle just as in the pure OpenGL code snipped I'm using as template: So the main part of the code is: // just call the OpenGL code. for (int i = 0; i _numPasses; ++i) { // extensions-glUniform1f(passLoc, float(i + 0.5) / _numPasses); if (i%2 == 0) { extensions-glUniform1i(imgLoc, 1); // use the first texture. glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT); } else { extensions-glUniform1i(imgLoc, 2); // Use the second texture. glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); } drawQuad(); } ... but here again... everything is fine with a single pass but the texture A becomes completely black as soon as I try with 2 passes... I'm really starting to feel desperated so if somebody as a clue why my first texture2D array gets cleared /destroyed/ sent into another dimension ? that would be very helpful. Buy the way, here is how the FBO camera is setup if you want to know that (this is some lua code, but I guess everyone can understand the osg calls): local PASSES = options.PASSES or 8; local FFT_SIZE = options.FFT_SIZE or 256 -- Create a single camera holding the attachments: local cam = osg.Camera(); cam:setRenderOrder(osg.Camera.RenderOrder.PRE_RENDER,11); cam:setClearColor(osg.Vec4(1.0,0.0,0.0,1.0)); --cam:setClearMask(GL.Mode.GL_COLOR_BUFFER_BIT + GL.Mode.GL_DEPTH_BUFFER_BIT) cam:setClearMask(0) cam:setViewport(osg.Viewport(0,0,FFT_SIZE,FFT_SIZE)) --cam:setReferenceFrame(osg.Transform.ReferenceFrame.ABSOLUTE_RF); --cam:setGraphicsContext(context); cam:setRenderTargetImplementation(osg.Camera.RenderTargetImplementation.FRAME_BUFFER_OBJECT) -- attach the buffers to the init camera: --cam:setReadBuffer(GLValues.GL_COLOR_ATTACHMENT0_EXT); local ss = cam:getOrCreateStateSet() ss:setMode(GL.Mode.GL_BLEND,osg.StateAttribute.Values.OFF+osg.StateAttribute.Values.OVERRIDE+osg.StateAttribute.Values.PROTECTED) ss:setMode(GL.Mode.GL_DEPTH_TEST,osg.StateAttribute.Values.OFF+osg.StateAttribute.Values.OVERRIDE+osg.StateAttribute.Values.PROTECTED) cam:attach(osg.Camera.BufferComponent.COLOR_BUFFER0,result.ffta,0) --,0,true); -- last true here means: generate mipmaps (is it needed ??) cam:attach(osg.Camera.BufferComponent.COLOR_BUFFER1,result.fftb,0) --,0,true); -- last true here means: generate mipmaps (is it needed ??) ss:setTextureAttribute(1,result.ffta,osg.StateAttribute.Values.ON); ss:setTextureAttribute(2,result.fftb,osg.StateAttribute.Values.ON); local ss = cam:getOrCreateStateSet(); cam:setReadBuffer(GLValues.GL_COLOR_ATTACHMENT0_EXT) cam:setDrawBuffer(GLValues.GL_COLOR_ATTACHMENT0_EXT) local proj = giProject.ProjectManager.getProject(ocean2); assignTexture{ss=ss,name=butterfly,project=proj,slot=0} release(proj) --- Save uniform here: giScene.SceneTools.setIntUniform(ss:getOrCreateUniform(nLayers, osg.Uniform.Type.INT), options.choppy and 5 or 3) local fftx_passes = osg.Group() cam:addChild(fftx_passes) local ss = fftx_passes:getOrCreateStateSet() -- Add the program: local proj = giProject.ProjectManager.getProject(ocean2); local prog = createProgram(proj,fftx) ss:setAttributeAndModes(prog) release(proj) -- Add passes: local pass = setupFFTPass(options,result,prog,8) -- this is where the pingPongDrawable is created and added (taking the program and
Re: [osg-users] TextureArray
Hi Paul, I can't find example that use TextureArray in osg example. but I can answer to your question. 2011/9/26 Paul Palumbo paul1...@yahoo.com Where can I find an example on how to use a TextureArray with OSG? I'm trying to setup a uniform to send this TextureArray to my fragment shader and I'm confused on how to do this. Usually, you'd send a texture to the shader by setting the texture uniform to the texture number so I thought I would need to do this for a TextureArray: geometry-getOrCreateStateSet()-setTextureAttribute(BASE_TEX_ID, textureArray, osg::StateAttribute::ON); that is good sset-addUniform( new osg::Uniform(osg::Uniform::SAMPLER_2D_ARRAY, textureArray, BASE_TEX_ID)); The third argument is the size of the uniform variable. 1 for value (float, int, vector, textureIndex, ...) 1 for an array of value (float[], int[], textureIndex[], ...) the size of the TextureArray is the depth component of Texture2DArray. you can specify it by Texture2DArray::setDepthTexture(...), or by adding an image Texture2DArray::setImage(unsigned int layer, osg::Image * image); HTH David Callu However, when I assign BASE_TEX_ID to 0, I'm getting: Uniform numElements 1 is invalid from this call: Uniform::Uniform( Type type, const std::string name, int numElements ) : This seems to imply that the third argument to the Uniform constructor isn't the texture number but the TextureArray size (?). Then how do you set this TextureArray to a particular texture number? I'm confused... Is there an example out there that shows how to use a TextureArray? Paul P. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43014#43014 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] TextureArray
Thanks for the response. Then, how do you associate the TextureArray with a texture unit number (which is then used in the setTextureAttribute() call)? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43017#43017 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] TextureArray
Let me phrase my question better... How do I associate a Texture2DArray defined in my stateset with a particular Uniform so that it can be accessible in the shader? For regular textures, this would be done using the Texture Unit number. Also, is it valid to have a Texture2DArray defined as having a texture format of GL_LUMINANCE_ALPHA32F_ARB? I've defined my texture array like this: Code: osg::Texture2DArray *textureArray = new osg::Texture2DArray(); textureArray-setTextureSize(0, 0, depth); textureArray-setInternalFormatMode(osg::Texture2DArray::USE_IMAGE_DATA_FORMAT); textureArray-setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR_MIPMAP_LINEAR); textureArray-setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR); textureArray-setUseHardwareMipMapGeneration(true); for (int i = 0; idepth; i++) { char filenameStr[1040]; snprintf(filenameStr, 1040, /%06d.tiff, i); std::string filename = directory + filenameStr; osg::ref_ptrosg::Image image = osgDB::readImageFile(filename); image-setInternalTextureFormat(GL_LUMINANCE_ALPHA32F_ARB); textureArray-setImage(i, image.get()); } geode-addDrawable(polyGeom); polyGeom-getOrCreateStateSet()-setTextureAttribute(TEX_ARRAY_ID, textureArray, osg::StateAttribute::ON); osg::ref_ptrosg::Uniform TextureArrayUniform = new osg::Uniform(osg::Uniform::SAMPLER_2D_ARRAY, textureArray, TEX_ARRAY_ID); geode-getOrCreateStateSet()-addUniform(TextureArrayUniform.get()); And I'm getting this OpenGL error when compiling my TextureArray: Warning: detected OpenGL error 'invalid enumerant' at StateSet::compileGLObejcts() compiling texture attribute. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43018#43018 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] CompositeViewer and ScreenCapture Handler
Hi, i have a composite viewer that holds two views. Currently, it always captures the frame of the view which is added first to the composite viewer. If i change the sequence of adding the views to the composite viewer, i get a frame of the second view. captureNextFrame wants me to pass in the ViewerBase, which is the CompositeViewer itself instead of a particular view.? Ho do i tell the ScreenCaptureHandler to save a frame of a particular view? Thank you! Cheers, Stephan -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43019#43019 ___ 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
This topic has been covered before in various forms. Please see the following discussions for enlightenment... http://forum.openscenegraph.org/viewtopic.php?t=4991highlight= http://forum.openscenegraph.org/viewtopic.php?t=103highlight= http://forum.openscenegraph.org/viewtopic.php?t=1786highlight= -Shayne -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Aurelien Albert Sent: Sunday, September 25, 2011 6:26 AM To: osg-users@lists.openscenegraph.org Subject: [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.or g ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] TextureArray
2011/9/26 Paul Palumbo paul1...@yahoo.com Let me phrase my question better... How do I associate a Texture2DArray defined in my stateset with a particular Uniform so that it can be accessible in the shader? For regular textures, this would be done using the Texture Unit number. this is the same thing for Texture2DArray, you define the Texture Unit number in the StateSet and in the uniform: int textureUnit = 0; osg::StateSet * ss = node-getOrCreateStateSet(); ss-setTextureAttributeAndMode( textureUnit, textureObject ); osg::Uniform * uniform = new osg::Uniform(osg::Uniform::SAMPLER_2D_ARRAY, textureArray, 1); uniform-set( textureUnit ); or uniform-set( (int) 0 ); // don't forget to cast in int, some compiler define 0 as an unsigned int ss-addUniform(uniform); Also, is it valid to have a Texture2DArray defined as having a texture format of GL_LUMINANCE_ALPHA32F_ARB? I've defined my texture array like this: Code: osg::Texture2DArray *textureArray = new osg::Texture2DArray(); textureArray-setTextureSize(0, 0, depth); textureSize = 0, 0, depth, you have depth texture, with each have a size of 0 by 0, strange. the size must be the size of texture read in the loop 'for (int i = 0; idepth; i++) ...' textureArray-setInternalFormatMode(osg::Texture2DArray::USE_IMAGE_DATA_FORMAT); textureArray-setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR_MIPMAP_LINEAR); textureArray-setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR); textureArray-setUseHardwareMipMapGeneration(true); for (int i = 0; idepth; i++) { char filenameStr[1040]; snprintf(filenameStr, 1040, /%06d.tiff, i); std::string filename = directory + filenameStr; osg::ref_ptrosg::Image image = osgDB::readImageFile(filename); image-setInternalTextureFormat(GL_LUMINANCE_ALPHA32F_ARB); textureArray-setImage(i, image.get()); } geode-addDrawable(polyGeom); polyGeom-getOrCreateStateSet()-setTextureAttribute(TEX_ARRAY_ID, textureArray, osg::StateAttribute::ON); osg::ref_ptrosg::Uniform TextureArrayUniform = new osg::Uniform(osg::Uniform::SAMPLER_2D_ARRAY, textureArray, TEX_ARRAY_ID); here, there are an error, this is not TEX_ARRAY_ID but just 1, see note before. geode-getOrCreateStateSet()-addUniform(TextureArrayUniform.get()); This is too complicate to give you a valid answer, depend to your hardware and need to look OpenGL specification. You can use the free tool gDEBugger http://www.gremedy.com/ to debug your opengl call. You can specify to gDEBugger to break on openGL error. and you immediatly know what opengl function call do an error. HTH David Callu And I'm getting this OpenGL error when compiling my TextureArray: Warning: detected OpenGL error 'invalid enumerant' at StateSet::compileGLObejcts() compiling texture attribute. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43018#43018 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] qtOsg EventHandler issue
Hi Robert. I'm working with a qtOsg application that uses internal windows. Each window represents a viewer thats is being managed by a composite viewer. 1 - The program starts with no scenario windows 2 - I can add or remove Windows with a new/open file operation. 3 - for the first window to be opened everything works perfect regarding events ( mouse click, mouse press, drag, etc ). 4 - For all the others i have to wait a time till the event handler starts to work. Sometimes, It takes more than 5 seconds. Do i have to force some call to make the current window active together with its current viewer's event handler ? When using osg 2.9.15 i had no trouble with this. Now I'm using osg 3.0.1 My friends have reported me the same problem in version 3.0.0. Regards Andre ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Switch node, and multiple views
Hi all, after going deeper into this matter, I realized I can't use TraversalMasks, because I have just 32 bits at disposal... I namely have an arbitrary number N of osg::Switch nodes in my scenegraph, not just four (I simplified the question, so as to make it easier to understand to people). And in general, I have M views (not just four) into this scenegraph as well. M in general N. So basically, I have a number of switches, and an even greater number K of different paths realizable through these switches. The point is, each of M views should be capable to display any of these K paths. Any ideas or pointers as of how to architect this in OSG? Thank you. --- On Mon, 9/26/11, Ulrich Hertlein u.hertl...@sandbox.de wrote: From: Ulrich Hertlein u.hertl...@sandbox.de Subject: Re: [osg-users] Switch node, and multiple views To: OpenSceneGraph Users osg-users@lists.openscenegraph.org Date: Monday, September 26, 2011, 10:56 AM Hi Lars, On 26/09/11 11:30 , Lars Karlsson wrote: Yes, I'd like to render one single scenegraph, however four times DIFFERENTLY (i.e. in four different views), and of course simultaneously. ... I looked quickly into TraversalMask... Is my hunch correct when I say that: - I make all four subgraphs (under Switch) active - I set their masks to 1, 2, 4, and 8 respectively - I take cameras of each of the four views in CompositeViewer, and set their masks to 1, 2, 4 and 8 respectively - now the CULL traversals for all four views will cull respective subgraphs: - CULL for view 1 culls subgraphs 2, 3, and 4 - CULL for view 2 culls subgraphs 1, 3, and 4 - CULL for view 3 culls subgraphs 1, 2, and 4 - CULL for view 4 culls subgraphs 1, 2, and 3 Am I on the right track? Thanks! Yes, except instead of a Switch you would probably just use a Group for this, unless you want to disable/switch the subgraphs as well. Cheers, /ulrich ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Switch node, and multiple views
Hi Lars, On Mon, Sep 26, 2011 at 11:58 AM, Lars Karlsson klars3...@yahoo.com wrote: Any ideas or pointers as of how to architect this in OSG? Thank you. I've accomplished the same thing you are trying to do by using cull callbacks on each node. It gives you much more flexibility than node masks. There are many ways to go about this. I created a custom data structure that stores a unique identifier for each view, and saved this data structure in the user data field of the cull visitor of the view. My cull callback then retrieves this identifier from the cull visitor and determines whether or not to render to the view. My cull callback maintains a list of all the view identifiers it is either allowed or not allowed to render to. This way you are not limited to 32 bit node masks to control the rendering of nodes. Hope this information was helpful and let me know if you would like more details. Cheers, Farshid --- On Mon, 9/26/11, Ulrich Hertlein u.hertl...@sandbox.de wrote: From: Ulrich Hertlein u.hertl...@sandbox.de Subject: Re: [osg-users] Switch node, and multiple views To: OpenSceneGraph Users osg-users@lists.openscenegraph.org Date: Monday, September 26, 2011, 10:56 AM Hi Lars, On 26/09/11 11:30 , Lars Karlsson wrote: Yes, I'd like to render one single scenegraph, however four times DIFFERENTLY (i.e. in four different views), and of course simultaneously. ... I looked quickly into TraversalMask... Is my hunch correct when I say that: - I make all four subgraphs (under Switch) active - I set their masks to 1, 2, 4, and 8 respectively - I take cameras of each of the four views in CompositeViewer, and set their masks to 1, 2, 4 and 8 respectively - now the CULL traversals for all four views will cull respective subgraphs: - CULL for view 1 culls subgraphs 2, 3, and 4 - CULL for view 2 culls subgraphs 1, 3, and 4 - CULL for view 3 culls subgraphs 1, 2, and 4 - CULL for view 4 culls subgraphs 1, 2, and 3 Am I on the right track? Thanks! Yes, except instead of a Switch you would probably just use a Group for this, unless you want to disable/switch the subgraphs as well. Cheers, /ulrich ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Switch node, and multiple views
Hi Farshid, Interesting, thank you for the pointer. Lars Hi Lars, On Mon, Sep 26, 2011 at 11:58 AM, Lars Karlsson klars3...@yahoo.com wrote: Any ideas or pointers as of how to architect this in OSG? Thank you. I've accomplished the same thing you are trying to do by using cull callbacks on each node. It gives you much more flexibility than node masks. There are many ways to go about this. I created a custom data structure that stores a unique identifier for each view, and saved this data structure in the user data field of the cull visitor of the view. My cull callback then retrieves this identifier from the cull visitor and determines whether or not to render to the view. My cull callback maintains a list of all the view identifiers it is either allowed or not allowed to render to. This way you are not limited to 32 bit node masks to control the rendering of nodes. Hope this information was helpful and let me know if you would like more details. Cheers, Farshid ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] qtOsg EventHandler issue
Hi Andre, I'm not a Qt guru, and am not the author of osgQt so can't provide guidance to the ins and out of Qt. Hopefully those more knowledgeable of Qt will be able to chip in. Robert. On Mon, Sep 26, 2011 at 7:29 PM, Andre Simoes andrersim...@gmail.com wrote: Hi Robert. I'm working with a qtOsg application that uses internal windows. Each window represents a viewer thats is being managed by a composite viewer. 1 - The program starts with no scenario windows 2 - I can add or remove Windows with a new/open file operation. 3 - for the first window to be opened everything works perfect regarding events ( mouse click, mouse press, drag, etc ). 4 - For all the others i have to wait a time till the event handler starts to work. Sometimes, It takes more than 5 seconds. Do i have to force some call to make the current window active together with its current viewer's event handler ? When using osg 2.9.15 i had no trouble with this. Now I'm using osg 3.0.1 My friends have reported me the same problem in version 3.0.0. Regards Andre ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Clipping planes for slave camera
Hi, Robert, Is it possible for a slave camera to have different near and far clipping planes from the master camera? Are there examples for it? I figure it will be more complicated than changing the angle of view or adding a shear to the view frustum. Thanks, Yefei ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] qtOsg EventHandler issue
Hi, Just thought I would mention that I am having similar issues (where the first osg window is responsive instantaneously and successively created windows can take anywhere from a few seconds to a few minutes to become responsive). My setup seems to be different though -- in my case I have a main window which does not do any osg stuff, and then I create other QMainWindow-derived classes which I use to display simulation visualisations. Each of the simulation window classes inherits from both QMainWindow and CompositeViewer (i.e. I have several composite viewers, not several views from a single composite viewer). The reason I did this was due to many issues with multi-threading when I used a single compositeviewer with different views -- the only threading model that worked here was SingleThreaded since choosing any other model would cause crashes. When I used the single composite viewer I also noted that the stats-viewer only ever displays in the first window -- this can be seen in the osgviewerQt example application as well, though I have not tried to debug this at all. This same example application seems to handle multiple pop-ups quite well (at nice high frame-rates) which I am unable to obtain with my multiple composite-viewer method which is one of the reasons I think I am doing something silly. I should mention that I am still fairly new to osg and osgQt and graphics programming in general and all of these issues are more than likely due to me doing something silly. Unfortunately I have had to temporarily stop debugging this issue as more urgent work has come up, though I am very keen to hear what others have to say on the matter. I saw a post in the mailing list archive at which might lead to a solution, though I have not had the opportunity to try it out yet and judging by the dates and discussion it seems it also pre-dates the current osgQt implementation quite a bit. Here is a link: http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/2007-December/005676.html I am the process of building a 2.9.? release of osg (I am using 3.0.1) to see if the older version has any effect. I wanted to post a sample app, but unfortunately it is not as easy as I had hoped. Cheers, Chris On Mon, Sep 26, 2011 at 10:01 PM, Robert Osfield robert.osfi...@gmail.comwrote: Hi Andre, I'm not a Qt guru, and am not the author of osgQt so can't provide guidance to the ins and out of Qt. Hopefully those more knowledgeable of Qt will be able to chip in. Robert. On Mon, Sep 26, 2011 at 7:29 PM, Andre Simoes andrersim...@gmail.com wrote: Hi Robert. I'm working with a qtOsg application that uses internal windows. Each window represents a viewer thats is being managed by a composite viewer. 1 - The program starts with no scenario windows 2 - I can add or remove Windows with a new/open file operation. 3 - for the first window to be opened everything works perfect regarding events ( mouse click, mouse press, drag, etc ). 4 - For all the others i have to wait a time till the event handler starts to work. Sometimes, It takes more than 5 seconds. Do i have to force some call to make the current window active together with its current viewer's event handler ? When using osg 2.9.15 i had no trouble with this. Now I'm using osg 3.0.1 My friends have reported me the same problem in version 3.0.0. Regards Andre ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Double-click events in AdapterWidget / OSGQtWidget
Hi, I managed to modify AdapterWidget : public QGLWidget so that it recognizes double-click events as well, by adding the associated protected method virtual void mouseDoubleClickEvent( QMouseEvent* event ). However, whenever I double click within the OSGQtWidget (which inherits public osgViewer::Viewer, public AdapterWidget), it not only generates osgGA::GUIEventAdapter::DOUBLECLICK event but an osgGA::GUIEventAdapter::PUSH event as well. So whenever I double-click within the OSGQtWidget area, I get the following sequence of events: osgGA::GUIEventAdapter::PUSH. 760 120 osgGA::GUIEventAdapter::RELEASE osgGA::GUIEventAdapter::DOUBLECLICK: 760 120 osgGA::GUIEventAdapter::RELEASE This is undesirable because my routine which handles osgGA::GUIEventAdapter::RELEASE event is ALWAYS executed before my osgGA::GUIEventAdapter::DOUBLECLICK routine. Is there a way for OSGQtWidget to recognize just the double-click, i.e. generate just the osgGA::GUIEventAdapter::DOUBLECLICK event? Thanks! ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Double-click events in AdapterWidget / OSGQtWidget
Hi, I managed to modify AdapterWidget : public QGLWidget so that it recognizes double-click events as well, by adding the associated protected method virtual void mouseDoubleClickEvent( QMouseEvent* event ). However, whenever I double click within the OSGQtWidget (which inherits public osgViewer::Viewer, public AdapterWidget), it not only generates osgGA::GUIEventAdapter::DOUBLECLICK event but an osgGA::GUIEventAdapter::PUSH event as well. So whenever I double-click within the OSGQtWidget area, I get the following sequence of events: osgGA::GUIEventAdapter::PUSH. 760 120 osgGA::GUIEventAdapter::RELEASE osgGA::GUIEventAdapter::DOUBLECLICK: 760 120 osgGA::GUIEventAdapter::RELEASE This is undesirable because my routine which handles osgGA::GUIEventAdapter::RELEASE event is ALWAYS executed before my osgGA::GUIEventAdapter::DOUBLECLICK routine. Is there a way for OSGQtWidget to recognize just the double-click, i.e. generate just the osgGA::GUIEventAdapter::DOUBLECLICK event? Thanks! ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] unexpected behavior
Hi all, I am having the weirdest problem. I have generated a scene graph with a pre-render camera that does the skydome and then this: osg::ref_ptrosg::Group root = new osg::Group; root-setName(root); setSceneData(root.get()); osg::ref_ptrmear::SkyDome sky = new mear::SkyDome; sky-setView(this); root-addChild(sky.get()); // for testing //root-addChild(osgDB::readNodeFile(GH_Geometry_6_29_11.osgb)); root-addChild(osgDB::readNodeFile(/home/keith/GH_Geometry_6_29_11.osgb)); root-addChild(osgDB::readNodeFile(cow.osgt)); Now, if I leave the fullpath GH model and the cow in there, I see the GH model and the cow. If I comment out the GH model line, I just see the cow. If I leave the fullpath model loaded and comment the cow out I don't see anything (except the sky). This is called from a View setup in a CompositeViewer/QWidget. bizarre, -Keith ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org