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?
Shadows speedup movement of camera
-
gregorgragor3
- Posts: 6
- Joined: Sun Apr 20, 2025 9:09 am
Re: Shadows speedup movement of camera
I tried creating shadow scene node for simple box, and there is no problem, probably because only few faces are there for shadows.
Re: Shadows speedup movement of camera
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
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
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
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
It seems large differences in frame rate do cause speed up or possible slow downs - related to prepare/clean shadows
Re: Shadows speedup movement of camera
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
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Shadows speedup movement of camera
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.
Re: Shadows speedup movement of camera
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
