Pokitto is on the way, what games should I make?

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!

1 Like

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


Very interesting article, thank you :slight_smile: Seriously cool how advanced the architecture was.

My point was only about the strictly mathematical mapping of pinhole projection and whether it has the property of always mapping straight lines to straight lines (which it does).

Apart from this there are always various distortions of course, as you say. For example circles are deformed to ellipses by the perspective etc.

1 Like

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

1 Like

Lodev covers textured raycasting later on, so it’s probably mentioned in that section.

Tangentially related: I’ve been to the temple of Knossos, but it was a very long time ago.


This is even the reason you cant see your eyes move in the mirror, every time you look away the brain cuts the blurred image away and will even substitute a older image. ( Saccadic masking)

1 Like

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? :smiley: 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 :slight_smile:

Just ran my raycasting on Pokitto, only have 20 FPS :smiley: 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 :smiley: (But programming by tutorials simply isn’t that satisfying.)


I bumped the raycasting FPS to over 30 by subsampling in horizontal direction twice – it’s half the rays to be cast and can’t practically be noticed (vertical resolution is kept the same).

BTW does anyone know where that wolfenstein raycasting demo is from? I’ve seen it running on Pokitto (e.g. screenshot here) but haven’t found the actual program.


Also I created a repo (very WIP):

1 Like

sorry to comment on this but your video is down.

I’ve done it. I’ll put it up somewhere

1 Like

Raycasting++ progress update :slight_smile: Gonna check Pokitto FPS.


EDIT: 15 FPS :sweat_smile:


looks awesome!!!

1 Like

Nice, I was under the impression that raycasting was strictly 2D, did it take much to the the extra floors in there?

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.

1 Like

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.

1 Like

Around 14fps but it is a straight port of Lodev’s version meaning it has no optimization at all for a non-FPU microcontroller (i.e. no trigonometry look-up tables, no fixed point math etc).

I know for a fact that it can be accelerated a lot with optimization and using mode13 would be faster as @spinal has already pointed out

1 Like

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!

Optimization just begins when all the self-evident stuff has already been done

1 Like