[osg-users] osgShadow::ShadowMap adding some polish

Mihai Radu radu at cm-labs.com
Thu Sep 13 15:48:20 PDT 2007


Hi Robert,

I'm working now on integrating the new osgViewer and osg 2.x into the
simulator of our company, and as a result I am moving to using
osgShadow::ShadowMap in place of the old code that I refactored to use
with osg 1.2, before the first iterations of the NodeKit.

I will extend the osg class to integrate with the company's physics and
viewer, and I am trying to keep to a minimum the overlap between the osg
code and the derived class.
Therefore there are a couple of things that seem simpler to change or
add-in to osgShadow::ShadowMap, and this way the class gets some
additions, if they are warranted.

As an example I added functions to get/set a Vec2 for the x/y size of
the depth texture used. (I attached the changed files)

There are three other points that I will need to work with:

1. updating the camera & TexGen during cull()

    One part here is to change the way the light is selected, one option
is to keep a reference to the intended osg::Light, the current code will
use the last light in the list of the RenderStage.
    Another is to set a different ways to update, the current way is to
use the bounding box of the entire scene. Another style that I found
useful is to use a given reference point and radius, for example so that
the shadows can follow a vehicle without losing resolution as it moves
about a terrain, or use the parameters of a given SpotLight.
I see that ShadowTechnique defines ShadowTechnique::CameraCullCallback,
but I did not see if it is ever used, is it intended for this kind of
usage ? Then what would be the best way of using it ?

2. custom GLSL shaders

    Need to be able to set / get custom programs for rendering the
scene. I can see this done by either passing an std::string for
vertex/fragment shaders, or by passing osg::Shader/Program.

3. Uniform variables for controlling rendering

    I suggest to have a set of standard uniforms ( a standard name like
for the other ones used by osg ) to help with implementation of custom
shaders. The values that are immediately needed are baseTexture,
shadowTexture, ambientBias, and the texture unit used for shadowing
coordinates, to access the appropriate gl_TexCoord[].
    When using the nodekit on complex scenes with multiple lights, that
can be enabled/disabled at run-time, I found that I needed to also use a
uniform to disable shadow application when the shadow casting light is
turned off, this can also be used on a per-object basis to turn off
application of shadows on some parts of the scene. The GL number of the
shadow-casting light is another important value when a different light
is used to cast shadows.

I'm eager to get your opinion on this.

Cheers
Mihai Radu

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ShadowMap.cpp
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20070913/a48e3b4c/attachment-0001.asc>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ShadowMap
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20070913/a48e3b4c/attachment-0003.txt>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 542 bytes
Desc: OpenPGP digital signature
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20070913/a48e3b4c/attachment-0002.pgp>


More information about the osg-users mailing list