Lights are enabled in Forward3D instead of putted back to what they were

Discussion area about developing with Ogre2 branches (2.1, 2.2 and beyond)
Post Reply
ChicChic
Kobold
Posts: 26
Joined: Tue Sep 05, 2017 10:19 am
x 7

Lights are enabled in Forward3D instead of putted back to what they were

Post by ChicChic »

Hi all,

As the tittle said, in the code of Forward3D::collectLights the lights are setted to invisible for some stuff and putted back to... visible !!!
Instead of setted back to what they were... it brang a problem in my software so i've made a patch.

I upload the patch, it has been made from Ogre 2.1 commit 2dcab1a29414bf53fe25d0b8dad97715064fb07b and the problem also appear in Ogre 2.2...
If some devs agree with that patch it should be pushed...

Cheers
Attachments
0001-Lights-are-enabled-instead-of-putted-back-to-what-th.patch
(1.58 KiB) Downloaded 15 times

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4501
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 936
Contact:

Re: Lights are enabled in Forward3D instead of putted back to what they were

Post by dark_sylinc »

Hi!

Great point!!!

Fix pushed.

The fix has also been backported to stable 2.2 and 2.1 branches.

Thanks for the fix!

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

Re: Lights are enabled in Forward3D instead of putted back to what they were

Post by ChicChic »

Ok, nice !

(I haven't seen it was also in ForwardClustered too :roll: )

Glad to help !

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

Re: Lights are enabled in Forward3D instead of putted back to what they were

Post by ChicChic »

Hello again,

I see that a very similar problem occurs in CompositorShadowNode::clearShadowCastingLights/CompositorShadowNode::restoreStaticShadowCastingLights with Light::setCastShadows ...

Is it possible to correct the issue the same way dark_sylinc ?

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4501
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 936
Contact:

Re: Lights are enabled in Forward3D instead of putted back to what they were

Post by dark_sylinc »

Actually no.
Those functions you pointed to are for manually managing shadow map/lights and force Ogre to use associate a light with a specific shadow map.

A light that does not cast shadows being forced to be associated with a shadow map is a contradiction.

If you want to turn off shadow casting or disable a light that you manually forced to be associated with a shadow map; either unbind the light from that shadow map; or alternatively set the light power to 0, thus the light will still burn GPU and CPU power, but it will not visually affect the scene; and restore the light power when you need to enable it again.
You can use light->getUserObjectBindings()->setUserAny to save the old light power for later restoring it.

I understand it's not user friendly (quickly flipping setCastShadows is convenient) but the implications of the contradiction are complex to solve (we must skip the shadow map from being processed, there will be holes/gaps in the shadow map, new shaders must be generated which can cause stalls)

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

Re: Lights are enabled in Forward3D instead of putted back to what they were

Post by ChicChic »

If you want to turn off shadow casting or disable a light that you manually forced to be associated with a shadow map; either unbind the light from that shadow map; or alternatively set the light power to 0, thus the light will still burn GPU and CPU power, but it will not visually affect the scene; and restore the light power when you need to enable it again.
That was the point of my problem, I use the CompositorShadowNode::setLightFixedToShadowMap to reuse existing shadow map from other workspace in order to save CPU/GPU time but when I disable a light (Light::setVisible) it caused visual problems for the other lights.
So I tried to use light power but CPU and GPU time were still burned.
Finally I wanted to disable shadow casting when I want to disable a light and here was my actual problem.

Ok so unbinding the light from the shadow map have solved my former issue.
I can reuse shadows from other workspace without any artifact, thanks !

Post Reply