Jump to content

Match Sticks and Max Physics Delta Time per Frame


Moesly_Armlis

Recommended Posts

Explaining the concept of Max Physics Delta Time per Frame using match sticks.

Make a curved line using a box of match sticks and then replicate the curved line using the longer stove style box of match sticks. If the scale is identical then the curved line could look clunky and have sharper edges because of poor resolution. With complex curves the expected result is a curved line that has fewer match sticks and loss of detail.

This experiment is to identify the difference between using the extreme values for Max Physics Delta Time per Frame. The value can be changed from the main menu settings general panel.

I am trying to notice the difference in using the values of 0.03 and 0.12 for the MPDTF.

If the vessel survives testing at a setting for MPDTF of 0.03 then at a setting for MPDTF of 0.12 the vessel should be more prone to break apart.

Example: a plane flies maneuvers and flown at high G force to try to break it apart. Then the value for Max Physics Delta Time per Frame is increased from 0.03 to 0.12 and the plane is again put through similar testing.

So far the results are not showing much difference and the two simulations have similar results. Extreme re entries will be tested next to show vessel simulation deviations.

Anyone else interested in contributing to this scientific experiment?

edit:

From the Wiki:

Max Physics Delta-Time per Frame

  • This setting determines how many physics calculations the program can run per game second. So, as the number increases, gameplay slows down, as more calculations happen every game second. It slows down, but not in the usual way. There is no lag, but now one second that passes on Kerbin takes more than one second in real time. This setting is good for keeping very large ships from falling apart. Additionally, in settings.cfg, this value can be increased beyond the range of the GUI slider.
  • Default: 0.04 sec

Edited by MoeslyArmlis
Link to comment
Share on other sites

Well, question 1 is is that actually what the Physics Delta setting means? It's a setting I've never fully understood.

EDIT: To expand, this is how I think the Physics Delta setting works. I have no idea if I'm right! The actual timestep used in the physics engine is fixed at a given physical timewarp setting, and is usually higher than the interval between frames. The Physics Delta setting then says, if the in-game time since the last frame is more than x, render another frame. In some sense it's a target framerate, and the default setting is equivalent to 25 fps. In some of my tests I've seen different behaviour in terms of frame times above and below that value, and it's of note that the debug menu framerate graph does not read correctly below that.

If I'm right the Physics Delta setting will affect framerate and lag but not vessel behaviour.

Edited by cantab
Link to comment
Share on other sites

Well, question 1 is is that actually what the Physics Delta setting means? It's a setting I've never fully understood.

I believe it slows down the in-game simulation speed. So basically, 1 second of real time can be 2, 3, 4, etc. seconds in game. It takes a load off of your processor because the game doesn't have to compute everything so quickly. Can often increase your framerate, or so I've heard.

Link to comment
Share on other sites

It says MAX delta time, so this setting might only make a difference when the simulation is struggling to keep up (timer turns yellow). In my understanding, if it takes less than 0.03s to calculate a physics frame, there is no difference between your two settings. If it takes longer, KSP will either take larger time steps (up to the max delta time), or slow down (if max delta is 0.1s and each physics frame takes 0.2s the game runs at half speed).

You might find differences in oscillation behavior. When building a plane with (too) much control authority and using SAS, I have often seen it flying stable at 1x, and heavily oscillating at 2x of higher physics warp (it sounds like a high delta time should be somehow similar to physics time warp).

Edited by pellinor
Link to comment
Share on other sites

no no. the physics delta is the time between physics frames- frames which in them physics forces are calculated.

the lower the physics delta is the more accurate the simulation is and the smaller the steps between frames are at the cost of higher CPU cost.

physics delta 4x as long means 1/4 the calculation per a given amount of time (larger or equal to the larger delta).

a simple test would be launching an i beam towards different layers of armor. at the right speed and physics delta (and some luck) you could bypass the first layer and hit only the second one (you could do it in any delta but speeds would need to increase)

Link to comment
Share on other sites

@cantab: what you describe sounds more like a "MIN physics delta time per frame" to me.

@EladDv: I agree about the term "physics delta", but why does the setting explicitely say "max physics delta"? Or are we talking about different settings?

Edited by pellinor
Link to comment
Share on other sites

A game usually has a main loop which basically looks like this:

Process Input -> Do Calculations -> Paint Frame -> Repeat

The more complex the game world and objects are, the more time it takes for one iteration thru the main loop. A good game bases it's calculations now on the time elapsed since last frame. And here comes the max physics delta into play: If the time elapsed since last loop is > MPD then time elapsed for physics calculations = MPD. Thats what the MPD is for.

Link to comment
Share on other sites

My understanding is that physics-delta per frame causes the game to prefer to run in slow motion, smoothly, rather than in real-time but at poor frame rate. I believe what italters is the ratio between physics frames (the game calculating what's actually going on) and graphics frames (the game drawing it to the screen).

When working in Unity physics calculations often have to be multiplied by something called time.deltaTime, which synchronizes them to the frame rate--so your physics-governed bullet is launched at 500 meters per second instead of 500 meters per frame.

What I see in practice in KSP is that if I increase max physics-delta, the game runs faster and choppier--which doesn't affect the performance of craft but does make Kraken attacks much more likely.

Link to comment
Share on other sites

To clarify (this is a bit dense, I reckon)

That setting defines the Unity built in lower threshold for just how low FPS can force simulation time to "slow down"

this is the point where your mission time display turns yellow - that means time is slowing down so that with a lower FPS rate, each frame doesn't need to represent such a large amount of "delta time" that would harm the precision of the simulation (aka: Release The Kraken!)

so it makes a compromise and slows down the simulation, so that in a low fps condition, each frame still covers the less than the maximum delta-time specified

that means the value of this setting is defined as the inverse of the minimum FPS you want to allow time to try to slow down and cover before the mission timer turns RED

mind then, when you see red - then the engine has crossed the line where it will slow time down for the sake of simulation stability -- and that means physics will start taking larger leaps across the gaps left by one's meagre FPS and whatever happens.... well, you know

so the higher you set that value, the less yellow it will allow before red (I hope I'm right on that, as this is just my own best reckoning of how it works)

so you trade simulation stability (no Kraken) for time not to go into slow-motion as much (at your own risk of Kraken)

and that's how I THINK it works

[Citation Needed]

Cheers

Edited by Moach
Link to comment
Share on other sites

The step size illustrates the process

The simulation is running many calculations. Each calculation is broken down into small iterations or steps. The smaller step size will increase the calculations performed per frame resulting in a finer fidelity and precise simulation.

A response time with a 1:1 real time to game time ratio being the ideal condition and the MET indicator is green. Response time of 4:1 will indicate red and the computer cannot calculate the frame fast enough and kerbal time runs slower. Response time of 4:1 is four seconds of real time for each second of kerbal time or four minutes of real time to one minute kerbal time.

Smaller steps demands more CPU time. A frame takes longer to calculate. Keeping up with the high demand for CPU cycles will result in having a slower response time.

Inversely if the step size is increased then the simulation runs rough and less precise. The demand on the CPU is reduced and frames can be completed quickly. This benefits a slow running simulation when precision is less important.

Using a computer to solve pi using successive approximation can illustrate that using smaller steps will result in a closer approximation and take longer to complete the solution.

Experiments

The experiment has not revealed much differences between the extreme values of the Max Physics Delta Time per Frame. The next part of the experiment is with greater part counts such as a complex space station. Docking with these stations has the indicator in the red. Under stressful conditions such as a rapid docking maneuver, could demonstrate contrast.

Dynamic Max Physics Delta Time per Frame

This addresses the issue of slow frame rate during situations where physics simulation precision is less important.

When conditions such as walking kerbals around a Minmus refinery complex cause an increase demand on the CPU and frame rate runs slow. You could try to use the physics time warp but the step size becomes too large and a K event can destroy the complex.

At these times increasing the Max Physics Delta Time per Frame would allow quicker frame rate when physics simulation precision is required less. Reducing the Max Physics Delta Time per Frame when the kerbal is within the vessel and greater simulation precision is required.

A simple answer is having a 0.12 MPDTF included in the range for physics time warp. Currently 2x physics time warp step size is too large and can cause K events.

Edited by MoeslyArmlis
Link to comment
Share on other sites

I had some quick tests yesterday with the MaxDeltaTime and PhysicalTimeRatioViewer (PhysicalTimeRatioViewer has now a new handy slider that lets you change that value during flight).

From those tests and the unity docs about MaxDeltaTime I concluded that a lower value will slow down the game much more than a higher value.

On the other hand if the value is set too high the game will have big fps spikes due to calculations being done.

There is no indicator that unity will sacrifice physics precision to keep up with time. So I'm assuming that's done purely on Kerbal's side for example during physical time warp.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...