Smoother Scrolling (unlock framerate)

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

User avatar
HL65536
Inserter
Inserter
Posts: 30
Joined: Sat Aug 20, 2016 8:21 pm
Contact:

Smoother Scrolling (unlock framerate)

Post by HL65536 »

TLDR
make framerate independent from update ticks
benefits:
-game runs slomo instead of super-laggy if ups drops
-smoother gameplay if 60fps cant be reached
-far smoother experience on non-60Hz screens


how? Most games already have this, so it cant be that difficult:
step1:
camera movement:
cameraPosToRender=lastTick.getCameraPos()+lastTick.getCameraSpeed()*(thisFrame.getTime()-lastTick.getTime());
Must work while riding car/train, too.

step2:
entity movement:
entityPosToRender=lastTick.getEntityPos()+lastTick.getEntitySpeed()*(thisFrame.getTime()-lastTick.getTime());

step3:
gui? I have no idea if gui is currently bound to fps or ups but it should be fps.
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: unlock framerate

Post by ssilk »

Please understand: If your double the framerate in Factorio to 120 Hz only every second frame would show you a changed picture.

Camera position is rendered to be at the position of the entity. But the entity doesn't move between two ticks.
cameraPosToRender=lastTick.getCameraPos()+lastTick.getCameraSpeed()*(thisFrame.getTime()-lastTick.getTime());
Ah. Well, I see what you want: You want, that the camera moves independent from entity.

Hmmm.... I think it could be really good looking, but the afford to achieve this is ... :)
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
Rseding91
Factorio Staff
Factorio Staff
Posts: 14264
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: unlock framerate

Post by Rseding91 »

Factorio does not do movement interpolation. All movement and all frame cycle advances are exact and change by exact amounts only known when they are changed during the game update loop.

Because of that you can't say "I moved the frame X last tick so I'll expect to do the same next tick". That "what I did last tick" information doesn't exist. Only the current frame is known for any given animation happening on screen.

As Factorio runs now if we increased the FPS to 120 the game would draw 2 literally identical (pixel perfect) frames, advance one game tick, then draw 2 new pixel perfect frames, advance and repeat. Because of that there's absolutely zero reason to render FPS > UPS as the pixels don't change.

The game already drops FPS when needed and can run easily with FPS < UPS if your graphics card can't keep up with rendering for instance.
If you want to get ahold of me I'm almost always on Discord.
User avatar
HL65536
Inserter
Inserter
Posts: 30
Joined: Sat Aug 20, 2016 8:21 pm
Contact:

Re: unlock framerate

Post by HL65536 »

Please read everything before posting, ssilk did and understood what I wanted, rendering should "predict" where the the object would be on screen if it moved continuously with the same speed since the last tick. (Mispredictions are so short lived, they are never noticed)
The piece of code should be for the programmers to show how easy it would be and in fact it is so easy that almost every game has it, even early alpha minecraft did it right.

change
entityPosToRender=lastTick.getEntityPos();
to
entityPosToRender=lastTick.getEntityPos()+lastTick.getEntitySpeed()*(thisFrame.getTime()-lastTick.getTime());

I know that the one line is very abstract but it should boil down to just a few lines of actual changed code.
Rseding91 wrote:The game already drops FPS when needed and can run easily with FPS < UPS if your graphics card can't keep up with rendering for instance.
This is what I meant with "smoother gameplay if 60fps cant be reached": If the graphics card cant keep up, it alternates between one and two update steps between each frame. This ends up looking very jittery and ugly.
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Smoother Scrolling (unlock framerate)

Post by ssilk »

Rseding just tired to explain, how this currently is and that he doesn't believe, that this is possible before 1.0 comes out for reasons. :)

I changed the title of this thread.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
Post Reply

Return to “Ideas and Suggestions”