Smooth transition from spelling projection to perspective projection?

I am developing a game consisting of two stages, one of which has a spelling projection, and the other is a perspective projection.

Currently, when we go between modes, we disappear to black, and then return to the new camera mode.

How would I go smoothly between the two?

+5
source share
2 answers

There are probably several ways to achieve this, two that I found that seemed to work best:

  • Drop all matrix elements from one matrix to another. This seems to work very well. I do not believe that this transition will be linear. You can try giving it an attenuation function instead of linear interpolation

  • A scaling of the fractions in the perspective matrix going to / from the field of view of about 0. You get from the spelling matrix into the perspective matrix of about 0 and go out to your target and probably will strongly adjust the near / far planes as you go. Otherwise, you will be up to 0, and then put in the spelling matrix. The idea behind this is that things seem flatter with a lower fov and that fov of 0 is essentially a spelling projection. This is more complicated, but can also be changed much more.

+5
source

I managed to do this without explicitly using matrices. I used Java, so the syntax is different, but comparable. One of the things I used is the mix () function. It returns value1 when factor is 1 and value2 when factor is 0, and has a linear transition for each value between them.

private double mix(double value1, double value2, double factor) { return (value1 * factor) + (value2 * (1 - factor)); }

When I call this function, I use value1 for perspective and mix(focalLength/voxel.z, orthoZoom, factor) for spelling, for example: mix(focalLength/voxel.z, orthoZoom, factor)

When determining your focal length and spelling ratio, it is useful to know that anything at the distance of focalLength/orthoZoom from the camera will be projected to the same point throughout the transition.

Hope this helps. You can download my program to see how it looks at https://github.com/npetrangelo/3rd-Dimension/releases .

+1
source

Source: https://habr.com/ru/post/1263983/


All Articles