Thread: Zoom exponent
View Single Post
Old 22nd March 2014, 09:33   #4
Nitorami
Major Dude
 
Join Date: Mar 2008
Location: Erlangen
Posts: 933
Uhhhh....that sounds like a lot of work.

Basically, the motion parameters, as you call them, are a rather ancient way to distort the screen while keeping GPU load low. The CPU calculates the mesh distortion first and then passes this on to the GPU which does a simple linear interpolation. The mesh is a simple flat m x n mesh.

The waves, dots and shapes are generated first, by the CPU, dan drawn to the screen.
Then, the CPU applies the motion variables zoom, rot, dx,dy, warp to the mesh.
The GPU applies the distorted mesh on the actual screen, generating a distorted copy.
This copy is then added to the original screen content by, I think, variable echo. Only then it becomes visible.

That means all motion variables apply to the past frame, not the newest one, i.e. you will always get to see the undistorted content of waves and shapes, plus the distorted echo.

I don't know exactly what warp does but certainly it is a composite of the basic motion dx,dy and possibly zoom or rot. You can try to emulate it in the per vertex section. Start with something simple like

dx = 0.01 * sin(6*x+time);
dy = 0.01 * sin(6*y+time);

As the name implies, the per frame section is run once per frame, and the per vertex section is run once per mesh point, where x and y (0...1) are the position of the mesh point on the screeen. You may also use rad for the distance from the center. For a mesh size of 64 x 48, the CPU runs the per vertex code 3072 times per frame which is why mesh size should not be set too high.

In the warp shader section (=a pixel shader; note that the term "warp" is arbitrary and has nothing to do with warp as motion parameter for the mesh), the plain screen position is available as uv_orig.xy, where the distorted version (as said above; distorted by the CPU and interpolated by the GPU) is uv.xy.
Nitorami is offline   Reply With Quote