Re: [osg-users] texture mapping to trapezoid
Hi, Thanks for all the replies. My problem was solved by applying some sort of perspective correction to my texture coordinates. While creating the geometry I supplied a Vec3Array instead of a Vec2Array as tex coord array. The tex coords that stay on short edge of the trapezoid, get a z value of (len_short_edge / len_long_edge) whereas the the other tex coords got 1. Before sampling, the fragment shader divided the incoming tex coord vector by its z. (In order to obtain a texture coordinate whose z is always 1). I changed: osg::Vec2Array *t = new osg::Vec2Array; t->push_back(osg::Vec2(0, 0)); t->push_back(osg::Vec2(0, 1)); t->push_back(osg::Vec2(1, 1)); t->push_back(osg::Vec2(1, 0)); geom->setTexCoordArray(0, t); to: osg::Vec3Array *t = new osg::Vec3Array; t->push_back(osg::Vec3(0, 0, 1)); t->push_back(osg::Vec3(0, 0.33f, 0.33f)); t->push_back(osg::Vec3(0.33f, 0.33f, 0.33f)); t->push_back(osg::Vec3(1, 0, 1)); geom->setTexCoordArray(0, t); and used the following fragment shader: uniform sampler2D sampler; void main() { vec3 texCoord = gl_TexCoord[0]; gl_FragColor = texture2D(sampler, texCoord / texCoord.z); } Have a nice day, Can -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=12874#12874 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] texture mapping to trapezoid
Hi Shayne, Thank you for the quick response :) A screen shot of quad is available here: http://img36.imageshack.us/img36/5741/problem2009052217560820.jpg I left my texture attributes as default. Also didn't change anything at a parent stateset (in other words, i gave the node returned by createBillboard() directly to osgViewer::setSceneData) my texture is a 256x256 bmp file which is available here: http://img40.imageshack.us/img40/981/spot.png Thanks, Can -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=12768#12768 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] texture mapping to trapezoid
Hi, I 'm having trouble mapping a texture2d to a quad. The texture looks correct when the quad is rectangle/square shaped, but incorrect when it is trapezoid shaped. I'm using the following code to create the geometry: http://pastebin.com/m47ba3f47 How can i fix it so that the texture looks correct (as if it was squeezed at the top and stretched at the bottom) Thank you! Cheers, Can -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=12760#12760 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] how to draw an object once
you can try adding an osg::Switch as a parent of your model and deactivate the subgraph containing your model using a custom UpdateCallback -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=11266#11266 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] unable to glReadPixels in osg::Drawable::drawImplementation
looks like the problem isn't with the code itself, but the scene graph that gets rendered before somehow didn't write to the depth buffer. sorry for bothering you, can -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=11053#11053 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] unable to glReadPixels in osg::Drawable::drawImplementation
Hi, I'm trying to implement a custom osg::Drawable which need to check the depth component of a certain pixel before rendering itself. The problem is, glReadPixels always returns 1.0 (even for the entire viewport, which obviously should not be possible). I didn't touch the default settings of depth test/range. Can anyone guess what the problem might be? ... Thank you. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=11044#11044 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] requesting help on lighting system
Hello, We are developing a commercial game/simulation engine based on OpenSceneGraph. We will be using this engine for a driving simulator that takes place in urban environments. Right now our most challenging problem is how to implement a high performance lighting system without compromising visual quality. The first issue was the poor lighting quality offered by fixed function pipeline, which we tried to overcome by using per-pixel lighting in shaders. The second issue we faced was the 8 light source limit of OpenGL. We tried to overcome this issue by using either selective lighting or multipass lighting. Selective lighting was fast, but introduced visual awkwardness like suddenly switching on light sources while navigating the environment. The multipass solution was better, but it degraded performance when used in combination with shaders. Since most of the lights in our scene are static (i.e. street lamps), we thought about disburdening the gpu by using lightmaps for static light sources. Unfortunately, using the lightmap generation offered by modelling tools is not an option since our customers will be able to create new environments in a custom "map editor" application. We implemented a simple lightmap generator which generates a separate lightmap for each drawable and for each light state (on/off), but this heavily increased our memory usage. We would like to hear your opinions on how we should progress from now on. Also, some sources of information regarding the subject will be very much appreciated. Thanks in advance, Can Hosgor -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=9502#9502 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] transforming normals
Thanks, I will try it as soon as possible -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=8879#8879 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] transforming normals
Hi, I'm writing a simple nodevisitor to compute the lightmap of a given node. This nodevisitor treats transforms and geodes specially, so that each vertex in the geometry is multiplied with the most recent transform matrix in order to obtain world coordinates. So far the above code works well except that i don't know how to transform the normals. Can I obtain the normal matrix directly from the transformation matrix, if so how? Thank you, Can -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=8857#8857 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] PagedLOD - paging out of nodes?
Hello, Currently, I'm trying to learn how paging works in osg. As an example, I divided my scene into several tiles, where each tile is an osg::PagedLOD. Then I add three osg::Groups to each tile. Each group contains some models i loaded for a specific detail level. In other words, the first group contains large buildings which can be seen from a large distance, the second group relatively smaller buildings an so forth. So far, the LOD functionality works great, now i want the PagedLODs to unload its contents when not visible, and load back when they become visible again. I wonder if this is supported by PagedLOD by default or should I take some other approach. Thanks, Can Hosgor -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=7128#7128 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org