Blomst : sunlight and fresnel
All right! This will be the third, and probably final, post in the serious on various technical stuff and graphical effects in our jam game, Blomst 🌻. You can also check out part one about procedural planets and part two about shader effects!
Go here if you want to play Blomst 🌻!
In this one, the subject is lighting! Plays both visual and functional roles in this game.
The fresnel (or rim light) looks nice, but it also makes it a little easier to see where things are on the dark side of the planet.
The sunlight not only illuminates the planet and brings out its eventual colours, but also makes plants grow and produce seeds when facing them throughout the cycling days on the sphere.
Rim light
No matter how dark the planet itself is, there is always a little bit of "backlighting" on the plants and the character to make them pop out and help the player find their way around. And it looks neat too! There is also one on the whole planet itself.

The effect is actually quite simple in theory, but requires a little bit of shader work. What it basically boils down to is shining a light at the object from behind, exactly towards the camera, so that some light ends up creeping up along the sides, giving that characteristic look with glowing edges:

And indeed, if we look at it from a different angle than that of the camera that the rim light is pointing toward, we can see how the opposite side is just entirely washed out by light:

The trick lies in the fact that the rim light always points straight at the camera, so if the camera moves and rotates, so does the rim light, and we never actually see the washed out side, only the glowing edges, making the effect work. Cheap but pretty trick!
Sun
This is even simpler. The sun is just a regular directional light, and works with a little bit of cheating, as it is actually the sky and sun circling the planet rather than the other way around, the planet's transform being the parent of these two, so that they follow along with it as it turns (another cheat here, you see—it's technically the planet rotating while the character stays in place as the player moves!).
Every time the sun completes a full 360° rotation, the game counts a new day, and as the sun passes over plants on each day, they grow or might produce seeds depending on their current state.
The solution was to use the same maths that are also used in shader to calculate the actual lighting. The N•L calculation does the trick, as the dot product between the surface normal and the direction of the light represents how directly the light is shining upon the geometry, and how much it should be lit, as demonstrated by this figure from here:

Using the same calculation in the game logic, I could check whether the sun was passing over a plant, and have something happen to it, such as this "sapling" flower growing into its fullest as a new day dawns upon it:
