C++ Raycasting, questioning the fish eye correction

63 views Asked by At

I am implementing an isometric (C++) rendering based on a 2D map, as in the Wolfenstein3D game from 1992. I wanted to implement my own solution, so the initial version is the naive approach where I don t make any assumption on the distance to the next cell intersection. This is an important precision, because this different approach makes harder to compare my code with the existing versions.

As in all the raycasting tutorials, I stumbled upon the fisheye effect, and had to correct it because the effect was quite huge:

enter image description here

I implemented the given solution, which is projecting the object distance along the normal of the projection plan, or multiplying by cos(beta), with Beta the FoV angle. After tweeking some of my system parameters, I came to something acceptable, however not yet the perfect solution presented in some tutorials in youtube. If now the walls are flat, I get due to this correction another error, the objects are seen closer on the edge of the FoV.

enter image description here

As you see, I would like to have only straight lines, but I still get some annoying curves. I did some tests, and the fish eye correction suggested in the tutorial doesn t fully add up. When we do the correction, we won t find the same distance for the same object, according the FoV angle we are using. So If I just rotate the player, without translating, I will see the size of the object changing. When I stare direct at them, the correction is 1, when I see them on the edge of my FoV, they will look bigger, because the cos(Beta) yields something between 0 and 1.

enter image description here

I would like to understand, is there a way to completely remove this effect, or will it always be there? You can have a look at my complete implementation.

0

There are 0 answers