# Do game engines put all interpolation onto the GPU?

Is it considered standard to push all the vertices and an interpolation of the next position onto the GPU?

Suppose a sector is moving up every game tick at 50 units per second. You could put on the shader something like (good old parametric equation-like formulas):

pos.x = a*x1 + (1 - a)*x0;


Where you'd calculate a as a uniform and only send this value to the GPU in an uncapped fashion, like so:

while (true) {
a = percentage of the way between frames [in range from 0.0 to 1.0]
updateGLUniform(..., a);
render();

// Rest of stuff

delay();
}


The other way of doing it was to manually set each entity and sector every single time you loop, but then you might have to update the position of a lot of things every game cycle. Just setting one value seems way more efficient.

However, I don't know if there's any downsides to this. Are there any negatives to shoving interpolation off to the GPU to save computation time in the game? Or is there something that I'm missing? What do major games do?

As written, your formula for pos.x always returns x no matter what value a takes:

pos.x = a*x + (1 - a)*x;


To get meaningful interpolation, we need to tell the GPU two positions to interpolate between,x0 and x1, yielding:

pos.x = a*x1 + (1-a)*x0;


So now that's three variables we need to tell the GPU about, instead of just one position for this frame.

So if our x0 and x1 change frequently (as is the case for many types of motion we want to represent in games - think dynamic physics, nonlinear animations, anything with player input or AI), then we haven't really saved ourselves any bandwidth this way. In some cases, doing the interpolation GPU-side might require sending double the transformation data compared to computing a single set of interpolated transforms CPU-side.

This transform data also tends to be fairly sparse - one matrix per dynamic object - so compared to the massive workloads GPUs handle projecting, rasterizing, and shading every pixel of the scene, interpolating movement on the CPU is usually not a major bottleneck.

That's not to say there aren't many cases where interpolating a value on the GPU makes sense - there are indeed many. It's just not quite as universal a solution for all movement as it might appear at first.

• Good catch, I forgot the subscripts (d'oh). You brought up a really good point about sending double the vertex data. – Water Apr 30 '17 at 3:57