Spyke
gamedev·Game DevelopmentbySmokeyDope

Creating a Dynamic Skybox Scripting System For TerraManic (Dev Log #1)

cross-posted from: https://lemmy.world/post/36742987

Mapgen

While not the main focus of this post, I did want to share mapgen stuff. Im still learning and figuring out how to get stuff locked in visually. I learned how to create schemantics with world edit and use as decorations for first trees, I created some models in blender and decorated the ground with some sticks and stones.

Weather

I did start to play around with weather. I want to tie rain triggers to skybox changes and have like 'stormy days' that start cloudy and have a heightened chance to trigger rain or storm. Of course tie it into the seasons api too so that spring has lots of rain and winter triggers snow storms that freeze water.

On Skyboxes

The first big development project after wrangling the basics of world generation actually ended up being about skyboxes and celestial stuff. I want my game to stand out visually and one of the ways to do that is to make good use of skyboxes. They add a touch of beauty and realism. If you've ever played with shader packs in other voxel games you might associate them with a kind of "premium visual experience" that usually requires modding and performance losses with acompanying dynamical shadows. Luanti Handles these very well completely seperate of any dynamical lighting so even low end systems can enjoy

It seems there arent many luanti games or even luanti game makers players that know you can put skyboxes in. I just learned about it by chance searching on a whim and finding an 8 year old developer video by one of the old Luanti devs SoFar..

Stage 1: Basic Day/Night toggle

The first stage was just to get the skyboxs in the game and to not be static anymore. Thats the concept at its most foundational, get the skyboxes to change and the most simple way is to do that via swapping the textures on some trigger event. SoFars SkyBoxes module was released under a commercially permissive license (LGPL2) and so was used as a foundational base to build out from.

The obvious trigger event to me was the in-game time that determines day/night cycle. Day time should have a daytime skybox and night having a nighttime skybox. Simple as.

This was relatively straight forward though some bugs needed to be ironed out like the skybox not triggering automatically on reconnect. After that was adding in a few more like sunrise, sunset, and midday triggers

Skybox Image Modification

Adding back in the in-game rotating sun and moon made the skybox sun and moon feel a little wierd. To start I wanted a sun-less daytime sky and moon-less nighttime skybox so that the in-game sun and moon looks natural as it rotates.

The skyboxes are cut up into 6 tile sides that get projected onto a rotating cube. To take out the moon or sun we just find the tile that has them and do a little bit of bad photoshopping with GIMP

New Celestial Bodies In The Sky

Doing this gave me a kind of epiphany. While the engine doesnt allow multiple sun, moon, planets, we can hack in the illusion of them by creating custom skybox profiles that swap out individual tiles. Two key insights.

  1. Swapping tiles mechanic save us from needing to copy whole skyboxes for each little variant edit. We can potentially even use alphas and the engines texture overlay system to optimize the process instead of whole tiles just a skybox with a hole cutout for different celestial overlays.

  2. Combining the function of hot swapping textures in game with smart triggering conditionals paves the foundation for advanced scripting (moon visible during some days, supermoons, blood moons, alien planets, two stars of different size on different days)

So while we can only have one actual in-game moon and sun, we can edit skyboxes and swap sun+moon to custom textures based on scripting events. create a suprisingly convining facade. I really like when fantasy and sci-fi planets have two suns or three moons or a ring world, im hoping taking some inspiration there can help make TerraManic feel fresh.

Stratosphere Layer

If you aren't familiar with luanti but are familiar with something like Minecraft theres a big distinction that needs to be understood with how worlds work. Minecraft is many millions of blocks from one limiting x,z end to another, however its only a couple hundred Y levels deep from deepest point to highest buildable point. kind of a wide as a ocean deep as a puddle situation.

Luanti is the opposite. Its only 64,000 blocks from one limiting end to another (still plenty of room for exploration), however its also 64,000 blocks deep from highest to lowest point Y level wise. You spawn at Y=0 and can move up +32,000 or down -32,000 and build to your hearts content.

The challenge is of course making good use of all this new dimensional room. I have some really cool gameplay ideas cooking I dont want to spoil yet but a quick and easy win was implementing Orbital layer that triggers a skybox change at a certain altitude and alters gravity.

Im thinking of creating some asteroids or sky islands that generate up here in the first layer of the stratosphere. An interesting thing with the space skybox is that sun is always visible the two orbiting bodies appear to be moon and the strange planet. Its really cool!

Visibility Woes

The Orbital layer reveals that the bare bones day night cycle luanti engine provides has some visual wierdness. By default skyboxes either have something or they dont simple boolean toggle. If its visible it never really disappears though it will go under the horizon. When that horizon disappears it becomes hard to ignore and kind of immersion breaking seeing the moon go down below your feet into the earth or the sunrise texture teleport from one horizon to another.

So, the next API step was to add a way to make textures invisible based on predefined time of day triggers or custom defined cycles.

Orbital Rotation

The last celestial thing I played around with before writing this was orbital rotation axis. Having the sun and moon go directly over your head is a little boring and predictable. I wanted to make it so that theres some variation in tilt based on season, planet type, or distance from the equator. Thats some future plans for scripting!

View original on lemmy.world
No comments on the original post yet.
Creating a Dynamic Skybox Scripting System For TerraManic (Dev Log #1) | Spyke