Creating or enabling light causes lag

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
chilly willy
Halfling
Posts: 65
Joined: Tue Jun 02, 2020 4:11 am
x 19

Creating or enabling light causes lag

Post 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?

User avatar
blitzcoder
Halfling
Posts: 99
Joined: Wed Oct 09, 2019 4:06 am
x 18

Re: Creating or enabling light causes lag

Post 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.

New Blitz3D/BlitzBasic/BlitzMax Home - https://blitzcoder.org
paroj
OGRE Team Member
OGRE Team Member
Posts: 2108
Joined: Sun Mar 30, 2014 2:51 pm
x 1134

Re: Creating or enabling light causes lag

Post 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

chilly willy
Halfling
Posts: 65
Joined: Tue Jun 02, 2020 4:11 am
x 19

Re: Creating or enabling light causes lag

Post 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()?

paroj
OGRE Team Member
OGRE Team Member
Posts: 2108
Joined: Sun Mar 30, 2014 2:51 pm
x 1134

Re: Creating or enabling light causes lag

Post by paroj »