Re: [osg-users] osgPPU osgShadow
Hi Art and all, I am coming back on this subject because I am currently trying to use osgPPU with osgShadow. I've followed this thread instructions and it works, but only with the ShadowMap technique, and the one I prefer is MinimalShadowMap. With this one, combined with HDR, it renders all my scene in white... Any idea on what to do ? Thanks ! On Wed, Oct 8, 2008 at 12:22 AM, Art Tevs stud_in...@yahoo.de wrote: Hi, Awesome, thanks for the correction. I see that my initial example forgot to actually add the model to the shadowed scene :P But that wasn't the real problem. The real problem was giving osgPPU the same node that i was using for shadows. I do not realy understand what you mean here with giving osgPPU the same node as for shadows. osgPPU doesn't now anything about the graph, it does only get camera as input, hence use the camera color buffer texture as input. Therefor the camera, which is connected to the osgPPU, which can be your main camera or some other one, should be able to render your shadowed scene. Cheers, art After seeing what you did in your correction I rearranged the graph like this: scene-addChild(shadowedScene); shadowedScene-addChild(loadedModel); and everything worked as expected. Now I just want to understand why this worked. It it because osgPPU and osgShadow are no longer fighting to control the state of the single scene node? ___ 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 -- Serge Lages http://www.tharsis-software.com ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgPPU osgShadow
I did mention this a while back about osgShadow. All my are examples do this now after installing a new Nvidia GTX 480 card(from a gtx 9800), with the latest drivers from Nvidia. My guess you are running Windows Vista/7, try alt tab? For a permanent fix disable the pesky Aero desktop! I tried looking for a fix last night and its something to do with swapbuffers either being called or not, I cannot remember it was late and the viewer code was baffling me! Ok it might b Regards Martin -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Art Tevs Sent: 02 October 2008 15:14 To: OpenSceneGraph Users Subject: Re: [osg-users] osgPPU osgShadow Hi Michael, I have never tried osgShadow at all, hence I can not say what happens if you use osgPPU with it. Could you prepare some simple example showing the issue? Maybe try the newest version from the svn, since there are some changes to the previous one. Best regards, art Hi guys, I've recently delved into osgPPU and am loving it. I have a scene beautifully rendering with HDR. However, when I tried adding osgShadow ShadowMap to the scene I had conflicts. I don't yet know exactly what is going just yet but I was wondering if anyone has had success combining these two and if so, I would appreciate the help. Thanks, Michael ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org __ Gesendet von Yahoo! Mail. Dem pfiffigeren Posteingang. http://de.overview.mail.yahoo.com ___ 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] osgPPU osgShadow
And my email updated and I see you found a solution... Oh well its probably just me ;) Martin -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Art Tevs Sent: 07 October 2008 23:22 To: OpenSceneGraph Users Subject: Re: [osg-users] osgPPU osgShadow Hi, Awesome, thanks for the correction. I see that my initial example forgot to actually add the model to the shadowed scene :P But that wasn't the real problem. The real problem was giving osgPPU the same node that i was using for shadows. I do not realy understand what you mean here with giving osgPPU the same node as for shadows. osgPPU doesn't now anything about the graph, it does only get camera as input, hence use the camera color buffer texture as input. Therefor the camera, which is connected to the osgPPU, which can be your main camera or some other one, should be able to render your shadowed scene. Cheers, art After seeing what you did in your correction I rearranged the graph like this: scene-addChild(shadowedScene); shadowedScene-addChild(loadedModel); and everything worked as expected. Now I just want to understand why this worked. It it because osgPPU and osgShadow are no longer fighting to control the state of the single scene node? ___ 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
Re: [osg-users] osgPPU osgShadow
Hi Martin, thanks for your reply but I am talking about another problem. The problem with osgShadow + Seven/Vista + fullscreen = black screen is pretty familiar to me, but I always disable aero on final setups so it's not a deal. My current problem is with osgShadow::MinimalShadowMap and osgPPU, my scene becomes white, but it works with the osgShadow::ShadowMap technique. Cheers, On Wed, May 12, 2010 at 6:10 PM, Martin Naylor martin.nay...@dsl.pipex.comwrote: And my email updated and I see you found a solution... Oh well its probably just me ;) Martin -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Art Tevs Sent: 07 October 2008 23:22 To: OpenSceneGraph Users Subject: Re: [osg-users] osgPPU osgShadow Hi, Awesome, thanks for the correction. I see that my initial example forgot to actually add the model to the shadowed scene :P But that wasn't the real problem. The real problem was giving osgPPU the same node that i was using for shadows. I do not realy understand what you mean here with giving osgPPU the same node as for shadows. osgPPU doesn't now anything about the graph, it does only get camera as input, hence use the camera color buffer texture as input. Therefor the camera, which is connected to the osgPPU, which can be your main camera or some other one, should be able to render your shadowed scene. Cheers, art After seeing what you did in your correction I rearranged the graph like this: scene-addChild(shadowedScene); shadowedScene-addChild(loadedModel); and everything worked as expected. Now I just want to understand why this worked. It it because osgPPU and osgShadow are no longer fighting to control the state of the single scene node? ___ 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 -- Serge Lages http://www.tharsis-software.com ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgPPU osgShadow
Hi Serge, Yeah sorry I somehow posted to a 2 year post. Good luck with your problem, I will butt out now as its out of my league J Martin. From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Serge Lages Sent: 12 May 2010 17:17 To: OpenSceneGraph Users Subject: Re: [osg-users] osgPPU osgShadow Hi Martin, thanks for your reply but I am talking about another problem. The problem with osgShadow + Seven/Vista + fullscreen = black screen is pretty familiar to me, but I always disable aero on final setups so it's not a deal. My current problem is with osgShadow::MinimalShadowMap and osgPPU, my scene becomes white, but it works with the osgShadow::ShadowMap technique. Cheers, On Wed, May 12, 2010 at 6:10 PM, Martin Naylor martin.nay...@dsl.pipex.com wrote: And my email updated and I see you found a solution... Oh well its probably just me ;) Martin -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Art Tevs Sent: 07 October 2008 23:22 To: OpenSceneGraph Users Subject: Re: [osg-users] osgPPU osgShadow Hi, Awesome, thanks for the correction. I see that my initial example forgot to actually add the model to the shadowed scene :P But that wasn't the real problem. The real problem was giving osgPPU the same node that i was using for shadows. I do not realy understand what you mean here with giving osgPPU the same node as for shadows. osgPPU doesn't now anything about the graph, it does only get camera as input, hence use the camera color buffer texture as input. Therefor the camera, which is connected to the osgPPU, which can be your main camera or some other one, should be able to render your shadowed scene. Cheers, art After seeing what you did in your correction I rearranged the graph like this: scene-addChild(shadowedScene); shadowedScene-addChild(loadedModel); and everything worked as expected. Now I just want to understand why this worked. It it because osgPPU and osgShadow are no longer fighting to control the state of the single scene node? ___ 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 -- Serge Lages http://www.tharsis-software.com ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgPPU osgShadow
Hi Art, thanks for your attention. I've constructed an example for you by minimally modifying Example viewer. Below is the modified view.cpp. It has an additional createScene function that sets up a shadowed scene. Also note the #define ENABLE_SHADOWS. Commenting that out will use the default scene instead of the shadowed one for comparison. Michael PS You'll have to link to osgShadow as well of course #include osg/GLExtensions #include osgViewer/Renderer #include osgGA/TrackballManipulator #include osgDB/WriteFile #include osgPPU/Processor.h #include osgteapot.h #define ENABLE_SHADOWS #if defined (ENABLE_SHADOWS) # include osgShadow/ShadowedScene # include osgShadow/ShadowMap # include osg/LightSource #endif //-- // Create camera resulting texture //-- osg::Texture* createRenderTexture(int tex_width, int tex_height, bool depth) { // create simple 2D texture osg::Texture2D* texture2D = new osg::Texture2D; texture2D-setTextureSize(tex_width, tex_height); texture2D-setResizeNonPowerOfTwoHint(false); texture2D-setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR); texture2D-setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR); texture2D-setWrap(osg::Texture2D::WRAP_S,osg::Texture2D::CLAMP_TO_BORDER); texture2D-setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::CLAMP_TO_BORDER); texture2D-setBorderColor(osg::Vec4(1.0f,1.0f,1.0f,1.0f)); // setup float format if (!depth) { texture2D-setInternalFormat(GL_RGBA16F_ARB); texture2D-setSourceFormat(GL_RGBA); texture2D-setSourceType(GL_FLOAT); }else{ texture2D-setInternalFormat(GL_DEPTH_COMPONENT); } return texture2D; } //-- // Create scene //-- osg::Group* createScene(const std::string filename) { osg::Node* loadedModel = NULL; // Load in the model to use in our scene if (!filename.empty()) loadedModel = osgDB::readNodeFile(filename); if (!loadedModel) loadedModel = createTeapot(); if (!loadedModel) return NULL; #if defined (ENABLE_SHADOWS) const int ReceivesShadowTraversalMask = 0x1; const int CastsShadowTraversalMask = 0x2; osgShadow::ShadowedScene* shadowedScene = new osgShadow::ShadowedScene; shadowedScene-setReceivesShadowTraversalMask(ReceivesShadowTraversalMask); shadowedScene-setCastsShadowTraversalMask(CastsShadowTraversalMask); osg::LightSource* lightSource = new osg::LightSource; lightSource-getLight()-setPosition( osg::Vec4(osg::Vec3(100.0, 0.0, 100.0f), 0.0f)); // Setup the scene with shadows via shadow mapping osgShadow::ShadowMap* shadowMap = new osgShadow::ShadowMap; shadowMap-setTextureSize(osg::Vec2s(1024, 1024)); shadowMap-setLight(lightSource); shadowedScene-setShadowTechnique(shadowMap); shadowedScene-addChild(lightSource); return shadowedScene; #else osg::Group* scene = new osg::Group; scene-addChild(loadedModel); return scene; #endif } //-- // Setup the camera to do the render to texture //-- void setupCamera(osg::Camera* camera) { osg::Viewport* vp = camera-getViewport(); // create texture to render to osg::Texture* texture = createRenderTexture((int)vp-width(), (int)vp-height(), false); osg::Texture* depthTexture = createRenderTexture((int)vp-width(), (int)vp-height(), true); // set up the background color and clear mask. camera-setClearColor(osg::Vec4(0.0f,0.0f,0.0f,0.0f)); camera-setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // set viewport camera-setViewport(vp); camera-setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); camera-setProjectionMatrixAsPerspective(35.0, vp-width()/vp-height(), 1.0, 256.0); // tell the camera to use OpenGL frame buffer object where supported. camera-setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT); // attach the texture and use it as the color buffer. camera-attach(osg::Camera::COLOR_BUFFER, texture); camera-attach(osg::Camera::DEPTH_BUFFER, depthTexture); } //-- int main(int argc, char **argv) { // parse arguments osg::ArgumentParser arguments(argc,argv); // give some info in the console printf(view ppufile [osgfile]\n); if (argc = 1) return 0; // construct the viewer. osg::ref_ptrosgViewer::Viewer viewer = new osgViewer::Viewer(); unsigned int screenWidth; unsigned int screenHeight;
Re: [osg-users] osgPPU osgShadow
Hi Michael, hmm, your setup for the shadowed scene isn't correct. I have attached a changed setup where I am able to see the teapot shadowed by some shadow technique and also working perfectly with the osgPPU (latest svn release). Look at it. Call with ./viewer Data/motionblur.ppu Does it solve your problem? Cheers, art --- Michael Guerrero [EMAIL PROTECTED] schrieb am Di, 7.10.2008: Von: Michael Guerrero [EMAIL PROTECTED] Betreff: Re: [osg-users] osgPPU osgShadow An: osg-users@lists.openscenegraph.org Datum: Dienstag, 7. Oktober 2008, 21:16 Hi Art, thanks for your attention. I've constructed an example for you by minimally modifying Example viewer. Below is the modified view.cpp. It has an additional createScene function that sets up a shadowed scene. Also note the #define ENABLE_SHADOWS. Commenting that out will use the default scene instead of the shadowed one for comparison. Michael PS You'll have to link to osgShadow as well of course #include osg/GLExtensions #include osgViewer/Renderer #include osgGA/TrackballManipulator #include osgDB/WriteFile #include osgPPU/Processor.h #include osgteapot.h #define ENABLE_SHADOWS #if defined (ENABLE_SHADOWS) # include osgShadow/ShadowedScene # include osgShadow/ShadowMap # include osg/LightSource #endif //-- // Create camera resulting texture //-- osg::Texture* createRenderTexture(int tex_width, int tex_height, bool depth) { // create simple 2D texture osg::Texture2D* texture2D = new osg::Texture2D; texture2D-setTextureSize(tex_width, tex_height); texture2D-setResizeNonPowerOfTwoHint(false); texture2D-setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR); texture2D-setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR); texture2D-setWrap(osg::Texture2D::WRAP_S,osg::Texture2D::CLAMP_TO_BORDER); texture2D-setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::CLAMP_TO_BORDER); texture2D-setBorderColor(osg::Vec4(1.0f,1.0f,1.0f,1.0f)); // setup float format if (!depth) { texture2D-setInternalFormat(GL_RGBA16F_ARB); texture2D-setSourceFormat(GL_RGBA); texture2D-setSourceType(GL_FLOAT); }else{ texture2D-setInternalFormat(GL_DEPTH_COMPONENT); } return texture2D; } //-- // Create scene //-- osg::Group* createScene(const std::string filename) { osg::Node* loadedModel = NULL; // Load in the model to use in our scene if (!filename.empty()) loadedModel = osgDB::readNodeFile(filename); if (!loadedModel) loadedModel = createTeapot(); if (!loadedModel) return NULL; #if defined (ENABLE_SHADOWS) const int ReceivesShadowTraversalMask = 0x1; const int CastsShadowTraversalMask = 0x2; osgShadow::ShadowedScene* shadowedScene = new osgShadow::ShadowedScene; shadowedScene-setReceivesShadowTraversalMask(ReceivesShadowTraversalMask); shadowedScene-setCastsShadowTraversalMask(CastsShadowTraversalMask); osg::LightSource* lightSource = new osg::LightSource; lightSource-getLight()-setPosition( osg::Vec4(osg::Vec3(100.0, 0.0, 100.0f), 0.0f)); // Setup the scene with shadows via shadow mapping osgShadow::ShadowMap* shadowMap = new osgShadow::ShadowMap; shadowMap-setTextureSize(osg::Vec2s(1024, 1024)); shadowMap-setLight(lightSource); shadowedScene-setShadowTechnique(shadowMap); shadowedScene-addChild(lightSource); return shadowedScene; #else osg::Group* scene = new osg::Group; scene-addChild(loadedModel); return scene; #endif } //-- // Setup the camera to do the render to texture //-- void setupCamera(osg::Camera* camera) { osg::Viewport* vp = camera-getViewport(); // create texture to render to osg::Texture* texture = createRenderTexture((int)vp-width(), (int)vp-height(), false); osg::Texture* depthTexture = createRenderTexture((int)vp-width(), (int)vp-height(), true); // set up the background color and clear mask. camera-setClearColor(osg::Vec4(0.0f,0.0f,0.0f,0.0f)); camera-setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // set viewport camera-setViewport(vp); camera-setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); camera-setProjectionMatrixAsPerspective(35.0, vp-width()/vp-height(), 1.0, 256.0); // tell the camera to use OpenGL frame buffer object where supported. camera-setRenderTargetImplementation(osg::Camera
Re: [osg-users] osgPPU osgShadow
Awesome, thanks for the correction. I see that my initial example forgot to actually add the model to the shadowed scene :P But that wasn't the real problem. The real problem was giving osgPPU the same node that i was using for shadows. After seeing what you did in your correction I rearranged the graph like this: scene-addChild(shadowedScene); shadowedScene-addChild(loadedModel); and everything worked as expected. Now I just want to understand why this worked. It it because osgPPU and osgShadow are no longer fighting to control the state of the single scene node? ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgPPU osgShadow
Hi, Awesome, thanks for the correction. I see that my initial example forgot to actually add the model to the shadowed scene :P But that wasn't the real problem. The real problem was giving osgPPU the same node that i was using for shadows. I do not realy understand what you mean here with giving osgPPU the same node as for shadows. osgPPU doesn't now anything about the graph, it does only get camera as input, hence use the camera color buffer texture as input. Therefor the camera, which is connected to the osgPPU, which can be your main camera or some other one, should be able to render your shadowed scene. Cheers, art After seeing what you did in your correction I rearranged the graph like this: scene-addChild(shadowedScene); shadowedScene-addChild(loadedModel); and everything worked as expected. Now I just want to understand why this worked. It it because osgPPU and osgShadow are no longer fighting to control the state of the single scene node? ___ 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] osgPPU osgShadow
Hi Michael, I have never tried osgShadow at all, hence I can not say what happens if you use osgPPU with it. Could you prepare some simple example showing the issue? Maybe try the newest version from the svn, since there are some changes to the previous one. Best regards, art Hi guys, I've recently delved into osgPPU and am loving it. I have a scene beautifully rendering with HDR. However, when I tried adding osgShadow ShadowMap to the scene I had conflicts. I don't yet know exactly what is going just yet but I was wondering if anyone has had success combining these two and if so, I would appreciate the help. Thanks, Michael ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org __ Gesendet von Yahoo! Mail. Dem pfiffigeren Posteingang. http://de.overview.mail.yahoo.com ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgPPU osgShadow
I just get a black screen. Maybe the initial screen render is not passed to the PPU's correctly. Michael ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgPPU osgShadow
Hmm, this could be an issue, yes. Could you try to setup the OSG_NOTIFY_LEVEL=info to see the logs. Maybe there are just some misconfiguration of the osgPPU pipeline. Have you connected the processor to the right camera? Do the camera render the scene into a RTT texture? Could you try to setup just a simple bypass/byrender pipeline similar to this: processor-setCamera(...); UnitOut* out = new ... processor-addChild(out); Which will just render the rtt texture (attached as color_buffer) of the camera to the frame buffer (to the screen). Cheers, art On Thursday 02 October 2008 20:08:28 Michael Guerrero wrote: I just get a black screen. Maybe the initial screen render is not passed to the PPU's correctly. Michael ___ 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