How to increase video game immersion with self-made light automation

Bün Çolak
Jan 13 · 4 min read
PC gaming station

Cyberpunk 2077 has been delayed. Again. I cannot spend too much time playing games lately, so I was holding my quota for playing a long game for Cyberpunk. Since it got delayed, I bought a game that I wanted to play for a long time: Red Dead Redemption 2 (RDR2). Playing on PC obviously.

I downloaded the 120GB game, started playing and quickly realized that my lamps were too bright. Fortunately, I have Wi-Fi light bulbs that I could adjust to a very low warm white. But the first hour of RDR2 plays on snowy terrain where the warm white felt too yellow. So I decided to change the light according to surroundings to achieve better video game immersion — and it worked. But there was still one thing that kept bugging me: I had to configure the light by myself each and every time. Manually. In 2020. There’s gotta be a better solution, right?

The idea: increase video game immersion via light automation

  • gets the screen (aka the game environment) in every 5–10 seconds,
  • calculates the average RGB value of the pixels,
  • and automatically changes all light bulbs to that color.

Here’s what I came up with first:

Every color that you see on screen can be described with an RGB (Red, Green, Blue) value. In other words, every color on your screen is just a mixture of red, green and blue. RGB values can be between 0–255. For example, RGB(156, 48, 123) is a deep purple. Side fact: because of these RBG values, you often see “16M colors” in marketing claims. It’s just 256*256*256. Nothing really spectacular, it’s just how math works.

Anyway, thanks to a small library to communicate with the lamps, I have implemented the first draft. Communicating with the lamps is simple in theory. They work in Wi-Fi, they all use the same port. So if you use some analyzers like SoftPerfect to find out which ports they are using, you can interfere with that channel. But why do the extra work when I could just use the existing library? It was working quite fine with only one problem remaining — average color was not saturated enough. Hence, there was still room for improvement regarding video game immersion.

Optimizing for further increased video game immersion

But this isn’t the end of the story. Video game immersion is all about eliminating distractions which is what automated light changes contribute to. However, constant changes can be distracting too. In other words, you don’t want the light to change too fast or too often because that would be nothing but annoying. In my case, sometimes just when the program took screenshots there would be a character in the game zoomed in, which made the colors just that person’s clothes. To change that, I had to make another small adaptation to the code.

Simply, I have implemented a small test to check the difference between the last couple of samples and determine if the change was necessary. I used Euclidian distance to check distance, which is not ideal, but gets the job done. Overall, the code is neither amazing nor extraordinary, but it can be accessed here. It works with WiZ Smart Lights. If you have different ones, the code is clean enough to change the library for different bulbs.

Automated light for better video game immersion: the demo

So, although I’m still playing RDR2 while waiting for Cyberpunk 2077, at least my automated lights leave me better prepared than ever.

Join Motius Talents Teaser
Join Motius Talents Teaser

Motius.de

We are an R&D company that is specialized in the newest…