23
votes
Accepted
Why use Time.deltaTime in Lerping functions?
See also this answer.
There are two common ways to use Lerp:
1. Linear blending between a start and an end
...
5
votes
Why does the kinematic body move in opposite direction after I interpolate its movement, and how do I fix it?
You can't rely on movement.x hitting 0. This is because floating point errors. Instead, check if it is closer to 0 than ...
4
votes
Accepted
GLSL "varying" interpolation: component-wise? Reference in the spec?
TL;DR: Yes, it is component-wise.
As you said, GLSL specifications have formulas for computing "datum associated with a fragment", like this one:
GLSL 330 spec : 3.5.1 Basic Line Segment ...
4
votes
Accepted
How to smooth rotations?
Yes, in fact that's what quaternions are often used for - interpolating between two different orientations. Other methods of representing orientation suffer from issues like gimbal lock and wrap-...
4
votes
Accepted
Fixed Timestep with Interpolation | Blurry & Choppy
Your lerps and slerps are backwards:
lerp(current, previous, alpha)
should be
lerp(previous, current, alpha)
ie. ...
4
votes
Accepted
Why do my sprites jitter when moving diagonally?
With out code, this might be hard, but if I had to take a guess, your sprites aren't gittering, your camera is. I suspect you are moving the camera either to the exact x or y position both when ...
3
votes
Accepted
How to smoothly interpolate 2D camera with pan and zoom
For a smooth loop like this, we want to scale the camera viewport from 1 x at the start to \$r\$ x at the end of the first loop (where \$r\$ is the ratio between the inner image size and the outer ...
3
votes
Accepted
Suitable interpolation for animating explosions
There are multiple easing functions (https://easings.net) that can help you, more specifically "ease out" functions (faster at the beginning, slower at the end).
I have all of those in the ...
3
votes
Accepted
How to smooth viewport panning when using minimap (in typical RTS)?
I think you should avoid setting your viewport position to the value selected in GUI in one, single frame.
Instead, I'd add a target position and ...
3
votes
Given a set of points with color values, finding a gradated color value from a given position
An idea that occurs to me would be to use something like Voronoi cells to split the area by color, and sort of blend them into each other. Essentially past the border between two colors use a smooth ...
3
votes
Accepted
D3D12: how to enable perspective correction when interpolating UV coordinates?
You've lost perspective correctness due to the way you've written your vertex shader.
Ordinarily, we'll transform our vertex from view space to clip space by multiplying it by a projection matrix that ...
2
votes
Why is interpolation passed into the rendering routine when the position and speed are related to the update routine?
Combining a physics engine that uses a fixed time-step with a variable-timed rendering loop can lead to very choppy movement. Sometimes you have two physics frames between two renders, sometimes none ...
2
votes
HeightMap from a graph
TL;DR: Use bicubic interpolation or spline interpolation.
So, you're looking for a method of two-dimensional interpolation. Unfortunately, this isn't a perfect two-dimensional grid (mathematically, it'...
2
votes
Suitable interpolation for animating explosions
Yes, the velocities are the highest at detonation time, and as the explosion progresses, the system loses energy.
So fast growth that fizzles out would be a good model.
So a function with a fifth ...
2
votes
Accepted
Aim/Scope Oscillation Algorithm
Using polar coordinates would do the trick. Here’s a graph of the function r=sin(2.3θ), with θ going from 0 to 2π:
Given ...
2
votes
Accepted
How do I interpolate an object from point A to B such that it accelerates, overshoots, and bounces back to target position?
A few small fixes:
Cache your initial position, and lerp from there to your end, to avoid a feedback loop where transform.position is being used to modify itself.
...
2
votes
Accepted
Slerp to slerp smoothing
I hadn't actually aligned in CatmullRom, it was one of my other tests. It got lost in all the messy code. The problem was solved by aligning the start and end points of the spline input. (params: pre, ...
2
votes
How do you determine which 4 pixels to interpolate, using bilinear interpolation?
Conventionally, the pixels (or "texels") in a texture are arranged in a 2D grid. Let's say it looks like this:
...
2
votes
Trouble getting the right Interp Speed with 'FInterp To' node
So I was wrong about the value of DeltaTime of FInterp To I hadn't use the EventTick in the <...
1
vote
How to smoothly interpolate 2D camera with pan and zoom
Here is my solution based on the answer given by DMGregory. This is Delphi Pascal. The LinearInterpolate function is just a lerp. Care has to be taken to avoid ...
1
vote
Camera Jitters When Displacing and Rotating Smoothly
Your GetSmoothFollowRotation() function is wrong.
SmoothDampAngle gives you an angle in degrees (0-360 or -180-180), but you're ...
1
vote
Interpolating between positions unfeasible at 30 frames per second?
I think this article summarizes the problem you are seeing FIX YOUR (UNITY) TIMESTEP!
You could calculate your fixedDeltaTime like:
...
1
vote
Godot 3.0 Constant 2D Angular Velocity
@skrx "+1" Thanks!
I wasn't able to make get_local_mouse_position().angle_to_point(position) work as intended, but using your method of angular speed, I was able to rework it to suit my purposes:
<...
1
vote
Accepted
Godot 3.0 Constant 2D Angular Velocity
A simple solution would be to get the angle to the target and then just rotate counter-clockwise if the angle is negative and clockwise if it's positive:
...
1
vote
Accepted
Can't figure out what's making the player teleport back to spawn
Your method for blending to the new updated position definitely looks dicey. While there are times when we want to use the pattern ...
1
vote
Accepted
Smooth Rotate Object While Orbiting
For anyone running into a similar issue, the solution (for me at least) was to just change it to rotating around the local z-axis rather than the world z-axis:
...
1
vote
Fixed timestep updates with a variable timestep update
The reason we do fixed timestep updates in the first place is to ensure our realtime game simulations stay consistent.
Take a simple object falling under gravity of -9.8 m/s^2 under Euler integration,...
1
vote
Why use Time.deltaTime in Lerping functions?
You are right, the method Quaternion Slerp(Quaternion a, Quaternion b, float t) interpolates between a and ...
1
vote
Why use Time.deltaTime in Lerping functions?
I think the core concept missing would be in this scenario A is not fixed.
A is updated with each step, by however much along the interpolation that Time.deltaTime is.
So, with A getting closer to B ...
1
vote
Accepted
Calculating t value to use with Hermite interpolation
It depends on what you want. It's always a trade-off between having to wait occasionally or having a longer lag. You can trade one against the other (by specifying your desired optimal buffer size).
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
interpolation × 173networking × 30
unity × 23
mathematics × 23
multiplayer × 23
fixed-timestep × 14
c# × 10
animation × 10
quaternion × 10
client-server × 10
c++ × 9
collision-detection × 9
physics × 9
algorithm × 9
lerp × 9
android × 8
rotation × 8
movement × 8
movement-prediction × 8
extrapolation × 8
game-loop × 7
opengl × 6
2d × 6
java × 6
xna × 6