Well it’s because you’re projecting on a plane. It’s kind of the reverse of the parallax effect.
It’s perfect for representing lines because you’re just inverting lines. That’s why your raycaster must use perpendicular increments instead of angles - you’re going to output on a plane as well.
CCD don’t have issues because they’re planar as well. If you reverse a plane, you get a plane.
As for the eyes, let’s not forget they’re spherical (kind of) instead of a plane, so they effectively see the world in their angular version, aka the fisheye effect. As jonne explained, our brain actually does the cos formula and stuff to correct it so we can see straight lines! Fortunately you don’t have to deal with this.
Anyway it’s all a matter of projections in the end. Raycasting is also a projecting method, quite a literal one!
Awesome! But for texturing I’ll have to know the exact hit point. However when I know the point, I can simply compute the distance to the projection plane (line), which I bet is much cheaper than what I’m doing now.
Found it. I want to emphasize that neither your eye nor the camera actually sees a non-distorted image. Any mapping to a flat surface produces distortion, the question is how much of it is so much that you begin to notice
I think I am the one who is confused. Was a very long day today, and my mind has been wandering all over the place.
But your question of “why” the same phenomenon (fisheye effect) is not visible in real life is answered by the article I linked. There is a fisheye effect due to perspective, and it was countered in the design of the Parthenon
Yep, I’ve been once interested in this, it causes a nice illusion called chronostasis.
EDIT: Also a related offtopic – when looking in the mirror and tilting my head I noticed that eyes rotate around the viewing axis (roll), not only left/right and up/down. Think about it for a second, it has many interesting implications, such as: can the eye muscles twist if you rotate too much? Also it makes stereoscopic vision worse. The eye movement is actually extremely complex topic, with many documented rules, algorithms and equations – begin with searching eye musles on Wikipedia and see where it brings you
Just ran my raycasting on Pokitto, only have 20 FPS But I haven’t done any optimizations whatsoever yet, so hopefully I can bump it up higher. It might also be worth actually reading something about raycasting and not try to figure out everything myself (But programming by tutorials simply isn’t that satisfying.)
It’s still 2D raycasting, you just must not stop at the first ray intersection, but keep tracing the ray and draw walls that are behind other walls – plus some extra code to draw the floor (just a line connecting top of one wall with the top of the next one) and not overwrite what’s already been drawn etc.
What FPS did you achieve with your raycasting demo, @jonne?
I’m afraid I’ll have to do some drastic stuff to increase the FPS. I’ve cut the draw distance a lot and am getting near 20 FPS, which is still too low. I intended to also add ceiling drawing and texturing which would cost yet more performance, so I may end up lowering the resolution/sampling even more. This probably won’t be able to render Minecraft, but could still work for a low-visibility-range dungeon game. Let’s see.
Have you tried using screenmode 13? It might be a little quicker and all of the math is 8bit and the update routine is ASM, on a static screen people have been able to get above 100fps. I assume that isn’t where your bottleneck is, but it might help a little.
Oh, so mine is already a bit faster. I’m using only integer math, can’t see anywhere to optimize anymore (but an experienced person could probably find something). I think I can pull off some hacks though. Will definitely try mode13 as @spinal suggests, thanks!