Sharing shadow map : help

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


ChicChic
Kobold
Posts: 26
Joined: Tue Sep 05, 2017 10:19 am
x 7

Sharing shadow map : help

Post by ChicChic »

Hi all,

I'm developing a software that (may) generates several cameras images at a time.
Each camera create an instance of a compositor workspace that has a shadow node inside.
This shadow node is configured to provide a directional light, several points and/or spots lights for example.

My question is : is it possible to share the shadow map of points and spots lights (not directional because of the special generation for pssm) so their shadows are generated only once for all the cameras ?

I'm trying some tests by using CompositorShadowNode::setStaticShadowMapDirty/setLightFixedToShadowMap plus other tweaks but it doesn't seems to achieve my goal...

Thanks !
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5505
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1372

Re: Sharing shadow map : help

Post by dark_sylinc »

Mmmmm no.... now that you bring it up. No.

The only thing I can think of (which is probably not user friendly at all) without modifying Ogre is to have only one workspace, and submit all render targets as external channels to that workspace, then have each render_pass draw to its own target and use its own camera (you can specify "camera MyCameraName" in the render pass)

But still.... IIRC if a shadow map is forced to recalculate (because camera transform changed and thus directional lights need an update) I believe the spot and point lights will also be recalculated (which is wrong... originally these lights also accounted the camera but they no longer do so anymore) unless they're manually controlled via setStaticShadowMapDirty/setLightFixedToShadowMap.

So bottom line: it might be possible but you'll be doing a lot of fighting. That effort could probably be best spend in modifying workspaces' code to borrow an existing shadow node from another workspace, provided during creation (and make sure the secondary workspaces do not delete a borrowed shadow node on destruction, the primary workspace should do it) and inserted into CompositorWorkspace::mShadowNodes (and have a CompositorWorkspace::mWeakShadowNodes set to look up in the destructor which shadow nodes we can't destroy).