Home ยป The Forest and the Trees

The Forest and the Trees

Recently while thinking about my personal videogame project, I decided to have a production meeting with myself. I was thinking of what it would take for me to move from pre-production to production.

Well, my producer self told me, your creative documentation is not in place yet. Your ambitions for level design have recently scaled up but you have not done the work of envisioning what you need to build to deliver on these ideas.

Okay fine, my creative self said, I’ll start putting moodboards together and getting my thoughts in order. So I started doing image searches and saving reference photos that might be useful for my project.

One of the image searches I did was, lame as it sounds, “spooky forest.” This is a horror game set on a forested island at night so yeah, “spooky forest” was a place to start. And what I got was a ton of images that pretty much all looked like this:

This was not super helpful in part because I already had this working in UE5. Between the sky light, directional light, and exponential height fog, this is pretty much what my game currently looks like except about half as bright. I used a pale blue color for all the light sources which is pretty much cinematic moonlight.

But then as I looked over the image search I realized there was something I’d overlooked.

It was color. Looking across those images, there are blues, purples, greens, golds, and other colors, and they all give a very different feel to what is generally the same subject. I hadn’t considered varying the ambient light color beyond that initial cinematic moonlight.

My level will have about a half dozen points of interest that I’m calling Hollows. Each hollow will be a small environmental area with some interactivity and storytelling, but functionally each one can also serve as a trap to neutralize one enemy. (The player has no combat abilities in my game.)

I decided that each hollow should have a key color that will be expressed through a soft shift in the ambient color of night. I’ll then look for ways to pull that color into the environmental assets as well and possibly with some more saturated point lights.

So then I got to thinking about how to gradually transition the color of my level’s three main ambient light sources. Unifying them was no problem, that was just a variable for the hex value of the color. But with up to six different lighting states and the player’s ability to freely traverse among them, how should I go about slowly adjusting that color based on location and proximity?

I’m familiar with using lerp functions to gradually shift between two sets of values. But how should I lerp between six sets of values and not just getting vague muck as my ambient color?

I am sure that actual devs would have a straightforward solution, but I’m not a dev, I’m a hacker. I decided to just set an overlap sphere on each hollow and not allow the spheres to intersect each other. When you enter one hollow’s overlap sphere, it sets a new target color value and calculates a lerp between your current ambient color value and the one defined by that hollow. I don’t want this to necessarily go off on every tick or get stuck in a huge while loop, so I just call the lerp function whenever the player moves. The color updates only when your location changes. The closer you get to a hollow, the more the color shifts to its final state.

During my weekly game dev session I worked through all this and got some of the initial coding done. Then I realized I’d once again architected the code in a dumb way that would confuse me later and I redid a bunch of it.

(If you’re a UE Blueprint scripter, I’m trying to keep any changes to an actor confined to the actor’s own blueprint. Other blueprints can send events to the actor that tell it to make the change, but I am trying to avoid casting to the actor and making changes remotely. Otherwise when I’m debugging later, I won’t be able to find the code that changes an actor because it’s in some other blueprint I’ve forgotten about.)

My code isn’t fully functional yet and I have no doubt it will need iteration. I don’t want to have the color be at 100% only if you’re standing directly on the hollow, for example, so I need to clamp the lerp to ensure that half or more of the region defined by the hollow’s overlap sphere shows the true color.

Even when this all works, it’s possible the effect will be too obvious. I may need to desaturate my color choices a bit to keep it subtle: enough to set the mood, to increase the feeling of traversal and of there being distinct areas of the island, but not enough that it’s distracting.

Anyway, all of this is because I ran an image search, saw nothing useful, and then realized everything was useful once I let myself see the forest instead of the trees. And that’s really all I wanted to say this week.