Re: [osg-users] Creating working shadow with one omnidirectional light

2014-05-09 Thread Trajce Nikolov NICK
Here you go, directly from the author :-)

Nick


On Fri, May 9, 2014 at 5:46 PM, Wojciech Lewandowski <
w.p.lewandow...@gmail.com> wrote:

> Mickael,
>
> As far as I know none of existing techniques in OSG does what you want.
> You will need to roll up your sleeves and work hard to obtain the effect
> you wish.
>
> I was once contracted to do multiple shadow lights with full spherical
> coverage of light field. Its proprietary code and I cannot share it. It was
> done with slightly different concept than cubemap. Space around point light
> was cut into NxM spherical segments and each of those segments was
> represented as single shadow map. Shadowmaps were stored as Texture2DArray.
> Casting shadows required smart blending of those shadowmaps in shaders. I
> did not try to use LispSM or other perspective shadow map for that. It did
> not make sense to me if I wanted uniform distribution of light and it would
> be particularly difficult to merge those shadow maps in casting shader if
> they used varying projections. So I used code which was based on
> MinimalShadowMap techinques but as a start you may also come from basic
> ShadowMap. Its most simple technique and most appropriate for
> customizations.
>
> But the whole excercise is terribly complex. You would need to use 6
> cameras to cull and render six shadow maps for your cubemap and then apply
> that cubemap with specifically written shader. Its highly advanced stuff.
> Please look at the most simple ShadowMap technique code and see if you
> understand all of the code there. If you do you can try to go further and
> experiment with shadow cubemap, if you don't undrstand some of it you will
> need to learn more...
>
> Best of Luck and obligatory Cheers,
> Wojtek
>
>
>
>
>
> 2014-05-09 16:17 GMT+02:00 Mickael Fleurus :
>
> I checked the source of the SilverLining SDK, and I don't think it will be
>> useful for what I search to achieve. After more research, I think that what
>> make that no solution is good for what I'm looking to achieve is that every
>> solutions use a single camera with a limited field of view to create
>> shadows. Places where my shadows disapear are places that are outside
>> camera's FOV. That's why I've tried to do my own shadow map in the first
>> place, with a cube map. Because this problem can disapear with the use of a
>> cube map. But, deep down, I'm sure that people making OSG thought of that
>> problem and that I'm loosing time for nothing.
>>
>> Thank you for the time you use trying to help me, anyway.
>>
>> Cheers,
>> Mickael
>>
>> --
>> Read this topic online here:
>> http://forum.openscenegraph.org/viewtopic.php?p=59335#59335
>>
>>
>>
>>
>>
>> ___
>> 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] Creating working shadow with one omnidirectional light

2014-05-09 Thread Wojciech Lewandowski
Mickael,

As far as I know none of existing techniques in OSG does what you want. You
will need to roll up your sleeves and work hard to obtain the effect you
wish.

I was once contracted to do multiple shadow lights with full spherical
coverage of light field. Its proprietary code and I cannot share it. It was
done with slightly different concept than cubemap. Space around point light
was cut into NxM spherical segments and each of those segments was
represented as single shadow map. Shadowmaps were stored as Texture2DArray.
Casting shadows required smart blending of those shadowmaps in shaders. I
did not try to use LispSM or other perspective shadow map for that. It did
not make sense to me if I wanted uniform distribution of light and it would
be particularly difficult to merge those shadow maps in casting shader if
they used varying projections. So I used code which was based on
MinimalShadowMap techinques but as a start you may also come from basic
ShadowMap. Its most simple technique and most appropriate for
customizations.

But the whole excercise is terribly complex. You would need to use 6
cameras to cull and render six shadow maps for your cubemap and then apply
that cubemap with specifically written shader. Its highly advanced stuff.
Please look at the most simple ShadowMap technique code and see if you
understand all of the code there. If you do you can try to go further and
experiment with shadow cubemap, if you don't undrstand some of it you will
need to learn more...

Best of Luck and obligatory Cheers,
Wojtek





2014-05-09 16:17 GMT+02:00 Mickael Fleurus :

> I checked the source of the SilverLining SDK, and I don't think it will be
> useful for what I search to achieve. After more research, I think that what
> make that no solution is good for what I'm looking to achieve is that every
> solutions use a single camera with a limited field of view to create
> shadows. Places where my shadows disapear are places that are outside
> camera's FOV. That's why I've tried to do my own shadow map in the first
> place, with a cube map. Because this problem can disapear with the use of a
> cube map. But, deep down, I'm sure that people making OSG thought of that
> problem and that I'm loosing time for nothing.
>
> Thank you for the time you use trying to help me, anyway.
>
> Cheers,
> Mickael
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=59335#59335
>
>
>
>
>
> ___
> 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] Creating working shadow with one omnidirectional light

2014-05-09 Thread Trajce Nikolov NICK
One more thing. There is setMaxFarPlane() method in
the osgShadow::LightSpacePerspectiveShadowMapDB.

Nick


On Fri, May 9, 2014 at 4:17 PM, Mickael Fleurus wrote:

> I checked the source of the SilverLining SDK, and I don't think it will be
> useful for what I search to achieve. After more research, I think that what
> make that no solution is good for what I'm looking to achieve is that every
> solutions use a single camera with a limited field of view to create
> shadows. Places where my shadows disapear are places that are outside
> camera's FOV. That's why I've tried to do my own shadow map in the first
> place, with a cube map. Because this problem can disapear with the use of a
> cube map. But, deep down, I'm sure that people making OSG thought of that
> problem and that I'm loosing time for nothing.
>
> Thank you for the time you use trying to help me, anyway.
>
> Cheers,
> Mickael
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=59335#59335
>
>
>
>
>
> ___
> 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] Android osgPlugins

2014-05-09 Thread Nathan Collins
Hi all,

I've got to this point again. I have built OSG and got the examples to run, but 
not load files. I'm getting the same issue from my original post:


Code:

05-09 14:33:04.726: E/Osg Viewer(4848): There are 1 models to load
05-09 14:33:04.726: E/Osg Viewer(4848): Loading: 
/storage/emulated/0/osg/cow.osgt
05-09 14:33:04.731: D/Osg Viewer(4848): itr='/vendor/lib'
05-09 14:33:04.731: D/Osg Viewer(4848): FindFileInPath() : trying 
/vendor/lib/osgPlugins-3.3.1/osgdb_osg.so ...
05-09 14:33:04.731: D/Osg Viewer(4848): itr='/system/lib'
05-09 14:33:04.731: D/Osg Viewer(4848): FindFileInPath() : trying 
/system/lib/osgPlugins-3.3.1/osgdb_osg.so ...
05-09 14:33:04.731: D/Osg Viewer(4848): itr='/usr/lib/'
05-09 14:33:04.731: D/Osg Viewer(4848): FindFileInPath() : trying 
/usr/lib/osgPlugins-3.3.1/osgdb_osg.so ...
05-09 14:33:04.731: D/Osg Viewer(4848): itr='/usr/local/lib/'
05-09 14:33:04.731: D/Osg Viewer(4848): FindFileInPath() : trying 
/usr/local/lib/osgPlugins-3.3.1/osgdb_osg.so ...
05-09 14:33:04.731: D/Osg Viewer(4848): itr='/vendor/lib'
05-09 14:33:04.731: D/Osg Viewer(4848): FindFileInPath() : trying 
/vendor/lib/osgdb_osg.so ...
05-09 14:33:04.731: D/Osg Viewer(4848): itr='/system/lib'
05-09 14:33:04.731: D/Osg Viewer(4848): FindFileInPath() : trying 
/system/lib/osgdb_osg.so ...
05-09 14:33:04.731: D/Osg Viewer(4848): itr='/usr/lib/'
05-09 14:33:04.731: D/Osg Viewer(4848): FindFileInPath() : trying 
/usr/lib/osgdb_osg.so ...
05-09 14:33:04.731: D/Osg Viewer(4848): itr='/usr/local/lib/'
05-09 14:33:04.731: D/Osg Viewer(4848): FindFileInPath() : trying 
/usr/local/lib/osgdb_osg.so ...
05-09 14:33:04.731: I/Osg Viewer(4848): Warning: dynamic library 
'osgPlugins-3.3.1/osgdb_osg.so' does not exist (or isn't readable):
05-09 14:33:04.731: I/Osg Viewer(4848): dlopen failed: library 
"osgPlugins-3.3.1/osgdb_osg.so" not found
05-09 14:33:04.731: I/Osg Viewer(4848): DynamicLibrary::failed loading 
"osgPlugins-3.3.1/osgdb_osg.so"
05-09 14:33:04.731: E/Osg Viewer(4848): Model not loaded




I have built OSG with the relevant flags to make it static, however I've built 
it against gnustl_shared. Does anyone know if this is what is causing OSG to 
look for shared versions of osgbd_osg.so rather than a static osgdb_osg.a?

I also noticed that it is not looking for libosgdb_osg.a. It was my 
understanding that the NDK toolchain prepends lib to all library names if it is 
not there.

Thanks,
Nathan.[/b]

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=59336#59336





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Creating working shadow with one omnidirectional light

2014-05-09 Thread Mickael Fleurus
I checked the source of the SilverLining SDK, and I don't think it will be 
useful for what I search to achieve. After more research, I think that what 
make that no solution is good for what I'm looking to achieve is that every 
solutions use a single camera with a limited field of view to create shadows. 
Places where my shadows disapear are places that are outside camera's FOV. 
That's why I've tried to do my own shadow map in the first place, with a cube 
map. Because this problem can disapear with the use of a cube map. But, deep 
down, I'm sure that people making OSG thought of that problem and that I'm 
loosing time for nothing.

Thank you for the time you use trying to help me, anyway.

Cheers,
Mickael

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=59335#59335





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Creating working shadow with one omnidirectional light

2014-05-09 Thread Trajce Nikolov NICK
Hi,

you have option to replace the shaders in the ShadowMap for this. Then you
can tune the effect as You wish., but this is a bit complex. Also, with my
setting with the direction light it should work with the light position -
it is what I use in my app and works great with the ephemeris model from
sundog software (SilverLining). I got inspired by the samples in the
SilverLining bundle. Go to sundog-soft.com and download the SilverLining
demo, there is a good sample osgshadow that has these shaders implemented
and are working well for all the light types, point light included

NIck


On Fri, May 9, 2014 at 11:28 AM, Mickael Fleurus
wrote:

> [quote="Trajce Nikolov NICK"]Hi,
>
> if your shadows are moving with the camera, then you are using the default
> viewer lighting mode which moves the light with the camera. Try setting the
> viewer with no light ( viewer->setLightingMode(osg::View::NO_LIGHT); ) and
> set your own LightSource in the scene that you can position yourself. Here
> is snippet from my app that might help:
>
>
> _viewer->getView(0)->setSceneData(_scene);
>
>
> _sun = new osg::LightSource;
> _sun->getLight()->setLightNum(0);
> _sun->setName("SUN");
> _sun->setCullingActive(false);
> _scene->addChild(_sun.get());
>
>
>
> then you position _sun->getLight() with zero (0) for the last argument in
> _sun->getLight()->setPosition(osg::Vec3(x,y,z),0)
>
>
> Nick
> [/quote]
>
> Thank for your answer, but, the thing is, I need my light to be a point
> light. It cannot be a directionnal light or a spotlight. Indeed, it work
> with a directionnal light. But not like I need it to work. But thank you to
> have took the time to respond me.
>
> I need a light that cast light in all direction, and shadow that
> correspond to the position of the light.
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=59333#59333
>
>
>
>
>
> ___
> 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] Creating working shadow with one omnidirectional light

2014-05-09 Thread Mickael Fleurus
[quote="Trajce Nikolov NICK"]Hi,

if your shadows are moving with the camera, then you are using the default 
viewer lighting mode which moves the light with the camera. Try setting the 
viewer with no light ( viewer->setLightingMode(osg::View::NO_LIGHT); ) and set 
your own LightSource in the scene that you can position yourself. Here is 
snippet from my app that might help:


_viewer->getView(0)->setSceneData(_scene);


_sun = new osg::LightSource;
_sun->getLight()->setLightNum(0);
_sun->setName("SUN");
_sun->setCullingActive(false);
_scene->addChild(_sun.get());



then you position _sun->getLight() with zero (0) for the last argument in 
_sun->getLight()->setPosition(osg::Vec3(x,y,z),0)


Nick
[/quote]

Thank for your answer, but, the thing is, I need my light to be a point light. 
It cannot be a directionnal light or a spotlight. Indeed, it work with a 
directionnal light. But not like I need it to work. But thank you to have took 
the time to respond me.

I need a light that cast light in all direction, and shadow that correspond to 
the position of the light.

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=59333#59333





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Creating working omnidirectional shadow

2014-05-09 Thread Trajce Nikolov NICK
Hi,

if your shadows are moving with the camera, then you are using the default
viewer lighting mode which moves the light with the camera. Try setting the
viewer with no light ( viewer->setLightingMode(osg::View::NO_LIGHT); ) and
set your own LightSource in the scene that you can position yourself. Here
is snippet from my app that might help:

_viewer->getView(0)->setSceneData(_scene);

_sun = new osg::LightSource;
_sun->getLight()->setLightNum(0);
_sun->setName("SUN");
_sun->setCullingActive(false);
_scene->addChild(_sun.get());

then you position _sun->getLight() with zero (0) for the last argument in
_sun->getLight()->setPosition(osg::Vec3(x,y,z),0)

Nick


On Fri, May 9, 2014 at 10:03 AM, Mickael Fleurus
wrote:

> Hi,
>  yeah sorry I messed up with what I meant to say. It's more shadow with
> omnidirectionnal light, or point light as I think it's named in osg.
>
> ViewDependentShadowMap is producing a weird result. Depending on how
> distant my camera is from the scene, I have strange artefacts that make the
> scene unwatchable( img VDSM1). And if the light is too distant, shadows are
> cut of a part of the scene.(img VDSM2)
>
> LightSpacePerspectiveShadowMapDB is also producing weird results.
> Depending on where my camera is, shadows are produced (img LSPSM1) or not
> (img LSPSM2). And sometimes, there is shadows only on a small part of the
> scene. (img LSPSM3)
>
> Are these problems that have been seen frequently, or is this caused by
> the rest of my code?
>
> ...
>
> Thank you!
>
> Cheers,
> Mickael
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=59329#59329
>
>
>
>
> Attachments:
> http://forum.openscenegraph.org//files/vdsm2_976.png
> http://forum.openscenegraph.org//files/vdsm1_300.png
> http://forum.openscenegraph.org//files/lspsm2_126.png
> http://forum.openscenegraph.org//files/lspsm1_521.png
> http://forum.openscenegraph.org//files/lspsm3_551.png
>
>
> ___
> 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] Differences between applying setStateSet in a Node and a Drawable?

2014-05-09 Thread Jaime
Thanks Robert for your response.

So, I don't know why it isn't working.

This is the way that I configure the shader:


> stateset->setTextureAttribute(0,  m_vGeoms[iContDrawable]->m_tDiffuse);
>   stateset->setTextureAttribute(1,  m_vGeoms[iContDrawable]->m_tNormal);  
>   stateset->setTextureAttribute(2,  m_vGeoms[iContDrawable]->m_tSpecular);
>   stateset->setTextureAttribute(3,  m_vGeoms[iContDrawable]->m_tOpacity);
>   
>   
>   stateset->addUniform( new osg::Uniform("baseMap", 0) );
>   stateset->addUniform( new osg::Uniform("bumpMap", 3) );
>   stateset->addUniform( new osg::Uniform("specularMap", 1) );
>   stateset->addUniform( new osg::Uniform("opacityMap", 2) );
> 
>   osg::ref_ptr posEye = new osg::Uniform( "fvEyePosition",  
> osg::Vec3(-100,0,0));
>   posEye->setUpdateCallback( new PosEyeCallback(m_pEye) );
>   stateset->addUniform( posEye.get() );
> 
>   osg::Geometry *tmpGeo = 
> dynamic_cast(m_vGeoms[iContDrawable]->m_pDrawable);
>   
>   tmpGeo->setTexCoordArray(0, tmpGeo->getTexCoordArray(0));
>   tmpGeo->setTexCoordArray(1, tmpGeo->getTexCoordArray(0));
>   tmpGeo->setTexCoordArray(2, tmpGeo->getTexCoordArray(0));
>   tmpGeo->setTexCoordArray(3, tmpGeo->getTexCoordArray(0));
> 
>   osg::Material *material = new osg::Material();
>   material->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(1.0f, 
> 1.0f, 1.0f, 1.0f));
>   material->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4(1.0f, 
> 1.0f, 1.0f, 1.0f));
>   material->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(1.0f, 
> 1.0f, 1.0f, 1.0f));
>   material->setShininess(osg::Material::FRONT_AND_BACK, 80.0f);
>   stateset->setAttribute(material, osg::StateAttribute::ON);  
> 
>   osgUtil::TangentSpaceGenerator* tsg = new 
> osgUtil::TangentSpaceGenerator(); 
>   tsg->generate(tmpGeo, 1);   
>   osg::Vec4Array* a_tangent = tsg->getTangentArray ();
> 
>   tmpGeo->setVertexAttribArray (6, a_tangent);
>   tmpGeo->setVertexAttribBinding (6, osg::Geometry::BIND_PER_VERTEX);
>   programObject->addBindAttribLocation ("rm_Tangent", 6);
>   osg::Vec4Array* a_binormal = tsg->getBinormalArray();
>   tmpGeo->setVertexAttribArray(7, a_binormal);
>   tmpGeo->setVertexAttribBinding(7, osg::Geometry::BIND_PER_VERTEX);  
> 
>   programObject->addBindAttribLocation ("rm_Binormal", 7);


Then, if I apply with m_node->setStateSet(stateset); it works!
[Image: http://s14.postimg.org/xu4tgtjz4/works.jpg ]
But if I apply with: 
m_vGeoms[iContDrawable]->m_pDrawable->setStateSet(stateset); it doesn't work.
[Image: http://s16.postimg.org/ag2ars5w4/NOWORK.jpg ][/img]

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=59331#59331





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Differences between applying setStateSet in a Node and a Drawable?

2014-05-09 Thread Robert Osfield
Hi Jaime,

On 9 May 2014 08:40, Jaime  wrote:
> What are the differences between applying setStateSet in a Node and in a 
> Drawable??
>
> I have a shader (BumpSpecularOpacity). If I set the stateset to a Node, it 
> works correctly. But, if I set to a drawable it doesn't work. The stateset 
> applied is the same.
>
> Any suggestions? Thanks!

In general applying a StateSet to a Node or Drawable should have the
same effect, the only except is the osgText::Text drawable that create
it's own custom behavior to handle the texture atlas that it needs for
it's operation.

Robert.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Creating working omnidirectional shadow

2014-05-09 Thread Mickael Fleurus
Hi,
 yeah sorry I messed up with what I meant to say. It's more shadow with 
omnidirectionnal light, or point light as I think it's named in osg. 

ViewDependentShadowMap is producing a weird result. Depending on how distant my 
camera is from the scene, I have strange artefacts that make the scene 
unwatchable( img VDSM1). And if the light is too distant, shadows are cut of a 
part of the scene.(img VDSM2)

LightSpacePerspectiveShadowMapDB is also producing weird results. Depending on 
where my camera is, shadows are produced (img LSPSM1) or not (img LSPSM2). And 
sometimes, there is shadows only on a small part of the scene. (img LSPSM3) 

Are these problems that have been seen frequently, or is this caused by the 
rest of my code?

... 

Thank you!

Cheers,
Mickael

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=59329#59329




Attachments: 
http://forum.openscenegraph.org//files/vdsm2_976.png
http://forum.openscenegraph.org//files/vdsm1_300.png
http://forum.openscenegraph.org//files/lspsm2_126.png
http://forum.openscenegraph.org//files/lspsm1_521.png
http://forum.openscenegraph.org//files/lspsm3_551.png


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Differences between applying setStateSet in a Node and a Drawable?

2014-05-09 Thread Jaime
What are the differences between applying setStateSet in a Node and in a 
Drawable??

I have a shader (BumpSpecularOpacity). If I set the stateset to a Node, it 
works correctly. But, if I set to a drawable it doesn't work. The stateset 
applied is the same.

Any suggestions? Thanks!

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=59328#59328





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org