Have a peek into the developers mind and let us know your thoughts.
Post Reply
finn
Posts: 9
Joined: 13 Dec 2017, 19:02
Contact:

Log #5: Lighting in the game, present and next (23/3/2018)

Post by finn » 23 Mar 2018, 14:00

BY FINN

My name is Finn and I am the "main guy" behind Mechanic Miner. I have worked on and off in the Danish gamedev industry since the original Hitman game nearly 20 years ago, has a programmer and technical lead. Among other games I have been involved in, is platform puzzler Limbo. Mechanic Miner came into my head around that time and I have worked on it ever since.

An important part of the game's visuals is the dithered lighting. Because we are currently preparing to make a playable underwater biome, we will have to add some features to the lighting system.

In this part I will explain a little about how the lighting system which is currently in the game, works.

I originally got the idea to using dithering (i.e. the checkerboard-like patterns with enlarged pixels) from Lucas Dupope's devlog on his new game Return of the Obra Dinn. This game is really hardcore in that respect, because it uses only black and white pixels in an attempt to create a retro look, which makes you think of an original Mac Classic (which only had a two color display). Dupope coined the phrase "dither-punk", which I think is a quite fun and fitting term.

So Mechanic Miner calculates and renders light as a combination of dynamic and static lighting. The actual resolution of light is very low, with one light value for every 7x7 pixels, which we call a block. When I say pixels, I mean the enlarged "pixelart" pixels, not actual screen/device pixels.

Here we have a scene in the sand caves - first without any lighting applied:
scene1.jpg
scene1.jpg (65.38 KiB) Viewed 1101 times
The lighting comprises of calculating a light field (in the very coarse resolution mentioned before), which is then filtered and dithered before rendering.

The first component in the light field is simple static ambient light:
scene2.jpg
scene2.jpg (15.8 KiB) Viewed 1101 times
Adding to that we have the static light beams, which appear in caves close to the surface. These beams make it a bit easier to see what you are doing, and also add to the mood/atmosphere:
scene3.jpg
scene3.jpg (17.75 KiB) Viewed 1101 times
Finally, dynamic lighting is added, here from the candle. Notice the gradual falloff with distance. The dynamic lights are actaully done by raycasting (in this very coarse resolution) from each light source, calculating falloff and checking if/when each ray hits some terrain:
scene4.jpg
scene4.jpg (19.62 KiB) Viewed 1101 times
This coarse lightmap is the basis, and it then goes through two filters before it is rendered.

The first is blurring, a simple boxblur filter, including some scaling and cropping of min/max values:
scene5.jpg
scene5.jpg (24.5 KiB) Viewed 1101 times
Secondly, it is rendered with normal bilinear filtering using a dithering shader to an offscreen buffer, which is then rendered to the actual screen:
scene6.jpg
scene6.jpg (83.72 KiB) Viewed 1101 times
And this is it - it is a quite simple lighting scheme, which has served us well so far. For the underwater biomes we basically want the lighting to some extent to interact with the machines (like a submarine) - but the lightmap's current (low) resolution makes that hard to do. So next time I will get into how we would need to change/add to this basic system to achieve the lighting we want for this kind of setting.

Do feel free to comment here below. We would like to hear your thoughts.

Thinzy
Posts: 10
Joined: 26 Feb 2018, 18:32
Contact:

Re: Log #5: Lighting in the game, present and next (23/3/2018)

Post by Thinzy » 23 Mar 2018, 16:58

very interesting!
Mechanic Miner Discord Moderator

Pizzaernam
Posts: 0
Joined: 23 Feb 2018, 17:03
Contact:

Re: Log #5: Lighting in the game, present and next (23/3/2018)

Post by Pizzaernam » 27 Mar 2018, 14:48

This is so freaking cool! I cannot wait to hear more about how you make the lightning more dynamic in an ocean biome.

The current lightning scheme sounds a little demanding, are you updating lightning realtime (every rendered frame) or are you baking in the lightning. I understand that it is not a big problem for a small veiwing area (zoomed in), but what about when you are zoomed out?

-Pizzaernam
- Pizzaernam

finn
Posts: 9
Joined: 13 Dec 2017, 19:02
Contact:

Re: Log #5: Lighting in the game, present and next (23/3/2018)

Post by finn » 28 Mar 2018, 11:25

Thanks:-)

The ambient and static lighting (the lightbeams) are baked, but the dynamic light sources are calculated and raycast every frame. The blurring is also done every frame. Because of the low resolution of the light field, it is not really very demanding atm.

Pizzaernam
Posts: 0
Joined: 23 Feb 2018, 17:03
Contact:

Re: Log #5: Lighting in the game, present and next (23/3/2018)

Post by Pizzaernam » 28 Mar 2018, 12:47

Okay, thanks for clearing that up :)

-Pizzaernam
- Pizzaernam

Magesit
Posts: 1
Joined: 03 Jul 2019, 11:34
Contact:

Log #5 Lighting in the game present and next 23/3/2018

Post by Magesit » 19 Jul 2019, 10:06

Looking at the .LUA files, it looks like the game calculates some kind of economy stat at 90 kph, 120 kph, 70 kph, 50 kph, and 30 kph ... but like NormanVauxhall said, details are coming in the next update.

Post Reply