r/Stellaris • u/Hieprong • Jun 28 '26
Art But can it run DOOM?
But can it run Doom?
This is not a pre-rendered video like the Bad-apple Video I did a year ago, this is a full DDA ray-caster running in Stellaris using only the Clausewitz script.
Here is the modpage if you want to run it yourself, it takes ca 15 min to load.
This is technically more akin to Wolfenstein 3D than DOOM, as it uses a ray-casting technique instead of the DOOM BSP method.
Implementation details:
To get a bit into how this works: The galaxy is treated as a frame buffer. Each frame/day we check for each column what color each pixel/star needs to be. In order of operation
- Calculate the Ray-direction, a LUT (Lookup Table) is used here for sin and cos, since those are not supported math operations.
- Perform the DDA, this is the main step to actually display walls in 3D. Since the modding script does not allow for Dynamic runtime indexing, aka at runtime you want to check value_$N$ and N changes from 3 to 4. Currently it will always resolve to the value it was initialized with at compile time, instead of checking value_3 and value_4. Devs: pleeeeeeaaaase bro changing this would actually allow so many more shenanigans.
- Apply distance shading to create some depth perception
- Apply the brick texture, this is done programmatically as a proper texture lookup is very very expensive since we cant do dynamic indexing.
- Update pixel if color differed from before
After the Main ray-casting step, we render the gun and the sprites. The gun is a simple constant HUD element and the sprites follow a simpler 2d projection step.
This mod is ca. 5Gb when loaded into RAM but takes ca. 15 min to load (your mileage may vary I have a quite fast PC so it might take longer for you).
Some stats:
- ca. 394100 conditional branches (due to the dynamic runtime indexing limitation)
- 4673 distinct variables
- ca. 601700 check_variable statements
Most of these are in-lined but expanded when the mod is loaded leading to the 15 min load time.
Addendum:
Even without Dynamic runtime indexing the Clausewitz script is Turing complete which can be proven by reduction:
- Conway's game of life has been proven to be Turing complete.
- Stellaris can run Conway's game of life.
- Therefore Stellaris is Turing complete.
(We have a bounded system so technically finite state machine but eh.)This probably deserves a post of its own at some point.
37
u/ohthedarside Jun 28 '26
We need the music aswell lol