Page 1 of 1

Creating or enabling light causes lag

Posted: Sun Aug 20, 2023 11:50 pm
by chilly willy

I have a character walk into a house and turn on a light. When the light is turned on there is a very noticeable delay between frames.

At first I just created the light when it was turned on. When that caused the delay I tried creating the light beforehand and then just calling Light::setVisible() when it was turned on. That still causes the delay.

I don't know much about OGRE's internals or 3D graphics in general but I think it might be that a bunch of new shaders need to be created?

What is causing the lag when I create/enable a light and can I do the time-consuming work before hand?


Re: Creating or enabling light causes lag

Posted: Mon Aug 21, 2023 2:03 am
by blitzcoder

Turning on and off seems to be fine here.. currently using 1.7.

Maybe try attaching it to a scenenode instead for the setVisible toggle.


Re: Creating or enabling light causes lag

Posted: Mon Aug 21, 2023 11:05 am
by paroj
chilly willy wrote: Sun Aug 20, 2023 11:50 pm

What is causing the lag when I create/enable a light and can I do the time-consuming work before hand?

are you using D3D11? Its shader compilation then. You can configure a fixed number of lights to be considered in the shaders to avoid recompilation:
viewtopic.php?p=550703#p550703


Re: Creating or enabling light causes lag

Posted: Wed Aug 23, 2023 11:47 am
by chilly willy

I'm using GL3+. I am making the materials programmatically, not in scripts. How does a TargetRenderState relate to a Material/Technique/Pass? How can I access it in code to call setLightCount()?


Re: Creating or enabling light causes lag

Posted: Wed Aug 23, 2023 12:24 pm
by paroj