Re: [osg-users] Normal Mapping using Dynamic Cubemap
Hi Sebastian, thanks for all comments. Do you know how I can manage these six faces of cubemap? I can handle all faces using one texture or I need to create six textures? I really need help with this...It's essential to my project. ... Thank you! Cheers, Rômulo -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72917#72917 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Normal Mapping using Dynamic Cubemap
Hi, Hi Sebastian, I have managed the normal and depth using MRT-FBO. I changed the osgdeferred example to display the normal (blue) and depth (green). Now I need to repeat this process for each six faces of cubemap. Nice to see that you're making progress. I have a question: to capture the normal/depth data, as seen in Figure, I used the eye space. For dynamic cubemap, I need to use the eye space or world space? Usually cubemaps are in world-space as they represent the view from a certain world-coordinate. Cheers Sebastian ... Thank you! Cheers, Rômulo -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72915#72915 Attachments: http://forum.openscenegraph.org//files/screenshot_from_2018_02_02_23_11_17_990.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
Re: [osg-users] Normal Mapping using Dynamic Cubemap
Hi Sebastian, I have managed the normal and depth using MRT-FBO. I changed the osgdeferred example to display the normal (blue) and depth (green). Now I need to repeat this process for each six faces of cubemap. I have a question: to capture the normal/depth data, as seen in Figure, I used the eye space. For dynamic cubemap, I need to use the eye space or world space? ... Thank you! Cheers, Rômulo -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72915#72915 Attachments: http://forum.openscenegraph.org//files/screenshot_from_2018_02_02_23_11_17_990.png ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Normal Mapping using Dynamic Cubemap
I'll try a last time: Hi, I still have problems to manage the normal view from reflected objects (using dynamic cubemaps technique). Please any tip here? Have you managed to render your normals, colors, depth etc to a MRT-FBO? If so, the next step is to render to do this 6 times, where each time you're FBO-attachments are the images of your cube-maps. You will need separate cubemaps for the normals, colors etc. Simply tell us where you're stuck. Last time it sounded like you're on a good way, but I personally don't have much time to help you with the detailed problems you encountered. Cheers Sebastian. ... Thank you! Cheers, Rômulo -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72885#72885 ___ 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] Normal Mapping using Dynamic Cubemap
Hi, I still have problems to manage the normal view from reflected objects (using dynamic cubemaps technique). Please any tip here? ... Thank you! Cheers, Rômulo -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72885#72885 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Normal Mapping using Dynamic Cubemap
Moreover, I installed the openscenegraph-examples package (using Ubuntu), however the osgdeferred example does not contain all complementary data (i.e. data/shaders/simpleShader01, data/shaders/colorTextureShader and data/shaders/lightingPass). I could not find these shader codes in https://github.com/openscenegraph/OpenSceneGraph-Data. ... Thank you! Cheers, Rômulo -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72730#72730 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Normal Mapping using Dynamic Cubemap
Hi Sebastian, I believe copying and pasting code is not the case here. I have read a lot about MRT, RTT and FBO and debugged some source code examples (including your hints), however I still have problems in my side to compute the normal. So let's go to new doubts: - In Kapelko's example, if I disable the bumpmap use, why is the normal still computed by using the TBN matrix (please see [0])? Why the nn is set to vec3(1.0)? In addition, why one of the walls does not contains data (green channel is missing?) - please see attachment? [0] https://bitbucket.org/kornerr/osg-deferred-shading/src/2b2f5532f41c305b31c46467291281388657b392/pass2.frag?at=default&fileviewer=file-view-default#pass2.frag-20 - ... Thank you! Cheers, Rômulo -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72729#72729 Attachments: http://forum.openscenegraph.org//files/screenshot_from_2018_01_11_11_13_50_144.png ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Normal Mapping using Dynamic Cubemap
Hi Rômulo, I already tried to describe the building-blocks for the way: 1. Render to FBO with MRT (see osgmultiplerendertargets example for this). The MRT/FBO-attachments should be your color, normal and depth. You'll need to use a shader that writes the correct information to the correct buffers. That's all in the example. Basically that's deferred rendering's approach. An example by Michael Kapelko can be found here: [0]. 2. Once you understand how to render to one FBO you can use your approach to render to the individual faces of your cubemap. You need to learn the basics. Pasting source code might not attract a lot of attention, so please try to follow my hints before asking the question over and over. [0] https://bitbucket.org/kornerr/osg-deferred-shading/src/5b8555059707?at=default Cheers Sebastian Am 26.12.2017 um 18:17 schrieb Rômulo Cerqueira: Hi Roberto and Sebastian, sorry for my duplicated post. I need to render the depth/normal surface to texture of reflected objects by cube maps. Until this moment, I got the depth data. Could you help me to get the normal data too (as single channel data). My current code follows below: C++ code: Code: // OSG includes #include #include #include #include #include #include #include #include #include #include #include #include // C++ includes #include #define SHADER_PATH_FRAG "normal_depth_map/shaders/normalDepthMap.frag" #define SHADER_PATH_VERT "normal_depth_map/shaders/normalDepthMap.vert" #define BOOST_TEST_MODULE "DynamicCubeMap_test" using namespace osg; unsigned int numTextures = 6; enum TextureUnitTypes { TEXTURE_UNIT_DIFFUSE, TEXTURE_UNIT_NORMAL, TEXTURE_UNIT_CUBEMAP }; osg::ref_ptr _create_scene() { osg::ref_ptr scene = new osg::Group; osg::ref_ptr geode = new osg::Geode; scene->addChild(geode.get()); const float radius = 0.8f; const float height = 1.0f; osg::ref_ptr shape; // sphere shape = new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(-3.0f, 0.0f, 0.0f), radius)); shape->setColor(osg::Vec4(0.6f, 0.8f, 0.8f, 1.0f)); geode->addDrawable(shape.get()); // box shape = new osg::ShapeDrawable(new osg::Box(osg::Vec3(3.0f, 0.0f, 0.0f), 2 * radius)); shape->setColor(osg::Vec4(0.4f, 0.9f, 0.3f, 1.0f)); geode->addDrawable(shape.get()); // cone shape = new osg::ShapeDrawable(new osg::Cylinder(osg::Vec3(0.0f, 0.0f, -3.0f), radius, height)); shape->setColor(osg::Vec4(1.0f, 0.3f, 0.3f, 1.0f)); geode->addDrawable(shape.get()); // cylinder shape = new osg::ShapeDrawable(new osg::Box(osg::Vec3(0.0f, 0.0f, 3.0f), 2* radius)); shape->setColor(osg::Vec4(0.8f, 0.8f, 0.4f, 1.0f)); geode->addDrawable(shape.get()); return scene; } osg::NodePath createReflector() { Geode* node = new Geode; const float radius = 0.8f; ref_ptr hints = new TessellationHints; hints->setDetailRatio(2.0f); ShapeDrawable* shape = new ShapeDrawable(new Sphere(Vec3(0.0f, 0.0f, 0.0f), radius * 1.5f), hints.get()); shape->setColor(Vec4(0.8f, 0.8f, 0.8f, 1.0f)); node->addDrawable(shape); osg::NodePath nodeList; nodeList.push_back(node); return nodeList; } class UpdateCameraAndTexGenCallback : public osg::NodeCallback { public: typedef std::vector< osg::ref_ptr > CameraList; UpdateCameraAndTexGenCallback(osg::NodePath& reflectorNodePath, CameraList& Cameras): _reflectorNodePath(reflectorNodePath), _Cameras(Cameras) { } virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) { // first update subgraph to make sure objects are all moved into position traverse(node,nv); // compute the position of the center of the reflector subgraph osg::Matrixd worldToLocal = osg::computeWorldToLocal(_reflectorNodePath); osg::BoundingSphere bs = _reflectorNodePath.back()->getBound(); osg::Vec3 position = bs.center(); typedef std::pair ImageData; const ImageData id[] = { ImageData( osg::Vec3( 1, 0, 0), osg::Vec3( 0, -1, 0) ), // +X ImageData( osg::Vec3(-1, 0, 0), osg::Vec3( 0, -1, 0) ), // -X ImageData( osg::Vec3( 0, 1, 0), osg::Vec3( 0, 0, 1) ), // +Y ImageData( osg::Vec3( 0, -1, 0), osg::Vec3( 0, 0, -1) ), // -Y ImageData( osg::Vec3( 0, 0, 1), osg::Vec3( 0, -1, 0) ), // +Z ImageData( osg::Vec3( 0, 0, -1), osg::Vec3( 0, -1, 0) ) // -Z }; for(unsigned int i = 0; i < 6 && i < _Cameras.size(); ++i) { osg::Matrix localOffset; localOffset.makeLookAt(position,position+id[i].first,id[i].second); osg::Matrix viewMatrix = worldToLocal*localOffset; _Cameras
Re: [osg-users] Normal Mapping using Dynamic Cubemap
Hi Roberto and Sebastian, sorry for my duplicated post. I need to render the depth/normal surface to texture of reflected objects by cube maps. Until this moment, I got the depth data. Could you help me to get the normal data too (as single channel data). My current code follows below: C++ code: Code: // OSG includes #include #include #include #include #include #include #include #include #include #include #include #include // C++ includes #include #define SHADER_PATH_FRAG "normal_depth_map/shaders/normalDepthMap.frag" #define SHADER_PATH_VERT "normal_depth_map/shaders/normalDepthMap.vert" #define BOOST_TEST_MODULE "DynamicCubeMap_test" using namespace osg; unsigned int numTextures = 6; enum TextureUnitTypes { TEXTURE_UNIT_DIFFUSE, TEXTURE_UNIT_NORMAL, TEXTURE_UNIT_CUBEMAP }; osg::ref_ptr _create_scene() { osg::ref_ptr scene = new osg::Group; osg::ref_ptr geode = new osg::Geode; scene->addChild(geode.get()); const float radius = 0.8f; const float height = 1.0f; osg::ref_ptr shape; // sphere shape = new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(-3.0f, 0.0f, 0.0f), radius)); shape->setColor(osg::Vec4(0.6f, 0.8f, 0.8f, 1.0f)); geode->addDrawable(shape.get()); // box shape = new osg::ShapeDrawable(new osg::Box(osg::Vec3(3.0f, 0.0f, 0.0f), 2 * radius)); shape->setColor(osg::Vec4(0.4f, 0.9f, 0.3f, 1.0f)); geode->addDrawable(shape.get()); // cone shape = new osg::ShapeDrawable(new osg::Cylinder(osg::Vec3(0.0f, 0.0f, -3.0f), radius, height)); shape->setColor(osg::Vec4(1.0f, 0.3f, 0.3f, 1.0f)); geode->addDrawable(shape.get()); // cylinder shape = new osg::ShapeDrawable(new osg::Box(osg::Vec3(0.0f, 0.0f, 3.0f), 2* radius)); shape->setColor(osg::Vec4(0.8f, 0.8f, 0.4f, 1.0f)); geode->addDrawable(shape.get()); return scene; } osg::NodePath createReflector() { Geode* node = new Geode; const float radius = 0.8f; ref_ptr hints = new TessellationHints; hints->setDetailRatio(2.0f); ShapeDrawable* shape = new ShapeDrawable(new Sphere(Vec3(0.0f, 0.0f, 0.0f), radius * 1.5f), hints.get()); shape->setColor(Vec4(0.8f, 0.8f, 0.8f, 1.0f)); node->addDrawable(shape); osg::NodePath nodeList; nodeList.push_back(node); return nodeList; } class UpdateCameraAndTexGenCallback : public osg::NodeCallback { public: typedef std::vector< osg::ref_ptr > CameraList; UpdateCameraAndTexGenCallback(osg::NodePath& reflectorNodePath, CameraList& Cameras): _reflectorNodePath(reflectorNodePath), _Cameras(Cameras) { } virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) { // first update subgraph to make sure objects are all moved into position traverse(node,nv); // compute the position of the center of the reflector subgraph osg::Matrixd worldToLocal = osg::computeWorldToLocal(_reflectorNodePath); osg::BoundingSphere bs = _reflectorNodePath.back()->getBound(); osg::Vec3 position = bs.center(); typedef std::pair ImageData; const ImageData id[] = { ImageData( osg::Vec3( 1, 0, 0), osg::Vec3( 0, -1, 0) ), // +X ImageData( osg::Vec3(-1, 0, 0), osg::Vec3( 0, -1, 0) ), // -X ImageData( osg::Vec3( 0, 1, 0), osg::Vec3( 0, 0, 1) ), // +Y ImageData( osg::Vec3( 0, -1, 0), osg::Vec3( 0, 0, -1) ), // -Y ImageData( osg::Vec3( 0, 0, 1), osg::Vec3( 0, -1, 0) ), // +Z ImageData( osg::Vec3( 0, 0, -1), osg::Vec3( 0, -1, 0) ) // -Z }; for(unsigned int i = 0; i < 6 && i < _Cameras.size(); ++i) { osg::Matrix localOffset; localOffset.makeLookAt(position,position+id[i].first,id[i].second); osg::Matrix viewMatrix = worldToLocal*localOffset; _Cameras[i]->setReferenceFrame(osg::Camera::ABSOLUTE_RF); _Cameras[i]->setProjectionMatrixAsFrustum(-1.0,1.0,-1.0,1.0,1.0,1.0); _Cameras[i]->setViewMatrix(viewMatrix); } } protected: virtual ~UpdateCameraAndTexGenCallback() {} osg::NodePath _reflectorNodePath; CameraList _Cameras; }; class TexMatCullCallback : public osg::NodeCallback { public: TexMatCullCallback(osg::TexMat* texmat): _texmat(texmat) { } virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) { // first update subgraph to make sure objects are all moved into position traverse(node,nv); osgUtil::CullVisitor* cv = dynamic_cast(nv); if (cv) { osg::Quat q = osg::Matrix::inverse(*cv->getModelViewMatrix()).getRotate();
Re: [osg-users] Normal Mapping using Dynamic Cubemap
Hi Sebastian, can you help me to find an example? I've been looking for this solution for almost two months. ... Thank you! Cheers, Rômulo -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72612#72612 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Normal Mapping using Dynamic Cubemap
Hi Rômulo, Repeating the question won't magically solve it. If you're after rendering normals and depth into textures (it doesn't matter if you are rendering to cubemap-faces IMHO) then see the multiple rendering target (MRT) example. Basically you need to attach a depth and normal target to your FBO and in a custom shader write the information to it (basically that's the first step in deferred rendering). There are some deferred-rendering/shading examples based on OSG around in the web. If you're unable to find them, I can help you to retrieve them. In the resolving pass, you need to bind the textures you've rendered to, to get the normals/depths. Beware that there will be issues concerning filtering (since depth and normals cannot be lineary interpolated in every case) Cheers Sebastian Am 19.12.2017 um 03:10 schrieb Rômulo Cerqueira: Hi, is it possible to generate dynamic cubemaps (with normal mapping textures)? ... Thank you! Cheers, Rômulo -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72606#72606 ___ 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