Re: [osg-users] How to add shadows to deferred shading?
HI Michael, On 21 October 2013 03:30, michael kapelko korn...@gmail.com wrote: Hi. Why is it the other way around? History :-) The OSG uses row major because it was the predominant convention used at the time of the OSG's inception, row major has the advantage that one doesn't need to transpose the vector before multiplying and data in the matrix is laid out how you would expect it. Then OpenGL adopted column major, despite still storing the matrices in row major order, now this was OK till OpenGL Shader Language came along and cemented the column major convention, but this time we already a big community using the OSG and code written to the row major convention. If I were to write a new scene graph today I'd choose column major simply to be compatible with GLSL, but with the existing OSG and community code switching would be far from t rival to switch over. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] problem about sequence of intersection points using osgUtil::PlaneIntersector
Hi, I am trying to get the intersection points between an intersection plane and a terrain using osgUtil::PlaneIntersector。 The code is listed as following: osg::Plane planeLeft( osg::Vec3(1,0,0), osg::Vec3(0+1,0,0) );//define an intersetion plane osg::Polytope polytopeLeft;//define the range of planeLeft polytopeLeft.add( osg::Plane(osg::Vec3(0,1,0), osg::Vec3(0,0,0)) ); polytopeLeft.add( osg::Plane(osg::Vec3(0,-1,0), osg::Vec3(0,GlobalVariable::g_maxDepth,0)) ); osg::ref_ptrosgUtil::PlaneIntersector insectorLeft = new osgUtil::PlaneIntersector(planeLeft, polytopeLeft); osgUtil::IntersectionVisitor ivleft(insectorLeft); geodeTerrain-accept(ivleft); if (insectorLeft-containsIntersections() ) { //output the intersection points fstream file; file.open(Terrain.txt,ios::out); osgUtil::PlaneIntersector::Intersections intersections = insectorLeft-getIntersections(); osgUtil::PlaneIntersector::Intersections::iterator itr = intersections.begin(); for ( unsigned int i=0; i(*itr).polyline.size(); ++i ) { file(*itr).polyline[i].x(),(*itr).polyline[i].y(),(*itr).polyline[i].z()std::endl; } file.close(); } I can get the intersection points successfully. But, when I change the terrain value just multiplying it with 3 and intersect with the same plane again, the sequence of output intersection points is reversed. So I wonder how can I control the sequence of the intersection points. Thank you! Cheers, Tianyun ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] problem about sequence of intersection points using osgUtil::PlaneIntersector
Hi Tianyun, The sequence that the points are joined up in will depend upon the algorithm which stitches all the triangle intersection segments together, it's objective is to stick things together not sort things into an order governed by the user - it's a complicated enough task that adding extra constraints wouldn't be helpful. If one did want to impose an order onto the file polylines generated then you are best doing this as post process. The alternatively is to simply write code that isn't sensitive to the ordering of the polylines. Robert. On 21 October 2013 08:45, Tianyun Su tianyun...@gmail.com wrote: Hi, I am trying to get the intersection points between an intersection plane and a terrain using osgUtil::PlaneIntersector。 The code is listed as following: osg::Plane planeLeft( osg::Vec3(1,0,0), osg::Vec3(0+1,0,0) );//define an intersetion plane osg::Polytope polytopeLeft;//define the range of planeLeft polytopeLeft.add( osg::Plane(osg::Vec3(0,1,0), osg::Vec3(0,0,0)) ); polytopeLeft.add( osg::Plane(osg::Vec3(0,-1,0), osg::Vec3(0,GlobalVariable::g_maxDepth,0)) ); osg::ref_ptrosgUtil::PlaneIntersector insectorLeft = new osgUtil::PlaneIntersector(planeLeft, polytopeLeft); osgUtil::IntersectionVisitor ivleft(insectorLeft); geodeTerrain-accept(ivleft); if (insectorLeft-containsIntersections() ) { //output the intersection points fstream file; file.open(Terrain.txt,ios::out); osgUtil::PlaneIntersector::Intersections intersections = insectorLeft-getIntersections(); osgUtil::PlaneIntersector::Intersections::iterator itr = intersections.begin(); for ( unsigned int i=0; i(*itr).polyline.size(); ++i ) { file(*itr).polyline[i].x(),(*itr).polyline[i].y(),(*itr).polyline[i].z()std::endl; } file.close(); } I can get the intersection points successfully. But, when I change the terrain value just multiplying it with 3 and intersect with the same plane again, the sequence of output intersection points is reversed. So I wonder how can I control the sequence of the intersection points. Thank you! Cheers, Tianyun ___ 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] How to add shadows to deferred shading?
Hi. I see. After I made shadowViewProjectionMatrix = V * P * translate(1, 1, 1) * scale(0.5, 0.5, 0.5) I finally got almost correct shadows: http://youtu.be/8KOCxiUkNsQ The final fragment shader is: http://goo.gl/cSYYfN Although, there are 3 problems: * there's wrong shadow at the left wall; * there's a strange stain at toruses' bottom which is altered by the main camera; * the shadow, as seen under the lowest torus, is altered by the main camera, too. What am I doing wrong? Thanks. 2013/10/21 Robert Osfield robert.osfi...@gmail.com HI Michael, On 21 October 2013 03:30, michael kapelko korn...@gmail.com wrote: Hi. Why is it the other way around? History :-) The OSG uses row major because it was the predominant convention used at the time of the OSG's inception, row major has the advantage that one doesn't need to transpose the vector before multiplying and data in the matrix is laid out how you would expect it. Then OpenGL adopted column major, despite still storing the matrices in row major order, now this was OK till OpenGL Shader Language came along and cemented the column major convention, but this time we already a big community using the OSG and code written to the row major convention. If I were to write a new scene graph today I'd choose column major simply to be compatible with GLSL, but with the existing OSG and community code switching would be far from t rival to switch over. Robert. ___ 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] problem about sequence of intersection points using osgUtil::PlaneIntersector
Hi Robert, As you suggested, I am ordering the sequence of intersection points with extra code after intersecting operation. But, I am wondering which operation of my program affects the algorithm stitching all the triangle intersection segments together and generate different order of intersection points. I just multiply the coordinates of each points with 3. I will check my program and data file again. Thank you. Tianyun On Mon, Oct 21, 2013 at 4:07 PM, Robert Osfield robert.osfi...@gmail.comwrote: Hi Tianyun, The sequence that the points are joined up in will depend upon the algorithm which stitches all the triangle intersection segments together, it's objective is to stick things together not sort things into an order governed by the user - it's a complicated enough task that adding extra constraints wouldn't be helpful. If one did want to impose an order onto the file polylines generated then you are best doing this as post process. The alternatively is to simply write code that isn't sensitive to the ordering of the polylines. Robert. On 21 October 2013 08:45, Tianyun Su tianyun...@gmail.com wrote: Hi, I am trying to get the intersection points between an intersection plane and a terrain using osgUtil::PlaneIntersector。 The code is listed as following: osg::Plane planeLeft( osg::Vec3(1,0,0), osg::Vec3(0+1,0,0) );//define an intersetion plane osg::Polytope polytopeLeft;//define the range of planeLeft polytopeLeft.add( osg::Plane(osg::Vec3(0,1,0), osg::Vec3(0,0,0)) ); polytopeLeft.add( osg::Plane(osg::Vec3(0,-1,0), osg::Vec3(0,GlobalVariable::g_maxDepth,0)) ); osg::ref_ptrosgUtil::PlaneIntersector insectorLeft = new osgUtil::PlaneIntersector(planeLeft, polytopeLeft); osgUtil::IntersectionVisitor ivleft(insectorLeft); geodeTerrain-accept(ivleft); if (insectorLeft-containsIntersections() ) { //output the intersection points fstream file; file.open(Terrain.txt,ios::out); osgUtil::PlaneIntersector::Intersections intersections = insectorLeft-getIntersections(); osgUtil::PlaneIntersector::Intersections::iterator itr = intersections.begin(); for ( unsigned int i=0; i(*itr).polyline.size(); ++i ) { file(*itr).polyline[i].x(),(*itr).polyline[i].y(),(*itr).polyline[i].z()std::endl; } file.close(); } I can get the intersection points successfully. But, when I change the terrain value just multiplying it with 3 and intersect with the same plane again, the sequence of output intersection points is reversed. So I wonder how can I control the sequence of the intersection points. Thank you! Cheers, Tianyun ___ 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] deferred shading in osg explained
Hi Community, is there some materials on this topic available somewhere? I know Wang Rui pointed to some code in osgRecipes for this, I am more into books, papers etc. Thanks, Nick -- trajce nikolov nick ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How to add shadows to deferred shading?
Hi, the shadow on the wall is probably created, because the wall is outside of the shadow cameras view frustum. How do you setup the wrapping of your depth texture? You could fix it, if you set the mode to clamp to border and set the border color to your far plane. This way everything that cannot be seen from your light source will not be shadowed(as in is outside of the view frustum). The shadow on your torus looks like a self shadowing problem. You will always have some errors because of the limited floating point precision. You should use a small offset in your depth comparison to get rid of this artifacts. A bit of tweaking will be necessary to get a good value. The last bug is indeed a bit strange. I'm not sure how it is produced. But it is view dependent, so it must have to do something with the view matrix of your main camera. Thank you! Cheers, Marcel -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56910#56910 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How to add shadows to deferred shading?
Hi. Can the third bug be related to different view projection matrices? My shadow camera uses ortho. Thanks. 2013/10/21 Marcel Pursche marcel.purs...@student.hpi.uni-potsdam.de Hi, the shadow on the wall is probably created, because the wall is outside of the shadow cameras view frustum. How do you setup the wrapping of your depth texture? You could fix it, if you set the mode to clamp to border and set the border color to your far plane. This way everything that cannot be seen from your light source will not be shadowed(as in is outside of the view frustum). The shadow on your torus looks like a self shadowing problem. You will always have some errors because of the limited floating point precision. You should use a small offset in your depth comparison to get rid of this artifacts. A bit of tweaking will be necessary to get a good value. The last bug is indeed a bit strange. I'm not sure how it is produced. But it is view dependent, so it must have to do something with the view matrix of your main camera. Thank you! Cheers, Marcel -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56910#56910 ___ 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] [3rdparty] OSG EXPORTER for 3DS MAX - Y-up
We are using Version 1.1.0, installed from here: http://sourceforge.net/projects/osgmaxexp/files/OpenSceneGraph%20Max%20Exporter/1.1.0/ Tim -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56913#56913 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [3rdparty] OSG EXPORTER for 3DS MAX - Y-up
Hi Tim, That exporter should behave correctly, meaning it should export the model in OSGs Z-up coordinate system. Which version were you previously using that exported as Y-up? Cheers, Farshid On Mon, Oct 21, 2013 at 7:31 AM, Tim Larson tlar...@hunter.com wrote: We are using Version 1.1.0, installed from here: http://sourceforge.net/projects/osgmaxexp/files/OpenSceneGraph%20Max%20Exporter/1.1.0/ Tim -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56913#56913 ___ 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