Shadows speedup movement of camera

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
gregorgragor3
Posts: 6
Joined: Sun Apr 20, 2025 9:09 am

Shadows speedup movement of camera

Post by gregorgragor3 »

When I am moving forward my player, after few seconds it suddenly speads up.
I figured that shadows of animated character does it. When I don't create shadow scene node for animated character (not the camera object), everything is fine.
Is there a way to solved this speed up problem?
gregorgragor3
Posts: 6
Joined: Sun Apr 20, 2025 9:09 am

Re: Shadows speedup movement of camera

Post by gregorgragor3 »

I tried creating shadow scene node for simple box, and there is no problem, probably because only few faces are there for shadows.
CuteAlien
Admin
Posts: 9923
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Shadows speedup movement of camera

Post by CuteAlien »

Camera speed and shadows shouldn't be related. Can you reproduce this with some example?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
gregorgragor3
Posts: 6
Joined: Sun Apr 20, 2025 9:09 am

Re: Shadows speedup movement of camera

Post by gregorgragor3 »

I use bullet physics and by pressing 'w', I add force relative to screen view to rigid body. Every frame I read rigid body position and apply it to Irrlicht camera. After holding 'w' for long time, after seconds the move speed is much higher. I suppose it has to do something vith Irrlicht render manager, releasing shadow cache, disabling/enabling enemy's shadow based on current view or something like that?
gregorgragor3
Posts: 6
Joined: Sun Apr 20, 2025 9:09 am

Re: Shadows speedup movement of camera

Post by gregorgragor3 »

I think I fixed it. I set vsync to true in createDevice . The FPS stays fixed at 60.
It seems large differences in frame rate do cause speed up or possible slow downs - related to prepare/clean shadows
CuteAlien
Admin
Posts: 9923
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Shadows speedup movement of camera

Post by CuteAlien »

Ah - so your physics is not framereate independent. Render slower -> frame takes longer -> physics does more or larger steps in one frame (or something like that). Fixing fps is one way around it, thought then people with different refresh rates will have different speeds (for example my current screen is 144hz, my old one is 60hz).

Somewhat complicated topic, one famous article about it is this one: https://gafferongames.com/post/fix_your_timestep
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Brainsaw
Posts: 1239
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Re: Shadows speedup movement of camera

Post by Brainsaw »

I don't know Bullet, but for the physics engine I use (O.D.E.) it is very important to have a fixed time step. I have moved the physics calculation to a thread of it's own, but it is also possible to do multiple steps per frame if necessary, or don't step the physics engine if Irrlicht runs faster. 60 FPS for phyiscs is ok most of the time though, but it may slow everything down if someone plays it with 40 FPS.
Image
Dustbin::Games on the web: https://www.dustbin-online.de/
CuteAlien
Admin
Posts: 9923
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Shadows speedup movement of camera

Post by CuteAlien »

Yes, you generally need fixed time-steps for physics. But they don't have to be the same as rendering. That's basically what the link I posted explains.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply