Re: [osg-users] Opaque black shadows since moving to OSG V3.0.1
Hi all, I actually posted about a similar issue 3 days ago, and included screenshots and a cpp file, but my post never made it on to the list. It may have been filtered due to attachments on first post. Anyway, I think there is a general regression in osgShadow from 2.8.3 to 3.0.1. The problem that I was seeing was with SoftShadowMap where the shaded areas are transparent. It is easily reproducible in the osgShadow example by making the SoftShadow technique default, and adding GL_BLEND to the default model 3 stateset. If GL_BLEND is enabled, shadows make the receiver object transparent in the areas where the shadows are projected. I tracked this down to a change in the shader code where shadows values were changed from a vec4 to a float. Using the original shader from 2.8.3 works fine, but the current one is broken. Cheers, Morné On Fri, Dec 2, 2011 at 6:53 PM, Wojciech Lewandowski w.p.lewandow...@gmail.com wrote: Hi, Guys, I think I see the reason why Robert commented it. For spotlights ambient factor should be attenuated with distance from light. It would be hard to compute attenuation in frag shader without assistance of vertex shader. I would bet it would be possible but very tricky, though. Anyway, IMHO when that line is commented its worse because such ambient factor is both wrong for directional and spot lights. That issue again proves that there is no silver bullet for shadow technique shaders. Depending on what your app does you may need different set of shaders, if not whole technique. So maybe you guys should consider passing in your own shaders (copied from 2.8 version) to make that look right again... Cheers, Wojtek Lewandowski 2011/12/1 Wojciech Lewandowski w.p.lewandow...@gmail.com Hi, Michael, Well, then I guess addition of gl_FrontLightProduct[0] should be uncomented. And thats a missing piece of the puzzle... SVN Blame shows that Robert commented it in 12737 rev on 29th of July. I guess its time to ask Robert what to do with this. Cheers, WL 2011/12/1 Michael Guerrero mjgue...@nps.edu Hi Wojtek, It certainly did seem as though I completely missed the addition with gl_FrontLightProduct[0].ambient. Unfortunately what happened was that after I copy/pasted it in the message I removed the quotes around it and more importantly the comment characters //. Here is a link to the file in question: http://www.openscenegraph.org/projects/osg/browser/OpenSceneGraph/tags/OpenSceneGraph-3.0.1/src/osgShadow/StandardShadowMap.cpp FYI, that piece of code looks the same on the trunk: http://www.openscenegraph.org/projects/osg/browser/OpenSceneGraph/trunk/src/osgShadow/StandardShadowMap.cpp -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44170#44170 ___ 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] Opaque black shadows since moving to OSG V3.0.1
Hi, Guys, I think I see the reason why Robert commented it. For spotlights ambient factor should be attenuated with distance from light. It would be hard to compute attenuation in frag shader without assistance of vertex shader. I would bet it would be possible but very tricky, though. Anyway, IMHO when that line is commented its worse because such ambient factor is both wrong for directional and spot lights. That issue again proves that there is no silver bullet for shadow technique shaders. Depending on what your app does you may need different set of shaders, if not whole technique. So maybe you guys should consider passing in your own shaders (copied from 2.8 version) to make that look right again... Cheers, Wojtek Lewandowski 2011/12/1 Wojciech Lewandowski w.p.lewandow...@gmail.com Hi, Michael, Well, then I guess addition of gl_FrontLightProduct[0] should be uncomented. And thats a missing piece of the puzzle... SVN Blame shows that Robert commented it in 12737 rev on 29th of July. I guess its time to ask Robert what to do with this. Cheers, WL 2011/12/1 Michael Guerrero mjgue...@nps.edu Hi Wojtek, It certainly did seem as though I completely missed the addition with gl_FrontLightProduct[0].ambient. Unfortunately what happened was that after I copy/pasted it in the message I removed the quotes around it and more importantly the comment characters //. Here is a link to the file in question: http://www.openscenegraph.org/projects/osg/browser/OpenSceneGraph/tags/OpenSceneGraph-3.0.1/src/osgShadow/StandardShadowMap.cpp FYI, that piece of code looks the same on the trunk: http://www.openscenegraph.org/projects/osg/browser/OpenSceneGraph/trunk/src/osgShadow/StandardShadowMap.cpp -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44170#44170 ___ 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] Opaque black shadows since moving to OSG V3.0.1
Hi Wojtek, It certainly did seem as though I completely missed the addition with gl_FrontLightProduct[0].ambient. Unfortunately what happened was that after I copy/pasted it in the message I removed the quotes around it and more importantly the comment characters //. Here is a link to the file in question: http://www.openscenegraph.org/projects/osg/browser/OpenSceneGraph/tags/OpenSceneGraph-3.0.1/src/osgShadow/StandardShadowMap.cpp FYI, that piece of code looks the same on the trunk: http://www.openscenegraph.org/projects/osg/browser/OpenSceneGraph/trunk/src/osgShadow/StandardShadowMap.cpp -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44170#44170 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Opaque black shadows since moving to OSG V3.0.1
Hi, Michael, Well, then I guess addition of gl_FrontLightProduct[0] should be uncomented. And thats a missing piece of the puzzle... SVN Blame shows that Robert commented it in 12737 rev on 29th of July. I guess its time to ask Robert what to do with this. Cheers, WL 2011/12/1 Michael Guerrero mjgue...@nps.edu Hi Wojtek, It certainly did seem as though I completely missed the addition with gl_FrontLightProduct[0].ambient. Unfortunately what happened was that after I copy/pasted it in the message I removed the quotes around it and more importantly the comment characters //. Here is a link to the file in question: http://www.openscenegraph.org/projects/osg/browser/OpenSceneGraph/tags/OpenSceneGraph-3.0.1/src/osgShadow/StandardShadowMap.cpp FYI, that piece of code looks the same on the trunk: http://www.openscenegraph.org/projects/osg/browser/OpenSceneGraph/trunk/src/osgShadow/StandardShadowMap.cpp -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44170#44170 ___ 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] Opaque black shadows since moving to OSG V3.0.1
Hello everybody, I'm updating some of my projects from V2.8.3 to V3.0.1 of OSG and i'm struggling with a shadow problem. In fact, osgShadow::LightSpacePerspectiveShadowMapCB produces opaque black shadows, while in previous version it darkened the objects. I've tried to change ambiant in light and objects materials with no success. What i'm looking for is something like AmbiantBias, to control the shadow intensity. Do you know any way to achieve this please? With this shadow technique, if possible. I'm running Windows 7 on an ATI Radeon HD 6850 Thanks! Cyril -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44136#44136 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Opaque black shadows since moving to OSG V3.0.1
Hi Cyril, None of the View Dependent Techniques was using Ambient Bias before. So thats not the case here I suppose. I am not sure if thats it but look at the shaders located in StandardShadowMap.cpp. I believe that Robert has switched the shadow shaders to use only fragment shaders somewhere between 2.9 and 3.0. That might have affected the ambient/emissive handling... Formerly ambientEmissive value was computed in shadow vertex shaders and passed to fragment shader. Now fragment shaders simply read material and light ambient colors and use them insted of former ambienEmiissive varying. Cheers, Wojtek Lewandowski 2011/11/30 Cyril Bondue c.bon...@cbbknet.com Hello everybody, I'm updating some of my projects from V2.8.3 to V3.0.1 of OSG and i'm struggling with a shadow problem. In fact, osgShadow::LightSpacePerspectiveShadowMapCB produces opaque black shadows, while in previous version it darkened the objects. I've tried to change ambiant in light and objects materials with no success. What i'm looking for is something like AmbiantBias, to control the shadow intensity. Do you know any way to achieve this please? With this shadow technique, if possible. I'm running Windows 7 on an ATI Radeon HD 6850 Thanks! Cyril -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44136#44136 ___ 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] Opaque black shadows since moving to OSG V3.0.1
I am also experiencing the same thing upgrading from 2.8.5 to 3.0.1. For a while I thought it was completely opaque until I looked closely at my lcd monitor where I found it to be just really really dark instead. Here is the relevant frag shader code from 3.0.1: Code: void main(void) { vec4 colorAmbientEmissive = gl_FrontLightModelProduct.sceneColor; // Add ambient from Light of index = 0 colorAmbientEmissive += gl_FrontLightProduct[0].ambient; vec4 color = texture2D( baseTexture, gl_TexCoord[0].xy ); color *= mix( colorAmbientEmissive, gl_Color, DynamicShadow() ); According to the opengl Orange book (shading language), gl_FrontLightModelProduct.sceneColor = gl_FrontMaterial.emission + gl_FrontMaterial.ambient * gl_LightModel.ambient. Using GDebugger I was able to inspect these values as my shadowed geometry was drawn and saw: gl_FrontMaterial.emission = {0,0,0,1} gl_FrontMaterial.ambient = {0.588,0.588,0.588,1} gl_LightModel.ambient = {0.1,0.1,0.1,1} Given these values, gl_FrontLightModelProduct.sceneColor = colorAmbientEmissive = {0.0588,0.0588,0.588,1} which explains the extreme darkness of the shadows. In OSG 2.8.5 colorAmbientEmissive was calculated like this: Code: colorAmbientEmissive = gl_FrontLightModelProduct.sceneColor + amb * gl_FrontMaterial.ambient; For me this version results in much brighert/less dark shadows. I see 2 choices to restore the previous look: 1) Use custom shaders in order to use our own colorAmbientEmissive calculation or 2) Make sure the LightModel's ambient is much higher than 0.1. If there's something easier that I'm missing, please let me know, Thanks, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44149#44149 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Opaque black shadows since moving to OSG V3.0.1
Hi Michael, Haven't you just skipped addition of gl_FrontLightProduct[0].ambient which should contain contribution of light 0 ambient * material ambient ? So final colorAmbientEmissive is gl_FrontLightModelProduct.sceneColor + gl_FrontLightProduct[0].ambient. This should produce similar colorAmbientEmissive term as old vertex shader version unless something else do not come into play. Perhaps you draw using BackFace materials ?. I also wonder if use of ColorMaterial mode may somehow result it different colorAmbientEmissive now Cheers, Wojtek 2011/11/30 Michael Guerrero mjgue...@nps.edu I am also experiencing the same thing upgrading from 2.8.5 to 3.0.1. For a while I thought it was completely opaque until I looked closely at my lcd monitor where I found it to be just really really dark instead. Here is the relevant frag shader code from 3.0.1: Code: void main(void) { vec4 colorAmbientEmissive = gl_FrontLightModelProduct.sceneColor; // Add ambient from Light of index = 0 colorAmbientEmissive += gl_FrontLightProduct[0].ambient; vec4 color = texture2D( baseTexture, gl_TexCoord[0].xy ); color *= mix( colorAmbientEmissive, gl_Color, DynamicShadow() ); According to the opengl Orange book (shading language), gl_FrontLightModelProduct.sceneColor = gl_FrontMaterial.emission + gl_FrontMaterial.ambient * gl_LightModel.ambient. Using GDebugger I was able to inspect these values as my shadowed geometry was drawn and saw: gl_FrontMaterial.emission = {0,0,0,1} gl_FrontMaterial.ambient = {0.588,0.588,0.588,1} gl_LightModel.ambient = {0.1,0.1,0.1,1} Given these values, gl_FrontLightModelProduct.sceneColor = colorAmbientEmissive = {0.0588,0.0588,0.588,1} which explains the extreme darkness of the shadows. In OSG 2.8.5 colorAmbientEmissive was calculated like this: Code: colorAmbientEmissive = gl_FrontLightModelProduct.sceneColor + amb * gl_FrontMaterial.ambient; For me this version results in much brighert/less dark shadows. I see 2 choices to restore the previous look: 1) Use custom shaders in order to use our own colorAmbientEmissive calculation or 2) Make sure the LightModel's ambient is much higher than 0.1. If there's something easier that I'm missing, please let me know, Thanks, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44149#44149 ___ 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