A raycasting engine with ambient light, dynamic observer light source.
The map and textures are from the mother of all first-person-shooter game Wolfenstein 3D. Wolfenstein 3D was groundbreaking in 3D using raycasting for low performance machines (by today’s measures).
This raycaster is made in Go (Golang) and use the UI library Fyne for window and image display.
To compile this application using go you need to first install Fyne. Installation instructions are found at their website.
Then type
go build -o wolfensteinmaze cmd/main.go
to build the executable binary.
Or run the application immediately by:
go run cmd/main.go
An excellent source of information on raycasting can be found on Lode’s Computer Graphics Tutorial - Raycasting.
I have written my own summary on the raycasting principle and algorithm.
A quick run through the maze and some final toggles of the rendering options for lights and textures.
Screenshots from running the maze using map (level 0) and textures from Wolfenstein 3D.
Render option | Valid values | Description |
---|---|---|
Ambient |
LOW, FULL, OFF |
The omnidirectional surrounding lighting. The always-surrounding light level if you like. |
Observer light |
ON, OFF, ANIMATED |
The dynamic light originating from the observer running the maze. When animated, the light is supposed to look like a light coming from a burning torch. |
Texture |
ON, OFF |
Using textures from Wolfenstein 3D. When OFF, the color used for the wall is the mean color of the texture. |
Note
|
The vertical red line in the middle, when using textures, is intentional and marks the middle pixel column of the screen/viewport. It is useful when running the maze and see where you are heading and aiming for. |
Note
|
The FPS (frames per second) counter show a relative low frame count. That is because I use the Fyne UI library to show the rendered frames/images. Fyne is not aimed to be a game render library but a common application UI. |
Information on how the Wolfenstein 3D map data is stored, structured and parsed can be found on the Wolfenstein map page.
To regenerate the map image, activate the test TestPaintWolfensteinMap
(remove the skip-test call at the start of the test) and then run the test.
$ go test -run TestPaintWolfensteinMap ./…
You can also generate a map at the console using the test TestPrintWolfensteinMap
(remove the skip-test call at the start of the test) and then run the test.
$ go test -run TestPrintWolfensteinMap ./…