Re: [osg-users] Shadows on "invisible" objects
Hi Allessandro, my case is a bit different, it is about invisible object to cast shadows on visible objects. The second link with the shader hints gave me an idea though... Thank you so much for the links !! Nick On Thu, Mar 30, 2017 at 10:05 AM, Alessandro Terenziwrote: > Hi Nick, > as far as I understand you'd like to cast shadows onto a geometry that is > kind of invisible but still can receive shadows, is this right? > > Have you already read these? > > http://forum.openscenegraph.org/viewtopic.php?t=8912; > highlight=invisible+shadow > > http://forum.openscenegraph.org/viewtopic.php?t=12628; > highlight=invisible+shadow > > Hope these will help. > Alessandro > > On Tue, Mar 28, 2017 at 9:06 AM, Trajce Nikolov NICK < > trajce.nikolov.n...@gmail.com> wrote: > >> Hi Community, >> >> I am trying to solve a problem where my scene is with shadow caster model >> where I want to see only the shadows and have the shadow caster model >> invisible. What would be the node masks game to achieve this? or some other >> solution? >> >> Thanks a bunch as always >> >> Nick >> >> -- >> trajce nikolov nick >> >> ___ >> 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 > > -- 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] Shadows on "invisible" objects
Hi Nick, as far as I understand you'd like to cast shadows onto a geometry that is kind of invisible but still can receive shadows, is this right? Have you already read these? http://forum.openscenegraph.org/viewtopic.php?t=8912=invisible+shadow http://forum.openscenegraph.org/viewtopic.php?t=12628=invisible+shadow Hope these will help. Alessandro On Tue, Mar 28, 2017 at 9:06 AM, Trajce Nikolov NICK < trajce.nikolov.n...@gmail.com> wrote: > Hi Community, > > I am trying to solve a problem where my scene is with shadow caster model > where I want to see only the shadows and have the shadow caster model > invisible. What would be the node masks game to achieve this? or some other > solution? > > Thanks a bunch as always > > Nick > > -- > trajce nikolov nick > > ___ > 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] Shadows on invisible objects
Thank you both for your replies. I figured out how to do it with the help of Terry's post. I'm putting my answer here in case anyone else comes across the same problem. I sub-classed osg.ShadowMap, and set a new custom fragment shader code. I created a flag (which I call 'ghostObject') to mark those nodes for which the effect will be applied. I set the flag on each node using: node.getOrCreateStateSet().addUniform(osg.Uniform('ghostObject', True)) If the flag is set, the shader will set the alpha of every pixel to 0, except those pixels that lie inside a shadowed area. If the flag is not set, the shader will just darken shadowed areas. Code: shaderSource = uniform sampler2D osgShadow_baseTexture; \m uniform sampler2DShadow osgShadow_shadowTexture; \n uniform vec2 osgShadow_ambientBias; \n uniform bool ghostObject;\n void main(void) \n {\n vec4 shadowProj = shadow2DProj( osgShadow_shadowTexture, gl_TexCoord[1] );\n gl_FragColor = gl_Color * texture2D( osgShadow_baseTexture, gl_TexCoord[0].xy );\n if(ghostObject shadowProj.x 0.5 )\n gl_FragColor.w = 0.0;\n else if( shadowProj.x 0.5 ){\n gl_FragColor.x = gl_FragColor.x * 0.5;\n gl_FragColor.y = gl_FragColor.y * 0.5;\n gl_FragColor.z = gl_FragColor.z * 0.5;\n }\n }\n Thank you! Cheers, Juan Code: -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=57876#57876 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Shadows on invisible objects
Hi Juan, It's hard to know exactly what you mean by invisible objects, or how they might recieve a shadow. Could you take a step back and explain at a high level what you are trying to achieve. Robert. On 18 May 2013 13:03, Juan Cruz j_...@hotmail.com wrote: Hi, I'm creating a visualization where it is critical for some invisible objects to be able to receive shadows on them. I know this sounds physically impossible, but I hope it is possible on a virtual environment. Is there any way of achieving this in OSG? Perhaps using shaders? Thank you! Cheers, Juan -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=54053#54053 ___ 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] Shadows on invisible objects
This sounds reasonable. If all your objects (including the invisible ones) have the appropriate NodeMask bit set, then they can all be rendered into your shadow map. Then when you render the final scene, you would need a specialized shader for rendering the invisible objects. This shader would only render pixels that are in shadow; you could render just a transparent gray for the shadowed pixels that you keep. -- Terry Welsh www.reallyslick.com Hi, I'm creating a visualization where it is critical for some invisible objects to be able to receive shadows on them. I know this sounds physically impossible, but I hope it is possible on a virtual environment. Is there any way of achieving this in OSG? Perhaps using shaders? Thank you! Cheers, Juan ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Shadows on invisible objects
On 8/5/2011 11:03 AM, Alessandro Terenzi wrote: Hi, I want to make an object invisible but, nonetheless, I also want it to receive shadows, any suggestion? By the way, I'm using the ShadowMap technique to implement shadows. Thanks. Alessandro When I use depth map shadows, I use a fragment shader to sample the depth texture. If I wanted to see only the shadow areas but not the lit areas, I'd just add the appropriate conditional call to discard. Hope that helps, -- -Paul Martz Skew Matrix Software http://www.skew-matrix.com/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Shadows on invisible objects
On 8/5/2011 11:03 AM, Alessandro Terenzi wrote: Hi, I want to make an object invisible but, nonetheless, I also want it to receive shadows, any suggestion? Receive? That makes no sense. Its appearance can't be altered by a shadow if it has no appearance. -- Chris 'Xenon' Hanson, omo sanza lettere. xe...@alphapixel.com http://www.alphapixel.com/ Digital Imaging. OpenGL. Scene Graphs. GIS. GPS. Training. Consulting. Contracting. There is no Truth. There is only Perception. To Perceive is to Exist. - Xen ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Shadows on invisible objects
Paul Martz wrote: When I use depth map shadows, I use a fragment shader to sample the depth texture. If I wanted to see only the shadow areas but not the lit areas, I'd just add the appropriate conditional call to discard. Thanks Paul, your suggestion is very helpful, anyway I wonder if there exists also a way to achieve the same result without relying on shaders...for example, in the past I used the ColorMask to create an 'invisible' object that was able to hide other objects (its shape and volume was reveiled if other objects moved behind it, even though it was not visible in the scene). You can also pick such kind of invisible objects, so, maybe, something similar can be done also with shadows. Basically I'm looking for a way to reveil the shape/volume of an invisible object by means of shadows casted onto it, I know that this may make no sense from a physical point of view, but we're in the CG world where only imagination is the limit, aren't we? Cheers. Alessandro -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=41897#41897 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org