Roger,
You are probably right that one should overwrite ViewData if he/she wants to
add Shadow computation specific uniforms (especially if they are supposed to be
updated in cull traversal). Thats something I have neglected because I had no
such uniforms in my code. It could be a good idea to create simpler mechanism
to add user uniforms along with their shaders. Maybe we could add
_viewDataCommonStateSet memeber to osgShadow::StandardShadowMap. This stateset
would be a placeholder for states and uniforms which would be passed to all
associated ViewDatas in ViewData::init.
Before such mechanism is added, you can, as J-S suggests, add your uniforms in
any Node/Drawable StateSet that lies on shadow render/apply cull traversal path.
Cheers,
Wojtek
----- Original Message -----
From: Roger James
To: OpenSceneGraph Users
Sent: Friday, January 23, 2009 1:49 AM
Subject: Re: [osg-users] Bug : LightSpacePerspectiveShadowMapDB and cow.ive
Wojciech Lewandowski wrote:
Guys,
Sorry if I offend anyone but I thought this should be obvious. Looks like
only J-S got it ;-) So I now shout to make it clear:
If you don't like Vertex shader I use you can easily turn it off and switch
to Fragment shader only version. You can easily adopt approach where you have
only one Fragment shader as older osgShadow::ShadowMap did. I have added Vertex
Shader only for one reason: to make sure ambient color is not wiped.
But if you want fixed vertex pipeline - simply call:
lispmObject->setMainVertexShader( NULL );
lispmObject->setShadowVertexShader( NULL );
and voila you got rid of VertexShaders.
Of course you will also have to substitute Fragment shaders with yours,
because my Fragment shaders expect that ambient term colorAmbientEmissive would
be passed from VertexShaders you turned off.
But further replacing fragmentShaders with something similar to
osgShadow::ShadowMap shaders is really straight forward. Just set
setMainFragmentShader with your Shader. And call setShadowFragmentShader with
NULL argument and then you will land with configuration similar to
osgShadow::ShadowMap. Which means you will lose ambient ;-).
Roger, You dont need to override ViewData if you only want to replace
shaders. Simply change the shaders in your DerivedShadowMap constructor. I
thought you want to do something more complicated when you presented me your
class.
Wojtek
PS. Actually there are a ways to compute ambient component in fragment
shader if one is desperate, but it would require other sacirfices. I wrote a
post on this topic few weeks ago.
----- Original Message -----
From: Roger James
To: OpenSceneGraph Users
Sent: Thursday, January 22, 2009 6:27 PM
Subject: Re: [osg-users] Bug : LightSpacePerspectiveShadowMapDB and
cow.ive
Alexandre Amalric wrote:
Hi osg-users,
has anyone tried to launch osgShadow example with --lispsm and cow.ive
model, apparently LightSpacePerspectiveShadowMapDB do not handle multi-textured
model.
Is there any specific configuration to make it work ?
I'm using osg svn.
Kind regards,
--
Alexandre AMALRIC Ingénieur R&D
Alexandre,
It is not a bug, and you cannot configure round it. The fragment shaders
in osgShadow::StandardShadowMap which are used by all the lispsm variants do
not support multi-texturing or the use of texgens. The only way round it is to
write your own shadow technique which derives from lispsm and overrides the
shaders with ones that do what you want. Here is a very useful code snippet
provided by Wojtek that shows how it is done.
class CComplexShadowTechnique : public
osgShadow::LightSpacePerspectiveShadowMapVB
{
public:
/** Convenient typedef used in definition of ViewData struct and
methods */
typedef CComplexShadowTechnique ThisClass;
/** Convenient typedef used in definition of ViewData struct and
methods */
typedef osgShadow::LightSpacePerspectiveShadowMapVB BaseClass;
CComplexShadowTechnique()
{
// Override shaders here
}
struct ViewData: public BaseClass::ViewData
{
virtual void init( ThisClass * st, osgUtil::CullVisitor * cv )
{
BaseClass::ViewData::init( st, cv );
// Add additional uniforms here
}
};
// This macro is required if you override ViewData and ViewData::init
// It generates virtual stub function in trhe Base class which
// calls associated ViewData::init.
// Probably this was the reason your ViewData::init was not called.
// Its just a case where virtualization does not help because I
actually
// want to virtualize ThisClass subclass and its method.
META_ViewDependentShadowTechniqueData( ThisClass, ThisClass::ViewData
)
};
Roger
--------------------------------------------------------------------------
Wojtek,
Mea culpa. I just missed it. I thought you had to override shaders in the
constructor.Thinking back I now remember that I had noticed the setXXShader
methods a while back I guess I had just forgotten them. I assume that you still
have to override the init to set up additonal uniforms.
Roger
------------------------------------------------------------------------------
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org