Re: [osg-users] Correct way to modify scene graph [SEC=UNCLASSIFIED]
Hi Russell, I suppose setting the threading model to SingleThreaded is not an option, maybe set Root Node to DYNAMIC variance? I can't remember the actual call. good luck, On 09/11/17 14:49, Thamm, Russell wrote: *UNCLASSIFIED* Hi I am in the process of porting an MFC application from plib to osg. Currently, if I want to actually modify the scene graph (adding, deleting nodes etc) while the render thread is running I do the following: parentNode->setNodeMask(0); modify scene graph below parent node parentNode->setNodeMask(~0); This seems to work but is there a better way? Cheers Russell *IMPORTANT*: This email remains the property of the Department of Defence and is subject to the jurisdiction of section 70 of the Crimes Act 1914. If you have received this email in error, you are requested to contact the sender and delete the email. ___ 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] Correct way to modify scene graph [SEC=UNCLASSIFIED]
UNCLASSIFIED Hi I am in the process of porting an MFC application from plib to osg. Currently, if I want to actually modify the scene graph (adding, deleting nodes etc) while the render thread is running I do the following: parentNode->setNodeMask(0); modify scene graph below parent node parentNode->setNodeMask(~0); This seems to work but is there a better way? Cheers Russell IMPORTANT: This email remains the property of the Department of Defence and is subject to the jurisdiction of section 70 of the Crimes Act 1914. If you have received this email in error, you are requested to contact the sender and delete the email. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] TBN Matrix for Normal Mapping - OSG and GLSL
Hi Jordi and Sebastian, thanks for your replies. I will have a look on osg::TangentSpaceVisitor, however I have a question: I will have in my OSG scene a lot of objects with/without normal mapping. How can I handle different normal textures using the same osg::TangentSpaceVisitor? ... Thank you! Cheers, Rômulo -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72339#72339 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [ShaderComposition] Redondant call to useProgram
Hi Robert, robertosfield wrote: > Which version of the OSG are you using? > I'm talking about master git (haven't check out the branch) robertosfield wrote: > Is the standard osgshadercomposition example generating this issue or is it > modified version? > Yes, no mod required in the osgshadercomposition example robertosfield wrote: > How are you detecting up the redundant calls issue? > I added a test a long time ago in Program.cpp Program::apply( osg::State& state ) Code: if( pcp != state.getLastAppliedProgramObject()) { // for shader debugging: to minimize performance impact, // optionally validate based on notify level. // TODO: enable this using notify level, or perhaps its own getenv()? if( osg::isNotifyEnabled(osg::INFO) ) pcp->validateProgram(); pcp->useProgram(); state.setLastAppliedProgramObject(pcp); }else{ OSG_WARN<<"WARNING: redondant useProgram pcp == state.getLastAppliedProgramObject()"< Hi Julien, > > I can't provide an answers without digging deeply in the code, this > week I'm really busy with clients so can't look in to. Next week I'll > be getting back to the shader_pipeline branch and better able to look > into it. > > Which version of the OSG are you using? Is the standard > osgshadercomposition example generating this issue or is it modified > version? How are you detecting up the redundant calls issue? > > Robert. > > On 4 November 2017 at 18:03, Julien Valentin <> wrote: > > > Hi Robert, > > > > Using the new shader composition (ex osgshadercompostion), I was surprised > > to detect a lot of redondant call to gluseprogram... > > I debugged a few and don't understand well State::push/popDefine and its > > policy to invalidate defineMap (defineMap.changed = true; seams to be > > called at each push/pop) > > (It's difficult to interact since it' s in the header) > > > > The problem seams here since it always tags as changed definemap (and so > > lead to some useless passage in State.cpp line 672 > > > > > > Code: > > if ((_lastAppliedProgramObject!=0) && > > (previousLastAppliedProgramObject==_lastAppliedProgramObject) && > > _defineMap.changed) > > { > > // OSG_NOTICE<<"State::apply(StateSet*) Program already applied > > ("<<(previousLastAppliedProgramObject==_lastAppliedProgramObject)<<") and > > _defineMap.changed= "<<_defineMap.changed< > _lastAppliedProgramObject->getProgram()->apply(*this); > > } > > > > > > > > Hoping this helps you to diagnose the problem :/ > > > > Thank you! > > > > Cheers, > > Julien > > > > -- > > Read this topic online here: > > http://forum.openscenegraph.org/viewtopic.php?p=72306#72306 > > > > > > > > > > > > ___ > > osg-users mailing list > > > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > > ___ > osg-users mailing list > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > -- > Post generated by Mail2Forum Code: -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72338#72338 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgoculus viewer picking
mmaurus wrote: > No, I actually mean eyetracking! > I have an integrated eyetracker. > Nice! Ok.. Well then you have to add the eyetracking rotations on top of the head rotations. Regards Björn -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72337#72337 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgoculus viewer picking
Hi again, I do not know which version of the OsgOculusViewer you are currently using. I just checked my own code and the OculusDevice class have had public interfaces to both head position and orientation since 3 years back (SDK version 0.4.2). Regards, Björn -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72336#72336 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgoculus viewer picking
No, I actually mean eyetracking! I have an integrated eyetracker. Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72335#72335 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgoculus viewer picking
Hi Michael, I guess you mean head tracking and not eye tracking. But that should be fairly straight forward. Create a line segment emanating from a point between the eyes and use that to calculate the intersections. There is no need to go from 2D to 3D in this case. The only thing you need to do is to recover the head position and orientation from the OculusDevice class. Either by writing your own method that publish that data directly from the Oculus SDK or by recovering that from the view matrices (which already have a public interface in the OculusDevice class). Regards, Björn -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72334#72334 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgoculus viewer picking
Hi Björn, thanks for the reply. I only have the DK2 without the controllers. Actually, I want to do picking using eyetracking. There I also get window coordinate and therefore need the same intersection methods. So if I unterstood you correctly, setting up a valid master camera, the picking should work? What is missing for that? Can I disable the oculus display and display just the scene? Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72333#72333 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgoculus viewer picking
Hi Michael, The OsgOculusViewer only renders to textures. What you see on your normal monitor is mirrored through the facilities provided by the Oculus SDK. I really do not know how mouse events are propagated through this window back to the osg application. The second assumption your code makes is that it assumes that there is a valid camera connected to the view. OsgOculusViewer uses a master-slave configuration, where the master view do not contain a valid camera object. Instead it is the slave cameras that is responsible for all rendering. A more esoteric question is: Do you really want mouse picking abilities when you are using a HMD? Shouldn't you be using the Oculus Touch capabilities for object picking inside VR instead? Regards, Björn -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72332#72332 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] osgoculus viewer picking
Hi, how can I get my PickHandler edited from the osgpick (see attachment) example working inside the osgoculusviewer? Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72331#72331 // class to handle events with a pick class PickHandler : public osgGA::GUIEventHandler { public: PickHandler() {} ~PickHandler() {} bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa) { switch(ea.getEventType()) { case(osgGA::GUIEventAdapter::PUSH): { osgViewer::View* view = dynamic_cast(&aa); if (view) pick(view,ea); return false; } case(osgGA::GUIEventAdapter::KEYDOWN): { if (ea.getKey()=='c') { osgViewer::View* view = dynamic_cast(&aa); osg::ref_ptr event = new osgGA::GUIEventAdapter(ea); event->setX((ea.getXmin()+ea.getXmax())*0.5); event->setY((ea.getYmin()+ea.getYmax())*0.5); if (view) pick(view,*event); } return false; } default: return false; } } virtual void pick(osgViewer::View* view, const osgGA::GUIEventAdapter& ea) { osgUtil::LineSegmentIntersector::Intersections intersections; std::string gdlist=""; osg::ref_ptr cam = view->getCamera(); std::cout << "mouse coordinates: " << ea.getX() << ", " << ea.getY() << ", camera = " << cam->getName() << std::endl; if (view->computeIntersections(ea,intersections)) { for(osgUtil::LineSegmentIntersector::Intersections::iterator hitr = intersections.begin(); hitr != intersections.end(); ++hitr) { std::ostringstream os; if (!hitr->nodePath.empty() && !(hitr->nodePath.back()->getName().empty())) { // the geodes are identified by name. os<<"Object \""getName()<<"\"" className()<<"\""
[osg-users] Osg 3.4.1 - Tutorial 12 Fails on Mac OSX Sierra - Framebuffer problem
I have just built 3.4.1 from github on the mac (MacOS Sierra, 10.12.6). The early tutorials Tut2 etc work fine. Tutorial 12, which introduces shadows, runs but dumps out warning messages. No shadows appear. here is the console output: Code: StatsHandler::StatsHandler() Setting up GL2 compatible shaders Warning: FrameBufferObject: could not create the FBO RenderStage::runCameraSetUp(), FBO setup failed, FBO status= 0x0 FRAGMENT glCompileShader "" FAILED glLinkProgram 0x7fb62e676ea0"" FAILED Warning: FrameBufferObject: could not create the FBO RenderStage::runCameraSetUp(), FBO setup failed, FBO status= 0x0 How to I fix or investigate the problem with failing to create the FBO? [/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72304#72304 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] MFC mdi child windows show the scene with different lighting
Hi Rakesh, If you are not willing to put in the effort to reproduce the scenario then maybe you don't really want help. ... Cheers, Lincoln -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72329#72329 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] MFC mdi child windows show the scene with different lighting
Hi Rakesh, If you want us to help you please reproduce the scenario by posting a minimal project (like modifying the MFC example) like I asked you to. The sooner you do that the sooner you will get help. Any other attempt like posting log files you are really just wasting time. ... Thank you! Cheers, Lincoln -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72328#72328 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] TBN Matrix for Normal Mapping - OSG and GLSL
Ouch bad link: https://github.com/openscenegraph/OpenSceneGraph/blob/master/src/osgPlugins/gles/TangentSpaceVisitor.cpp#L46 this one is the right one! 2017-11-08 9:19 GMT+01:00 Jordi Torres : > Hi Romulo, > > You can use TangentSpaceGenerator to get the values of the T B and N. Here > you have a code example: https://github.com/sketchfab/osg/blob/ > 5d35b2a2d55e92b4c736ea5edcd9eeedf9ea6786/src/osgPlugins/ > gles/TangentSpaceVisitor.cpp#L46 > > Cheers. > > 2017-11-07 21:48 GMT+01:00 Rômulo Cerqueira : > >> Hi, >> >> I have used normal mapping using GLSL and OSG for my application (an >> imaging sonar simulation) and I got problems by calculating the TBN matrix >> on shaders. The normal vectors contain lower resolution on border in >> comparison with the center of image. >> >> Follows my vertex code: >> >> Code: >> >> #version 130 >> >> out vec3 pos; >> out vec3 normal; >> out mat3 TBN; >> >> void main() { >> pos = (gl_ModelViewMatrix * gl_Vertex).xyz; >> normal = gl_NormalMatrix * gl_Normal.xyz; >> >> vec3 n = normalize(normal); >> vec3 t = normalize(cross(normal, vec3(-1,0,0))); >> vec3 b = cross(t, n) + cross(n, t); >> TBN = transpose(mat3(t,b,n)); >> >> gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; >> gl_TexCoord[0] = gl_MultiTexCoord0; >> } >> >> >> >> >> Part of my fragment code: >> >> Code: >> >> #version 130 >> >> in vec3 pos; >> in vec3 normal; >> in mat3 TBN; >> uniform sampler2D normalTexture; >> >> void main() { >> vec3 newNormal = (texture2D(normalTexture, gl_TexCoord[0].st).rgb * >> 2.0 - 1) * TBN; >> newNormal = normalize(newNormal); >> ... >> } >> >> >> >> >> The resulting figure is attached. >> >> How can I calculate the TBN matrix to compute the normal mapping properly? >> >> Thanks in advance, >> >> >> ... >> >> Thank you! >> >> Cheers, >> Rômulo[/img] >> >> -- >> Read this topic online here: >> http://forum.openscenegraph.org/viewtopic.php?p=72324#72324 >> >> >> >> >> Attachments: >> http://forum.openscenegraph.org//files/screenshot_from_2017_ >> 11_06_23_00_48_832.png >> >> >> ___ >> osg-users mailing list >> osg-users@lists.openscenegraph.org >> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >> > > > > -- > Jordi Torres > > > -- Jordi Torres ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] TBN Matrix for Normal Mapping - OSG and GLSL
Hi Romulo, You can use TangentSpaceGenerator to get the values of the T B and N. Here you have a code example: https://github.com/sketchfab/osg/blob/5d35b2a2d55e92b4c736ea5edcd9eeedf9ea6786/src/osgPlugins/gles/TangentSpaceVisitor.cpp#L46 Cheers. 2017-11-07 21:48 GMT+01:00 Rômulo Cerqueira : > Hi, > > I have used normal mapping using GLSL and OSG for my application (an > imaging sonar simulation) and I got problems by calculating the TBN matrix > on shaders. The normal vectors contain lower resolution on border in > comparison with the center of image. > > Follows my vertex code: > > Code: > > #version 130 > > out vec3 pos; > out vec3 normal; > out mat3 TBN; > > void main() { > pos = (gl_ModelViewMatrix * gl_Vertex).xyz; > normal = gl_NormalMatrix * gl_Normal.xyz; > > vec3 n = normalize(normal); > vec3 t = normalize(cross(normal, vec3(-1,0,0))); > vec3 b = cross(t, n) + cross(n, t); > TBN = transpose(mat3(t,b,n)); > > gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; > gl_TexCoord[0] = gl_MultiTexCoord0; > } > > > > > Part of my fragment code: > > Code: > > #version 130 > > in vec3 pos; > in vec3 normal; > in mat3 TBN; > uniform sampler2D normalTexture; > > void main() { > vec3 newNormal = (texture2D(normalTexture, gl_TexCoord[0].st).rgb * > 2.0 - 1) * TBN; > newNormal = normalize(newNormal); > ... > } > > > > > The resulting figure is attached. > > How can I calculate the TBN matrix to compute the normal mapping properly? > > Thanks in advance, > > > ... > > Thank you! > > Cheers, > Rômulo[/img] > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=72324#72324 > > > > > Attachments: > http://forum.openscenegraph.org//files/screenshot_from_ > 2017_11_06_23_00_48_832.png > > > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > -- Jordi Torres ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] TBN Matrix for Normal Mapping - OSG and GLSL
Hi Rômulo, Hi, I have used normal mapping using GLSL and OSG for my application (an imaging sonar simulation) and I got problems by calculating the TBN matrix on shaders. The normal vectors contain lower resolution on border in comparison with the center of image. You cannot get a valid Co-TangentSpace by taking only the normal into account considering arbitrary geometries. There are multiple ways to tackle this however: First is to calculate the mesh's tangentspace beforehand and pass the tangent and binormal via vertex attributes. See the osgUtil::TangentSpaceGenerator (example in the osg::CookBook AFAIK). Second one is to calculate it in the view-space. Beware of dragons, since the precision will be awful for big coordinates: http://www.thetenthplanet.de/archives/1180 hth Sebastian Follows my vertex code: Code: #version 130 out vec3 pos; out vec3 normal; out mat3 TBN; void main() { pos = (gl_ModelViewMatrix * gl_Vertex).xyz; normal = gl_NormalMatrix * gl_Normal.xyz; vec3 n = normalize(normal); vec3 t = normalize(cross(normal, vec3(-1,0,0))); vec3 b = cross(t, n) + cross(n, t); TBN = transpose(mat3(t,b,n)); gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; gl_TexCoord[0] = gl_MultiTexCoord0; } Part of my fragment code: Code: #version 130 in vec3 pos; in vec3 normal; in mat3 TBN; uniform sampler2D normalTexture; void main() { vec3 newNormal = (texture2D(normalTexture, gl_TexCoord[0].st).rgb * 2.0 - 1) * TBN; newNormal = normalize(newNormal); ... } The resulting figure is attached. How can I calculate the TBN matrix to compute the normal mapping properly? Thanks in advance, ... Thank you! Cheers, Rômulo[/img] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72324#72324 Attachments: http://forum.openscenegraph.org//files/screenshot_from_2017_11_06_23_00_48_832.png ___ 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