Re: [osg-users] Precipitation effect coming too fast, and hiding on some areas
Hi Robert, On Mon, Dec 15, 2008 at 7:55 AM, Robert Osfield robert.osfi...@gmail.comwrote: Hi Fred Jefferson, On Sun, Dec 14, 2008 at 10:49 AM, Frederic Bouvier fredlis...@free.fr wrote: I have a patch to PrecipitationEffect that seems to work. I'll submit it to osg-submissions I've just done a review of these changes and don't feel that there are mostr straightforward and effecient way to implement what is effectively near plan clipping. The code will make the vertex program slower, and not cut down on rasteristation and fill load. I feel a better route would be to either: 1) use two Camera's to depth partition the scene as suggested earlier in this thread, as this would give you control over the worlds depth range where the precipitation exists This one works! 2) Use an osg::ClipPlane to clip the precipitation effect. Using a clip plan would also allow you to control angle of the clipping. I don't know how to use that (I'm a beginner). Fred, I would be grateful if you could share your code, if you do it. Neither the above routes require any changes to the core OSG, and both would not affect the vertex program load, and would clip out fragment so would cut down the fragment program load so would be more efficient than the submitted fix. Could you test out the above suggestions? Thanks, Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Jefferson Pinheiro (51) 9192 3535 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Precipitation effect coming too fast, and hiding on some areas
I'm working on a driving project on OSG, and now I am making it rain. I added a precipitation effect for that. My scale is 1 unit = 1 cm. *First question:* When my car runs just a bit (say, 5 km/h), the rain comes at my face as though I was running at 200 km/h. And if I run faster than 20 km/h or so, the rain bacomes glitchy (looks like it's snowing, too). How do I change the speed at which the rain comes? *Second question* It also rains inside my car. I tried adding a node mask for that, but it didn't seem to work. Is it possible not to make it rain inside the cars (which are on a separete osg::Group)? Thanks, -- Jefferson Pinheiro ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Precipitation effect coming too fast, and hiding on some areas
Hi Robert, On Fri, Dec 12, 2008 at 2:26 PM, Robert Osfield robert.osfi...@gmail.comwrote: Hi Jefferson, On Fri, Dec 12, 2008 at 3:56 PM, Jefferson Pinheiro jeffersonmpinhe...@gmail.com wrote: I'm working on a driving project on OSG, and now I am making it rain. I added a precipitation effect for that. My scale is 1 unit = 1 cm. First question: When my car runs just a bit (say, 5 km/h), the rain comes at my face as though I was running at 200 km/h. And if I run faster than 20 km/h or so, the rain bacomes glitchy (looks like it's snowing, too). Shudder. Why or why would you have such a scale? Can't you just have a sensible scale like 1 unit = 1m? Even so, my colleague's project is on that scale and the same thing happens. I you really must have such as scale then try putting a scale above the PrecipitationEffect. setParticleSize? I tried increasing that, and big values causes the rain to look like snow; lower values makes it look normal or too small. Or adding a matrix transform and scale matrix? That didn't seem to work, either. How do I change the speed at which the rain comes? Have you looked at the API? I tried several combinations of setParticleSpeed, wind and cell size, the problem persisting. Is it possible to just disable the effect of rain coming at your face when the camera moves forward? Second question It also rains inside my car. I tried adding a node mask for that, but it didn't seem to work. Is it possible not to make it rain inside the cars (which are on a separete osg::Group)? PrecipitationEffect doesn't have an support itself for constraining the effect to appear inside/outside specified geometries. The best thing you could do would be to either try using the stencil buffer to prevent the fragments of the effect being rendered where you don't want them. Thanks, I'll take a look at that. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Jefferson Pinheiro ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Request: bool Polytope.contains(another_polytope)
I understand. About my other question then, there is currently no workaround to test collision between two polytopes? I tried polytope.contains(polytope2.getReferenceVertexList()) but it doesn't seems to work either (always returning false). Any other ideas? On Thu, Dec 4, 2008 at 7:05 AM, Robert Osfield [EMAIL PROTECTED]wrote: Hi Jefferson, Like Gordon says, if you need the function then the thing to do is implement it and submit it. I'm not hear to take end users feature requests and then go a implement them for free. I have bucket load of work to do, working well over my forty hour week every week, with many of these hours doing project maintenance and support work without financial return, the simply is no scope for doing extra stuff just out of kind heartedness - I do strangely enough have a life outside the OSG. Robert. On Wed, Dec 3, 2008 at 8:10 PM, Jefferson Pinheiro [EMAIL PROTECTED] wrote: Hello Robert, Can you please implement a function, in class Polytope, that checks if the current polytope intersects another polytope? Or is there another way to do that, and I'm not seeing? Thanks, -- Jefferson Pinheiro ___ 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 -- Jefferson Pinheiro (51) 9192 3535 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Request: bool Polytope.contains(another_polytope)
Hello Robert, Can you please implement a function, in class Polytope, that checks if the current polytope intersects another polytope? Or is there another way to do that, and I'm not seeing? Thanks, -- Jefferson Pinheiro ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Request: bool Polytope.contains(another_polytope)
Alas, I lack the knowledge to do that. On Wed, Dec 3, 2008 at 6:25 PM, Tomlinson, Gordon [EMAIL PROTECTED] wrote: Rather than asking Robert to implement this function you could implent it your self as you have the source and contribute it back to the OSG source and community for which we would all be grateful *Gordon* __ *Gordon Tomlinson* *Product Manager 3D **Email * : gtomlinson @ overwatch.textron.com __ *(C): (+1) 571-265-2612 (W)**: (+1) 703-437-7651* Self defence is not a function of learning tricks but is a function of how quickly and intensely one can arouse one's instinct for survival - *Master Tambo Tetsura* -- *From:* [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED] *On Behalf Of *Jefferson Pinheiro *Sent:* Wednesday, December 03, 2008 3:11 PM *To:* OpenSceneGraph Users *Subject:* [osg-users] Request: bool Polytope.contains(another_polytope) Hello Robert, Can you please implement a function, in class Polytope, that checks if the current polytope intersects another polytope? Or is there another way to do that, and I'm not seeing? Thanks, -- Jefferson Pinheiro ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Jefferson Pinheiro (51) 9192 3535 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] zNear and zFar making no difference
For performance reasons, I want to render only that which is close to my camera. I tried changing zNear and zFar, but they make absolutely no effect (I tried values such as 100,200; 10,20; 0.01;0.02). However, for instance, changing the FOV (which is 80 now), does changes the FOV. My world scale is 1 unit = 1 cm. What might be wrong? { viewer.setCameraManipulator(cm); //cm = class CamManipCarro : public osgGA::MatrixManipulator (a custom camera manpulator) osg::ref_ptrosg::GraphicsContext::Traits traits = new osg::GraphicsContext::Traits; traits-x = 0; traits-y = 0; traits-width = GetSystemMetrics(SM_CXSCREEN); traits-height = GetSystemMetrics(SM_CYSCREEN); traits-windowDecoration = false; traits-doubleBuffer = true; //traits-sharedContext = 0; osg::ref_ptrosg::GraphicsContext gc = osg::GraphicsContext::createGraphicsContext(traits.get()); // HERE !! Changing the last 2 parameters makes no effect. I wanted it would render only that which is between 100 and 200 units from my camera. viewer.getCamera()-setProjectionMatrixAsPerspective(80,(double) GetSystemMetrics(SM_CXSCREEN) / (double) GetSystemMetrics(SM_CYSCREEN),100,200); viewer.getCamera()-setNearFarRatio(0.02); viewer.getCamera()-setGraphicsContext(gc.get()); viewer.getCamera()-setViewport(new osg::Viewport(0,0, traits-width, traits-height)); GLenum buffer = traits-doubleBuffer ? GL_BACK : GL_FRONT; viewer.getCamera()-setDrawBuffer(buffer); viewer.getCamera()-setReadBuffer(buffer); osg::Camera* hudCamera = createHUD(); hudCamera-setGraphicsContext(gc.get()); hudCamera-setViewport(0,0,traits-width, traits-height); viewer.addSlave(hudCamera, false); viewer.setSceneData(root); viewer.realize(); viewer.getCamera()-setUpdateCallback(new CameraUpdateCallback()); } -- Jefferson Pinheiro ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] zNear and zFar making no difference
Ah, thanks, that solved the problem. However, there is now a new problem: is it possible to change this view distance for everything, except the skybox (so that the skybox is always rendered)? My skybox, currently, is on a Group, that is child of root. On Tue, Dec 2, 2008 at 5:05 PM, Robert Osfield [EMAIL PROTECTED]wrote: HI Jefferson, The OSG by default doesn't enable the near and far planes for culling purposes, as doing so would require end users to accurately manage their near/far plane. To enable the near/far culling simple do: viewer-getCamera()-setCullingMode(osg::CullSettings::VIEW_FRUSTUM_CULLING | osg::CullSettings::SMALL_FEATURE_CULLING); You may also want to disable the compute and near/far planes. viewer-getCamera()-setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); Robert. On Tue, Dec 2, 2008 at 7:48 PM, Jefferson Pinheiro [EMAIL PROTECTED] wrote: For performance reasons, I want to render only that which is close to my camera. I tried changing zNear and zFar, but they make absolutely no effect (I tried values such as 100,200; 10,20; 0.01;0.02). However, for instance, changing the FOV (which is 80 now), does changes the FOV. My world scale is 1 unit = 1 cm. What might be wrong? { viewer.setCameraManipulator(cm); //cm = class CamManipCarro : public osgGA::MatrixManipulator (a custom camera manpulator) osg::ref_ptrosg::GraphicsContext::Traits traits = new osg::GraphicsContext::Traits; traits-x = 0; traits-y = 0; traits-width = GetSystemMetrics(SM_CXSCREEN); traits-height = GetSystemMetrics(SM_CYSCREEN); traits-windowDecoration = false; traits-doubleBuffer = true; //traits-sharedContext = 0; osg::ref_ptrosg::GraphicsContext gc = osg::GraphicsContext::createGraphicsContext(traits.get()); // HERE !! Changing the last 2 parameters makes no effect. I wanted it would render only that which is between 100 and 200 units from my camera. viewer.getCamera()-setProjectionMatrixAsPerspective(80,(double) GetSystemMetrics(SM_CXSCREEN) / (double) GetSystemMetrics(SM_CYSCREEN),100,200); viewer.getCamera()-setNearFarRatio(0.02); viewer.getCamera()-setGraphicsContext(gc.get()); viewer.getCamera()-setViewport(new osg::Viewport(0,0, traits-width, traits-height)); GLenum buffer = traits-doubleBuffer ? GL_BACK : GL_FRONT; viewer.getCamera()-setDrawBuffer(buffer); viewer.getCamera()-setReadBuffer(buffer); osg::Camera* hudCamera = createHUD(); hudCamera-setGraphicsContext(gc.get()); hudCamera-setViewport(0,0,traits-width, traits-height); viewer.addSlave(hudCamera, false); viewer.setSceneData(root); viewer.realize(); viewer.getCamera()-setUpdateCallback(new CameraUpdateCallback()); } -- Jefferson Pinheiro ___ 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 -- Jefferson Pinheiro (51) 9192 3535 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Migrating to a forum?
I would prefer a forum too. Even though I use gmail with filters. 2008/11/4 Jean-Sébastien Guay [EMAIL PROTECTED] Hi Peter, like you said just to forums instead.. every descent forum has thread notifications. So no need to track down forums, you will get an email when someone has answered or posted in your forum thread. So you prefer getting e-mail *and* going to a forum rather than just getting e-mail? A lot of us at least skim all topics, and read most of them. Using a forum in that case would just be too long (switching to topics all the time, waiting for pages to display). And we would then get notification for all topics we're interested in, which would be equivalent to a mailing list. E-mail is instantaneous (once it's downloaded) and much more efficient for our time. J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Jefferson Pinheiro (51) 9192 3535 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Untextured materials = pure black
Can you tell me, please, how to set a default texture for the root? 2008/11/2 Jean-Sébastien Guay [EMAIL PROTECTED] Hi Jefferson, Just to add to what Terry said: b) set a simple default texture (for example, a 1x1 white texture) on the root node of your scene. This is what ShadowMap does (and the new ViewDependentShadow too) which is why you don't have that problem when using ShadowMap. SoftShadowMap could be modified to do it too, but hasn't yet, which probably just means not too many people use it. J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Jefferson Pinheiro (51) 9192 3535 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Disable self shadows (ShadowMap)
Or, attach an empty osg::Program to get the fixed pipeline. If you're just using the default shadow shader for your shadows, the fixed pipeline for your cars might be sufficient instead of having to write a shader without shadowing yourself. car_node-getOrCreateStateSet()-setAttributeAndModes( new osg::Program, osg::StateAttribute::ON); That makes every car receive some weird, colorful noise. Firstly, I notice that you are using OSG 2.6. The versatility of the API into the shadowing stuff is much better in the 2.7 versions, and allows you better control over what is being applied, so I recommend you move to that if you can. I've just compiled and tried OSG 2.7.4. But I don't understand what you mean by better control. I was expecting to see, in the header ShadowedScene, something like: - setOnlyReceivesShadowTraversalMask - setOnlyCastsShadowTraversalMask - setCastsAndReceivesShadowTraversalMask Perhaps that could be implemented? Otherwise, how would you do, in OSG 2.7, to disable self-shadowing? Thanks, Jefferson 2008/11/2 Jean-Sébastien Guay [EMAIL PROTECTED] Hi Jefferson, Once again, a complement to the info David provided: Create a shader - you can use the GLSL in ShadowMap.cpp as a starting point - and then bind it to your car node stateset with the usual methods Or, attach an empty osg::Program to get the fixed pipeline. If you're just using the default shadow shader for your shadows, the fixed pipeline for your cars might be sufficient instead of having to write a shader without shadowing yourself. car_node-getOrCreateStateSet()-setAttributeAndModes( new osg::Program, osg::StateAttribute::ON); Hope this helps, J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] http://www.cm-labs.com/ http://whitestar02.webhop.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
Re: [osg-users] Untextured materials = pure black
Yes, that solved the problem. Many thanks, you both! I'm posting the code, for reference. osg::ref_ptrosg::StateSet stateSet(root-getOrCreateStateSet()); osg::Image* image = new osg::Image; // allocate the image data, noPixels x 1 x 1 with 4 rgba floats - equivilant to a Vec4! int noPixels = 1; image-allocateImage(noPixels,1,1,GL_RGBA,GL_FLOAT); image-setInternalTextureFormat(GL_RGBA); // fill in the image data. osg::Vec4* dataPtr = (osg::Vec4*)image-data(); osg::Vec4 color(1,1,1,1); *dataPtr = color; // make fake texture osg::Texture2D* fakeTex = new osg::Texture2D; fakeTex-setWrap(osg::Texture2D::WRAP_S,osg::Texture2D::CLAMP_TO_EDGE); fakeTex-setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::CLAMP_TO_EDGE); fakeTex-setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR); fakeTex-setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR); fakeTex-setImage(image); // add fake texture stateSet-setTextureAttribute(0,fakeTex,osg::StateAttribute::ON); stateSet-setTextureMode(0,GL_TEXTURE_1D,osg::StateAttribute::OFF); stateSet-setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::ON); stateSet-setTextureMode(0,GL_TEXTURE_3D,osg::StateAttribute::OFF); 2008/11/3 Jean-Sébastien Guay [EMAIL PROTECTED] Hello Jefferson, Can you tell me, please, how to set a default texture for the root? See src/osgShadow/ShadowMap.cpp around line 290, which starts with this comment: // fake texture for baseTexture, add a fake texture // we support by default at least one texture layer // without this fake texture we can not support // textured and not textured scene You can set this 1x1 white texture at the root of your graph, and if any node has a different texture on unit 0 it will override it automatically. Hope this helps, J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Jefferson Pinheiro (51) 9192 3535 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Real size model how to??
Try scaling up in your code. osg::Matrix scale; scale.makeScale(10,10,10); osg::MatrixTransform *myMatrixTransform= new MatrixTransform(); myMatrixTransform-setMatrix(scale); myMatrixTransform-addChild(frogNode); root-addChild(myMatrixTransform); 2008/11/2 [EMAIL PROTECTED] Hello, I'm loading a model using osgDB::readNodeFile(frog.3ds). osg seems to scale down my model, if I scale down/up my modwl using 3DStudio, it has no effect on OSG, it always show it the same size. any idea?? thank you. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Jefferson Pinheiro (51) 9192 3535 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Disable self shadows (ShadowMap)
Consider this scene: - Terrain and some buildings: osg::Group sceneNode - Several cars: osg::Group carNode Both are children of a ShadowedScene. I'm using ShadowMap as a technique. I want that the buildings cast shadows on the terrain/road (that is working fine), and that the cars cast shadows on the terrain, BUT not on themselves (disable self shadows for the car node). Is that possible? - Jefferson ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Untextured materials = pure black
Every material that has no texture associated becomes completely black when I do one of the following: - change the shadow technique from ShadowMap to SoftShadowMap - add any of the GLSL bloom shader I found on the net ( http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=27976postdays=0postorder=ascstart=0or http://www.gamedev.net/community/forums/topic.asp?topic_id=395186) Any idea why this is happening? Details: I have a single light, declared thusly: osg::Vec3 lightPosition(4,4,8); // my prog's scale is big osg::LightSource* ls = new osg::LightSource; ls-getLight()-setPosition(osg::Vec4(lightPosition,1)); ls-getLight()-setAmbient(osg::Vec4(0.5,0.5,0.5,1.0)); ls-getLight()-setDiffuse(osg::Vec4(0.9,0.9,0.9,1.0)); shadowedScene-addChild(ls); I'm posting direct links to the shaders, case you're lazy to open those ones :) http://magiadosdoces.com/temp/PP_GL_Bloom1.fx http://magiadosdoces.com/temp/PP_GL_Bloom2.fx http://magiadosdoces.com/temp/PP_GL_Bloom3.fx http://magiadosdoces.com/temp/PP_GL_Bloom4.fx http://magiadosdoces.com/temp/shader.frag And this is how I'm loading the shaders: osg::ref_ptrosg::StateSet stateSet(root-getOrCreateStateSet()); osg::Program* program = new osg::Program; osg::Shader* frag = new osg::Shader( osg::Shader::FRAGMENT ); frag-loadShaderSourceFromFile(Shaders/shader.frag); program-addShader(frag); stateSet.get()-setAttributeAndModes(program, osg::StateAttribute::ON); I'm using OSG 2.6, Windows Vista 64, Geforce 8800M GTS. Oh and by the way, the bloom shader effect doesn't works even on the textured surfaces. They simply remain the same. Image: http://magiadosdoces.com/temp/car.jpg Thanks, Jefferson ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org