Raycasting "fisheye effect" question

Posted by mattboy on Game Development See other posts from Game Development or by mattboy
Published on 2012-12-10T02:38:50Z Indexed on 2012/12/10 5:19 UTC
Read the original article Hit count: 1664

Continuing my exploration of raycasting, I am very confused about how the correction of the fisheye effect works.

Looking at the screenshot below from the tutorial at permadi.com, the way I understand the cause of the fisheye effect is that the rays that are cast are distances from the player, rather than the distances perpendicular to the screen (or camera plane) which is what really needs to be displayed. The distance perpendicular to the screen then, in my world, should simply be the distance of Y coordinates (Py - Dy) assuming that the player is facing straight upwards.

enter image description here



Continuing the tutorial, this is exactly how it seems to be according to the below screenshot. From my point of view, the "distorted distance" below is the same as the distance PD calculated above, and what's labelled the "correct distance" below should be the same as Py - Dy. Yet, this clearly isn't the case according to the tutorial. My question is, WHY is this not the same? How could it not be? What am I understanding and visualizing wrong here?

enter image description here

© Game Development or respective owner

Related posts about ray-casting

Related posts about raycasting