Page 1 of 1

Smoother Scrolling (unlock framerate)

Posted: Sat Oct 08, 2016 12:47 pm
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.

Re: unlock framerate

Posted: Sat Oct 08, 2016 11:26 pm
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 ... :)

Re: unlock framerate

Posted: Sun Oct 09, 2016 6:49 am
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.

Re: unlock framerate

Posted: Sun Oct 09, 2016 11:42 am
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.

Re: Smoother Scrolling (unlock framerate)

Posted: Sun Oct 09, 2016 1:41 pm
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.