Attempt to run real-time 3D shaders on Game Boy Color

Engineer Danny Spencer has unveiled a real-time 3D shader that calculates and moves the shadows of 3D-like objects in real time when light is shone on them on the Game Boy Color. As the object rotates and the light moves around it, the light and dark areas change on the fly.
I put a real-time 3D shader on the Game Boy Color | Danny's Blog
Real-time Shader for the Game Boy Color - YouTube
Rather than drawing polygons in earnest, Spencer's aim was to fit the minimum configuration necessary to achieve a 3D appearance within the capabilities of the Game Boy Color. Therefore, he first checked the atmosphere of the shadows using 3D software on the PC, and then created materials that would match the display of the game console.

Specifically, the orientation of the object's surface is written out as an image, and a sequence of images is prepared. The Game Boy Color then quickly references and displays the images created in this way.
The concept of shading is simple: how bright something appears is determined by the relationship between the orientation of the surface and the direction of light. The key point is that it starts from a basic shading model like

The difficulty was the calculation cost. The Game Boy Color's CPU had limited capabilities, and it couldn't make heavy use of calculations like multiplication and floating-point numbers. So Spencer decided to use a method that referenced a pre-made table. In other words, instead of calculating exactly each time, he looked up the necessary values from the table and used addition or subtraction to approximate the results as long as the visual appearance remained stable. As a result, he was able to reduce the number of steps required per pixel.

The drawing process is also tailored to the display characteristics of the game console, and because it is difficult to redraw the entire screen in one frame, the screen is rewritten tile by tile while calculating the range that can be updated in the limited time. The conditions that tend to cause afterimages and flickering are also used to their advantage to create the illusion of movement.

Spencer also used a technique to rewrite some of the instructions during execution, replacing slow processes with faster ones. This low-level optimization cut down on the processing time of the heavy parts, allowing for updates that appear to be real-time.

While the AI was useful for creating auxiliary scripts, it proved difficult to generate accurate optimization code for the Game Boy Color's assembly code, and the code ultimately had to be fixed by hand. Spencer explains, 'A small mistake in the AI's conversion process caused the color sequence to become distorted, and it went unnoticed for a long time.' He emphasizes the importance of testing the AI's algorithms while also highlighting its usefulness.
Spencer has released the real-time 3D shader he developed for the Game Boy Color on GitHub.
nukep/gbshader: A real-time shader demo for the Game Boy Color!
https://github.com/nukep/gbshader
Related Posts:







