Page 1 of 1

night rendering with eye adaptation

Posted: Fri Feb 15, 2019 9:30 pm
by trad_emark
TL;DR
Use eye adaptation algorithm to make the game better visible during night.

What ?
Human eye consists of receptors of two types: rods (tyčinky) and cones (čípky).
Rods are responsible for brightness and are active all day, but especially useful at night.
Cones are responsible for colors and are active at day only.
Eye adaptation is process where rods become more activated and cones suppressed (day to night transition) and vice-versa.
The result is that rendering night scene is not about reducing brightness.
Instead, in computer graphics, night scenes are usually rendered with:
- desaturated colors
- hue shift towards blue
- sharper lights/shadows

I made a quick test with a screenshot (note that the final results could be made much better):
factorio-2.png
factorio-2.png (611.84 KiB) Viewed 1924 times
vs.
factorio-1.png
factorio-1.png (779.66 KiB) Viewed 1924 times

Eye adaptation is usually made with a luminance-gather pass, where luminance is averaged over the whole screen, than weighted with luminance from previous frame and finally it is applied to the color buffer as a desaturation and hue shift. The weighting is asymmetric, bright-to-dark adaptation takes up to 20 minutes IRL and dark-to-bright takes 2 to 5 minutes.

In factorio, the luminance-gather pass could probably be replaced with estimation based on the number of currently active lights in current scene.

Why ?
Factorio is not a horror game and day-night cycle is minor game mechanic, therefore it should not stand in the way of general playability.

Re: night rendering with eye adaptation

Posted: Fri Feb 15, 2019 9:43 pm
by quyxkh
Combining this with implicit moon phases could be pretty cool, nights slowly cycle between your-eyes-adapt-pretty-well to you-can't-see-past-your-headlamp ... and "they mostly come at night" would get a hell of a lot scarier.

Re: night rendering with eye adaptation

Posted: Sat Feb 16, 2019 9:32 am
by BlueTemplar
Interesting, I don't think I've ever seen a game with a hue shift towards blue at night, and it was my understanding that we tend to perceive the rod "color" as just luminance (grey) ?

Sharper lights/shadows sounds great !

Note that this has already been discussed several times in the FFFs, but in the relation to the Nightvision equipment - it seems like you would want to remove it completely ?

Re: night rendering with eye adaptation

Posted: Sat Feb 16, 2019 9:59 am
by darkfrei
How about science packs on the belts? They are have same color, somewhere between white and blue.

Re: night rendering with eye adaptation

Posted: Sat Feb 16, 2019 3:28 pm
by trad_emark
BlueTemplar wrote: Sat Feb 16, 2019 9:32 am Interesting, I don't think I've ever seen a game with a hue shift towards blue at night, and it was my understanding that we tend to perceive the rod "color" as just luminance (grey) ?
The hue shift is very slight IRL so most games ignore it entirely. I have mentioned it for the sake of completeness.
Note, the colors are desaturated (turned gray) but not entirely. It should also have a slow transition, so the hue shift might be more apparent during those phases?
BlueTemplar wrote: Sat Feb 16, 2019 9:32 am Note that this has already been discussed several times in the FFFs, but in the relation to the Nightvision equipment - it seems like you would want to remove it completely ?
I do not have a strong opinion about the night vision equipment apart from that it is not available at the beginning of the game.
quyxkh wrote: Fri Feb 15, 2019 9:43 pm Combining this with implicit moon phases could be pretty cool, nights slowly cycle between your-eyes-adapt-pretty-well to you-can't-see-past-your-headlamp ... and "they mostly come at night" would get a hell of a lot scarier.
It could probably be made controllable by mods :D
And the night vision equipment would actually benefit the player during the dark-moon phase.