[osg-users] OSG for android cube texture problem
Hello everyone:I got a cube texture problem in my program base on ES2.0. The texture is black, does anyone know what is the problem.Here is my shader code: *Vertex shader * varying vec3 Normal; varying vec3 EyeDir; uniform samplerCube cubeMap; void main() { gl_Position = gl_ModelViewProjectionMatrix*gl_Vertex; Normal = gl_NormalMatrix * gl_Normal; EyeDir = vec3(gl_ModelViewMatrix * gl_Vertex); } *Fragment shader * varying vec3 Normal; varying vec3 EyeDir; uniform samplerCube cubeMap; void main(void) { vec3 reflectedDirection = normalize(reflect(EyeDir, normalize(Normal))); reflectedDirection.y = -reflectedDirection.y; vec4 fragColor = textureCube(cubeMap, reflectedDirection); gl_FragColor = fragColor; } Here is my osg code: void CSkyBox::setSkyBoxRadius(osg::Vec3 centre, double r) { m_centre=centre; m_r=r; } osg::TextureCubeMap* CSkyBox::readCubeMap(osg::Image* imagePosX, osg::Image* imageNegX, osg::Image* imagePosY, osg::Image* imageNegY, osg::Image* imagePosZ, osg::Image* imageNegZ) { osg::TextureCubeMap* cubemap = NULL; if (imagePosX && imageNegX && imagePosY && imageNegY && imagePosZ && imageNegZ) { cubemap = new osg::TextureCubeMap; cubemap->setImage(osg::TextureCubeMap::POSITIVE_X, imagePosX); cubemap->setImage(osg::TextureCubeMap::NEGATIVE_X, imageNegX); cubemap->setImage(osg::TextureCubeMap::POSITIVE_Y, imagePosY); cubemap->setImage(osg::TextureCubeMap::NEGATIVE_Y, imageNegY); cubemap->setImage(osg::TextureCubeMap::POSITIVE_Z, imagePosZ); cubemap->setImage(osg::TextureCubeMap::NEGATIVE_Z, imageNegZ); cubemap->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); cubemap->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); cubemap->setWrap(osg::Texture::WRAP_R, osg::Texture::CLAMP_TO_EDGE); cubemap->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR); cubemap->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR); } return cubemap; } osg::TextureCubeMap* CSkyBox::readCubeMap() { std::string path=getImagesPath(); osg::Image* imagePosX = osgDB::readImageFile(path+"\\posx.jpg"); osg::Image* imageNegX = osgDB::readImageFile(path+"\\negx.jpg"); osg::Image* imagePosY = osgDB::readImageFile(path+"\\posy.jpg"); osg::Image* imageNegY = osgDB::readImageFile(path+"\\negy.jpg"); osg::Image* imagePosZ = osgDB::readImageFile(path+"\\posz.jpg"); osg::Image* imageNegZ = osgDB::readImageFile(path+"\\negz.jpg"); return readCubeMap(imagePosX, imageNegX, imagePosY, imageNegY, imagePosZ, imageNegZ); } struct TexMatCallback : public osg::NodeCallback { public: TexMatCallback(osg::TexMat& tm) : _texMat(tm) { } virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) { osgUtil::CullVisitor* cv = dynamic_cast(nv); if (cv) { const osg::Matrix& MV = *(cv->getModelViewMatrix()); const osg::Matrix R = osg::Matrix::rotate( osg::DegreesToRadians(112.0f), 0.0f,0.0f,1.0f)* osg::Matrix::rotate( osg::DegreesToRadians(90.0f), 1.0f,0.0f,0.0f); osg::Quat q = MV.getRotate(); const osg::Matrix C = osg::Matrix::rotate( q.inverse() ); _texMat.setMatrix( C*R ); } traverse(node,nv); } osg::TexMat& _texMat; }; class MoveEarthySkyWithEyePointTransform : public osg::Transform { public: /** Get the transformation matrix which moves from local coords to world coords.*/ virtual bool computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const { osgUtil::CullVisitor* cv = dynamic_cast(nv); if (cv) { osg::Vec3 eyePointLocal = cv->getEyeLocal(); matrix.preMult(osg::Matrix::translate(eyePointLocal)); } return true; } /** Get the transformation matrix which moves from world coords to local coords.*/ virtual bool computeWorldToLocalMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const { osgUtil::CullVisitor* cv = dynamic_cast(nv); if (cv) { osg::Vec3 eyePointLocal = cv->getEyeLocal(); matrix.postMult(osg::Matrix::translate(-eyePointLocal)); } return true; } }; osg::Node* CSkyBox::createSkyBoxWithTextureCubeMap(osg::TextureCubeMap* skymap) { osg::StateSet* stateset = new osg::StateSet(); osg::TexMat *tm = new osg::TexMat; stateset->setTextureAttribute(0, tm); if (skymap) { stateset->setDataVariance(osg::Object::DYNAMIC); osg::ref_ptr skyProgram = new osg::Program; osg::Shader* vertex_shader = new osg::Shader(osg::Shader::VERTEX,skybox_vert); skyProgram->addShader(vertex_shader); osg::Shader* fragment_shader = new osg::Shader(osg::Shader::FRAGMENT,skybox_frag); skyProgram->addShader(fragment_shader); stateset->addUniform(new osg::Uniform("uEnvironmentMap",0)); stateset->setAttributeAndModes(skyProgram); stateset->setTextureAttribute(0,skymap); } //stateset->setTextureAttributeAndModes(0, skymap, osg::StateAttribute::ON); stateset->setMode( GL_LIGHTING, osg::StateAttribute::OFF ); stateset->setMode( GL_CULL_FACE, osg::StateAttribute::OFF ); // clear the depth to the far plane. osg::Depth* depth = new osg::Depth; depth->setFunction(osg::Depth::ALWAYS); depth->setRange(1.0,1.0); stateset->setAttributeAndModes(depth, osg::StateA
[osg-users] [osgPlugins] PositionAttitudeTransforms ignored when exporting
Hi, I just compiled OSG 3.2.0 with fbx plugin support. When exporting my scene in FBX or 3DS formats, some objects are not correctly placed. This does not happen when exporting to .osg or .ive. Looking further on it, I realized that those objects not located properly were children of PositionAttitudeTransfroms. Replacing PositinoAttitudeTransforms for MatrixTransforms results in correct FBX and 3DS models. I had never tried this before since I have always used native formats, so I'm sorry if this is a known issue that I missed before. Thank you! Cheers, Joseph -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=55798#55798 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] PositionAttitudeTransforms ignored when exporting
Hi Joseph, I'm not famaliar with the DBX and 3DS formats as I'm not the author of these plugins but I would say in general that 3rd party formats like these will only be able to map a small subset of OSG functionality, and in some case there may be no clear path to implementing it. In the case of PositionAttitudeTransforms the only thing that might be possible would be to convert to a MatrixTransform, potentially this could be done by the exporter, but then what do you do for AutoTransform, Billboards, PagedLODs etc. etc. There is huge parts of the OSG that will be only be supportable by the native formats. Robert. On 7 August 2013 15:48, Joseph Sahexmeier wrote: > Hi, > > I just compiled OSG 3.2.0 with fbx plugin support. > > When exporting my scene in FBX or 3DS formats, some objects are not correctly > placed. This does not happen when exporting to .osg or .ive. > > Looking further on it, I realized that those objects not located properly > were children of PositionAttitudeTransfroms. > > Replacing PositinoAttitudeTransforms for MatrixTransforms results in correct > FBX and 3DS models. > > I had never tried this before since I have always used native formats, so I'm > sorry if this is a known issue that I missed before. > > Thank you! > > Cheers, > Joseph > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=55798#55798 > > > > > > ___ > 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] [osgPlugins] PositionAttitudeTransforms ignored when exporting
Thanks for the answer Robert. That was pretty much my guess, in fact I am customizating my scene graph when it has to be exported (replacing LOD, etc.). I just thought PositionAttitudeTransform was of too common use to be left out. In order to minimize the impact on my codebase, I'll try to replace osg::PAT with osg::MatrixTransform through a nodeVisitor, see if that works. Thanks a lot. Regards, Joseph -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=55800#55800 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Inconsistency detected by ld.so: dl-close.c
Hello, I have been investigating a crash on shutdown that I suspect is related to osg or osgEarth singletons. As I was paring down the application, the crash changed to the following message: Inconsistency detected by ld.so: dl-close.c: 759: _dl_close: Assertion `map->l_init_called' failed! Here is my source code, .earth file, and g++ invocation: = #include int main() { osgDB::readNodeFile("test.earth"); return 0; } = = g++ -pthread -g /home/cstankevitz/Work/2012-06-01_uavlib/uavlib/Utils/SynVidTest/main.cpp -losgViewer -losg && ./a.out = Can someone tell me why I am getting this error? Thank you, Chris ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] osgDB::Registry::instance(true) sometimes segfaults
Hello, The first program does not segfault. The second does segfault: === #include int main() { osgDB::Registry::instance(true); return 0; } === #include int main() { osgDB::readNodeFile("/home/cstankevitz/Work/2013-07-02_osgearth/osgearth/tests/crs.earth"); osgDB::Registry::instance(true); return 0; } === The stack trace, which I'm sorry to say is missing symbols, shows that the segfault happens during something like static un-initialization. malloc_consolidate() at 0x74ad16e0 _int_free() at 0x74ad2148 0x7390b32f 0x7fffef884acc 0x7fffefcb748a 0x7fffefba06fd 0x7fffefba1e3f 0x7fffefb6633e 0x738ea8a0 0x738eac1c _dl_fini() at 0x77de9a8d __run_exit_handlers() at 0x74a8e689 exit() at 0x74a8e715 __libc_start_main() at 0x74a78614 _start() at 0x401079 Would you please tell me why this is happening? Thank you, Chris ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgDB::Registry::instance(true) sometimes segfaults
On Wed, Aug 7, 2013 at 12:27 PM, Chris Stankevitz wrote: > The first program does not segfault. The second does segfault: I neglected to mention these important details: - Loading the node file but not clearing the registry singleton does not segfault. However it does report "Inconsistency detected by ld.so: dl-close.c: 759: _dl_close: Assertion `map->l_init_called' failed!" - My earth file contents: Thank you, Chris ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Occlusion Query Node Error
Hello and thank you for any help in advance, I am working with some code that a coworker had created, but is unavailable at the moment. It deals with Occlusion Query Nodes. When we were still in OSG version 2.8, my coworker had grabbed a lot of the methods from the 3.0 version's OcclusionQueryNode.cpp and put them in our code so that we could use them for our sun. However, now that we have transitioned to 3.0, the code that was brought in isn't being used anymore, defaulting to OSG's code. The issue is, whenever our sun is on screen, we are getting the following error now: "osgOQ: QG: Invalid RQCB." This apparenlty happens becaues of this area of code: Code: RetrieveQueriesCallback* rqcb = dynamic_cast< RetrieveQueriesCallback* >( cam->getPostDrawCallback() ); if (!rqcb) { OSG_FATAL << "osgOQ: QG: Invalid RQCB." << std::endl; return; } I think it might be that we aren't setting up the nodes correctly, but I haven't been able to find any examples or documentation related to this error or how to properly set up occlusion query nodes in OSG. Any help is appreciated, please let me know if you have any questions regarding my question. Zach[/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=55804#55804 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Thanks to the presenters and helpers at the SIGGRAPH BOF
Greetings and Salutations, I would like to personally thank Jefferson Amstutz and Robert Osfield for presenting at the BOF. Jeff works for SURVICE Engineering Company and they had 2 posters at SIGGRAPH [#51 and 102]. I would also like to personally thank David Glenn for heroic feats of Google+ Hangout support and for holding the karaoke microphone over the laptop speaker during Robert's video presentation. Jeff's presentation was excellent. The hangout presentation will become famous in OSG history.. J Will send some BOF photos to be posted. John smime.p7s Description: S/MIME cryptographic signature ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Thanks to the presenters and helpers at the SIGGRAPH BOF
Hi John, Are these presentations ever [recorded and] made available for replay? PhilT From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of John Richardson Sent: 08 August 2013 00:00 To: osg-users@lists.openscenegraph.org Subject: [osg-users] Thanks to the presenters and helpers at the SIGGRAPH BOF Greetings and Salutations, I would like to personally thank Jefferson Amstutz and Robert Osfield for presenting at the BOF. Jeff works for SURVICE Engineering Company and they had 2 posters at SIGGRAPH [#51 and 102]. I would also like to personally thank David Glenn for heroic feats of Google+ Hangout support and for holding the karaoke microphone over the laptop speaker during Robert's video presentation. Jeff's presentation was excellent. The hangout presentation will become famous in OSG history.. J Will send some BOF photos to be posted. John ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org