Mode7


The rendering technique in "Moduls7" is an old pesudo-3d rendering  method commonly known as Mode7.

"Mode7" is a software rendering mode where lines of an image can be drawn somewhat freely. This allowed games like Mario Kart to have look-alike 3d effects on hardware that was distinctly 2d.


It works by scanning across the screen line by line and computing which pixel should be read from a backing texture. For "Modulus7" a texture might and its level might look like:

The renderer takes in a camera position (x,y on the texture) and a rotation (angle 0-360) and for each pixel on the screen below the horizon computes the x,y, that pixel should appear. Initially this was based on a port of a mode7 software renderer, which used web workers and canvas. For learning experience, I then ported the code into WebGL so that it could run in a hardware-accelerated shader. This is somewhat ironic, as WebGL is more than capable of being used to implement full modern 3D graphics. But it's instead being used to simulate a 2d rendering technique from the SNES. 

The main body of the Web GL fragment shader is attached above. It converts each screen pixel onto a position in a texture for "mode7" simulated rendering

Leave a comment

Log in with itch.io to leave a comment.