Dev Blog 3: Environmental system, and the problem with snow.

Great progress has been accomplished lately with the development of a few core elements. A few weeks ago, the grader has been completed. At least, phase 1 of it. Which means it is now fully drivable with main systems working: lights, blade, wing and leaning front wheels. I wanted, initially, launch it without putting more details into it, in order not to loose any time on non-essential details and carry on with the development of other features. Sort of a way to expedite the launch of other core game features.

Future phases of the grader development will eventually include (Not necessarily in that order):

Systems update: Fuel management, engine parameters, maintenance, etc.
Aesthetic update: Textures implementation, decals, dirt, etc.
Interior update: Cabin interior and 1st person view driving.

The problem with snow.

Here’s the problem with snow: it is made of billions of particles that collide with each other and with the environment. In other words, something unmanagable for a computer. At least, not at runtime like we need in a videogame. So the challenge was to replicate that behavior in a way that a computer can calculate in realtime. Some funky stuff have been tried in the past (see Dev Blog 2 for interesting ugly ideas), and I came up with this solution:

Particles are indeed being used, but only for visual effects: snow precipitations, blowing snow and mist, and are being destroyed after a few seconds, keeping the count to a managable number. That way, your computer will be able to run it smootly. As for the snow accumulations on the ground (the part that we are interested in plowing), the terrain is actually covered with a snow-textured 3D layer that interacts with triggers coded in the plows, wheels, and anything that is meant to deform the snow surface. Those triggers are coded in a way that they will instruct the snow layer to either rise of lower. For example, a few inches in front of the blade, the snow layer will rise as it piles up, but underneath the blade, it will lower to 0. On the side of the blade (the side the blade is oriented), the snow layer is instructed to rise to simulate a windrow… which can then be removed by an other plow, for example, the wing.

A windrow piled up by the main blade. The effect is made by graphically deforming the snow layer and changing the texture.

In addition, the snow texture is modified depending on the height of the snow. So when it’s at the normal accumulation height, it has a fresh and even snow texture. But when it’s being piled up by the plow, it has a rough, uneven texture.

The snow effect is then completed with a bunch of weather effects, physics materials and scripts to make it, and the snow plow, behave as it should.

Weath… I mean… environmental system

I then got working on the weather system: the core engine that would get the information on what kind of weather is desired (for example light winds, moderate snow precipitations), and get all the effects working to properly simulate the weather conditions. That also implies some side effects. Like strong winds = blowing snow. Or heavy snow = low visibility. That engine is meant to take all of that into consideration.

The logic table of the input values, and the output conditions.

Then, it hit me: we need a day/night cycle. The initial idea was to play at a given specific time of the day depending on the scenario. But then I realized having a day/night cycle would add a whole new dimension to the gameplay and a lot a realism. I had a discussion with my partner on this project and we spoke about what kind of time scale would be the best. In other words, how much time a whole day in the game would take in real life.

For example, in The Sims, 1 hour in the game takes 1 real minute. So a whole day in the game takes 24 minutes (if you don’t speed up). That’s way too fast for our game. I was thinking about something like 1 real hour for 1 day in the game. After our discussion, we agreed on the same time scale they use in GTA: 48 real minutes for a whole day in the game.

Now that we knew our day cycle in the game would be 48 minutes, we needed several things to be coded: Procedural skybox (A picture skybox won’t do it, as the sky has to change as the day goes by), a sun orbiting, a moon orbiting (yes, moon lighting!), and a global illumination (GI) that follows along (ok I’m getting a bit technical here…).

Now that our weather engine was getting intimately linked to the day/night cycle, I changed the system name for “Environmental System”. A lot of work! A lot of learning. Many many google searches. And now, the result: a complex but fully functional environmental engine. On demand snow storms, and a beautiful day/night cycle.

The weather module inside the environmental engine, showing the complex relationship between each parameter that define how the weather will render on screen.

If you want to see more pictures and videos, see the “Media” section of our website. It is regularly updated with the latest content.

Those dev blogs will be put out on a regular basis when new content is added to the project, for those who are curious to see a bit more about what’s going on. Until next time, you stay safe and healthy. Cheers!

A sunset during light winds, light snow conditions, all generated by our new environmental system.