Cosmic
This (work in progress) demonstrates how to extend my limitless terrain generator (as in The Forest - see my itch page) to 3D space. It generates nebulae as volumes of gas of varying density. Stars of varying magnitudes and with varying numbers of planets are found at some 3D positions. Click near any star to see its propertes.
This has been inspired by the Week Sauce (May 2023) Jam with the theme "Cosmic Wonders". It has taken about 4 days to write from scratch, making some use of previous code. It is not a game but rather a means of generating a cosmos in which games might take place.
It is written in vanilla Javascript using a simple 2D canvas. A downside is that the 800x600 pixel view takes about 15 seconds to draw (in Firefox, Windows 11, Surface Book 3) because it is probing 300 light years depth (screen scale is supposed to be 1 ly/pixel). But then, even if we could travel at a sizeable fraction of the speed of light it would take many months before the perspective view of such things would change noticeably.
The source code is all available (below). Others may like to take the ideas further.
Note that it is not the drawing of the graphics that takes time but the exploring of a block of space 800 x 600 x 300 light-years. I am therefore interested in SYCL (search for that) as a means of parallelising the generator rather than the graphics. I think SYCL has more potential than WebGL or WebGPU for this kind of thing.
For programmers interested in the source files, try the following exercises relating to the initial view.
1. Display the average density of stars as a (very small) number per cubic light year.
2. How far is the nearest visible star and how many planets does it have?
3. Display a table of the numbers of stars for each of the possible numbers of planets.
4. Demonstrate that there is no correlation between star colour and number of planets.
Status | In development |
Category | Other |
Platforms | HTML5 |
Author | grelf |
Tags | 3D, Experimental, Procedural Generation, Space |
Leave a comment
Log in with itch.io to leave a comment.