[WIP] SkyBerron 2.5d Raycasting

This is a 2.5d raycasting tech demo I have been working on for several weeks. It’s still very buggy, slow and lacks a lot of features, but I think it starts looking good.



SkyBerron Raycast.bin (153.7 KB)


I hate to be the one to bring it up, but as good as all these tech demos are,
they’re of little use to anyone if you never publish the source code.


Looks really good! Are you using 12-bit colors directly? Do you experience any flickering on HW?

There are 15 different textures, each of them having 128x128 16 colors. There is one custom 16 color palette per texture. For each main 16 color palette, there are 16 fade to black palettes for lightning based on distance. So although I’m currently targeting 220x176 65k colors, I suppose only just a few colors of the full 16 bit color space are in use.

There’s some flickering on emulator due to low frame rate and rendering bugs, mainly missing wall hits due to bad calculations.

1 Like

Looks very promising! A little bit of an fish eye near the walls and DDA somehow passing through corners, but I suppose these will be easily fixed. I’m very curious about the colors and performance of the final result.

1 Like

Thanks. I know the ray to 2d grid intersection calculations are pretty buggy, I may have to rebuild math from scratch before going into clever performance tricks. I love optimizing code for performance and size and I have already got some tricks pushing in my mind to be taken into code. I expect performance and smoothness should improve a bit, but colors and look will stay the same, unless I get mode7 floor texturing working without a high performance penalty. I may reduce texture size from 128x128 to 64x64 to make room for more assets, but I’m still aiming for a tech demo, not even a full engine. Feature wise, the raycast engine I’m using is 2d grid based, so it is way simpler than yours and allows less features. It may be like comparing Wolfenstein 3d to Doom in every aspect.

That math already exists and is pretty optimized, look for raycasting DDA algorithm – if you implement it, it should solve you missed intersections and the fish eye effect, and should also perform better (it avoids branching etc.). My implementation is here, but it’s full of macros and other stuff, you’ll better take a look e.g. at this.

It looks like you’re using distance fog but lighting all walls the same. In addition to the fog have walls facing in different directions lit with different intensity to add more sense of depth. Like this:

When you have it debugged you try to add more effects for beautification, e.g. wall height dimming, or wall reflections on the floor, which is cheap and easy – I’ve done it in one of my demos (you can see it on the gray floor):

Your high res, high color achievement has a potential of being the nicest looking demo so far, so that’s a nice motivation to keep you going.

Also if you could share the code I’d help you look for optimizations, I have been working on optimizing my raycaster for a long time now and know the spots and tricks to save cycles.