The Making of the Cloud Enhancement Pack - Part 1
Clouds have often been a neglected part of the Train Simulator world. Generic, ill-proportioned, low resolution, over-exposed, under-exposed; at least one of these words can usually be used to describe what has come before. Naturally, trains and railway infrastructure are always going to be the main focus of Train Simulator but considering the sky dominates the upper half of the scene, we think they are vital to providing proper immersion. As well as just being nice to look at, they also inform the player what the weather is doing, what it is likely to do and often the time of day too. In the creation of the Sky & Weather Enhancement Pack (SWEP) 2.0, I set out to see how far Train Simulator's ageing 'sky dome' system could be pushed to create something more realistic and convincing than had come before. I never imagined this would be the start of a 7 month project and what would be achieved. This blog is the story of that development. I hope you enjoy it.
16th November 2022. It’s a cold, crisp blue sky morning and SWEP 2.0 has been in development for a week or so. Late morning, cumulus cloud starts to appear but not the cauliflower-esque kind you might associate with a summer’s day, more the ragged/darker type you tend to get in the autumn/early spring. Just by looking at them, you know there’s a chill in the air. I know that Train Simulator supports different cloud visuals depending on season so I think, right, now is the time to nab some photos to give ‘Fair Cloud’ in autumn/spring a different flavour.
Where to photograph them though? Photographing clouds isn’t as easy as stepping outside the front door and pointing the camera upwards. In an ideal world, you want to be at the top of a hill, with an uninterrupted 360 degree panorama. Sadly, these kind of spots are hard to come by, especially in my local area, so I headed to somewhere I knew where there should at least be a 180 degree view and most importantly, facing north. It’s no good shooting into the sun with clouds for Train Simulator, you let the simulator handle the backlighting.
After a 10 minute drive, I arrive at my muddy field of choice and traipse across the stubble to where the view is as open as possible. It’s a good job there are no crops in the ground…! An hour or so is spent photographing the passing clouds. I do this by facing roughly east and taking a shot every 25 degrees or so until I am facing west. This is something I’ve only ever done once before for the ‘Fair Cloud’ seen in the original SWEP so I hedge my bets with different types of shots. Some wide angle for as much sky as possible, others more zoomed for extra detail and some right above my head for the underside. Before I know it, it’s 1.30pm, a large bank of cloud is heading in and a rumbling stomach is telling me it’s time to go home. I head back to the car, stomp off the mud clumped to the bottom of my boots and drive home to a sausage sandwich.
Muddy field |
With the aforementioned sausage sandwich suitably gobbled, it was time to process the photos. This is where a nifty piece of sofware called PanoramaStudio comes in handy. I’m sure there are many of this type but it allows you to take images taken in sequence and stitch them together to form a single image. Perfect for something like cloudscapes. With a few of those processed from the 1 hour shooting period, I then saw to implementing them in the cloud ‘texture’. For the layman, a texture is simply an image that is mapped (projected) onto a 3D model in the simulator, in this case, the hemispherical sky dome.
This is where I realised a bit more work was going to be required before being able to see the panoramas in the simulator. To date, the sky dome I had been working with, created way back in 2016 for the Wherry Lines route, duplicated the texture four times so you would see the same clouds every 90 degrees you turn the camera. This is an efficient way of doing things as it allows you to use a smaller texture size, which certainly made more sense in the days of 32-bit Train Simulator, but with the advent of 64-bit, larger textures are not so much of a problem. With this in mind, I increased the width of the texture from 4096 to 16384 pixels and remapped it accordingly in Blender (a 3D modelling program). Voila, a unique 360 panorama was now possible. The logic being that the texture wraps around the hemisphere and the two ends meet.
Example of a stitched panoramic image | |
Now that was sorted, it was time to clean up the panoramic images ready to be placed on the texture. As you can see from the image above, the horizon is not a clean, horizontal line but with indulating ground and trees at the extremities. For the purposes of the texture, all traces of the horizon need to be removed, which involves the following:
- Rotating the image so the horizon is as level as possible
- Cropping the image at the bottom to remove as many obstructions as possible whilst balancing the need to keep as much sky as possible at other points.
- Cleaning up the remaining obstructions by using the ‘Spot Healing’ brush in Photoshop. With this brush, you select the obstruction, it is then erased and the brush fills the void with an interpolated image of what surrounds the obstruction so it doesn’t look out of place. This has its limitations, especially with larger obstructions or if the surrounding image is detailed and varied. If you don’t look too closely though, it tends to do the job.
The same image as above but cleaned up. The dark blue cut-outs are where unwanted clouds have been erased. |
Each panorama has approximately a 180 degree useable view so two of these are usually sufficient for a full texture. One of the most difficult parts though is the two merges that need to take place between the panoramas to make them look like a seamless cloudscape rather than two separate images simply plonked next to each other. This usually involves quite a bit of trial and error with different panoramas taken from the same session, looking for two which have clouds of a similar height at each extremity so they can be seamlessly blended into each other. With that done, I now had a 360 degree panoramic cloudscape that looked good in the simulator but there was one problem, a problem that had made me reluctant to open this can of worms in the first place.
A blend between two panoramas. Also evidence of the spot healing brush having been used towards the bottom centre-left. |
It might be tempting to think that 2D photo-based cloudscapes in games/simulators are simple photographs but as has already been shown, there is more to it to even get to the stage where a photo, or sequence of photos, looks right. It’s no good just having a photograph though as a simulator is a dynamic experience. The sky and sun are controlled separately to the clouds and as a result, as much trace of these two things need to be removed from the texture. The sun is already tackled by using two 180 degrees panoramas photographed away from the sun but removing the blue sky and isolating the clouds is a whole different kettle of fish.
The most obvious solution to this is to simply select the blue sky using the magic wand tool in Photoshop. This allows you to click anywhere on the texture and whatever the colour value is at that click point, everywhere in that texture with a similar colour value is also selected. This method is fine but has one fundamental flaw in that it creates hard edges between the clouds and the sky. This can often end up looking too severe in-game. Selecting in this manner becomes rather laborious after a while too. I started thinking, there must be an easier and better way to select the sky, possibly even in just one click.
Enter saturation masks. The one attribute that blue sky has which varies most from clouds is not actually its colour, as clouds can often have bluey greys, but its high saturation. Saturation is how rich/vivid the colour looks. Using this very useful tutorial, https://goodlight.us/writing/saturationmasks/saturationmasks.html, it is possible to create a one-click process which turns the texture into a black and white image where the most saturated parts (the sky) are black and the least saturated parts (the clouds) are white. This can then be copied into the alpha channel. The alpha channel is the part of the texture that tells the simulator what to display, where white is fully transparent to black being fully opaque. Not only is this a simple process that only takes a few clicks but the transitions between the clouds and sky are smooth. It is by no means perfect, especially at the horizon where the sky becomes more hazy and less saturated, but it does a good job for the majority of the texture.
The alpha channel of the final texture, created using a saturation mask, with two 180 degree panoramas stitched together |
After that, it was just a case of loading up the simulator, seeing how the clouds look, adjusting their brightness/contrast to match the simulated blue sky behind and they were done. With the final result being much better than anything than had come before.
The only shot I have of these first clouds in action in Train Simulator |
I wondered whether there was an online resource available with a high quality set of panoramic cloudscapes so I could quickly replicate this without having to keep going out to do it manually. Sadly, nowhere seemed to offer the quality, variety and consistency required so there was only one thing for it, I set out to try and find a better location locally with a higher viewing point and fewer horizon obstructions to repeat the process with different cloud formations.
Sure enough, I did find a better location. Only 5 minutes away and with a much finer view. Over the next two months, 17 trips were made to capture different clouds. I realised that this was probably one of the worst times of year to commence such a project as the short daylight hours meant there were only really 3 or so hours a day where the light was suitable. In addition, during these coldest months, fair weather cumulus cloud is rare due to the lack of daytime heating which creates them so I was often solely going out for high cloud (cirrus) or overcast stratus.
A panoramic image from the new and improved location |
Photographing cirrus during this time made me aware of yet another problem in that Train Simulator only supports three separate cloud layers. They are named ‘wispy’, ‘thick’ & ‘storm’. The latter two obscure sunlight when active so only wispy allows the sun to shine whilst a cloud is being shown. With fair weather cloud already using the wispy layer, I had resigned myself to cirrus not being a possibility in the simulator. As with many things in the realm of Train Simulator though, it’s amazing what can be achieved with some jiggery pokery. In the blueprint (a file that contains the parameters of most objects/features in the simulator) that controls the clouds, you activate a cloud layer by applying a value of 1 to it. If you wish to hide it, you make that value 0. One day I had the bright idea of seeing if anything would happen when making that value -1 on the ‘storm’ layer. Nothing, the layer stayed invisible as one would expect. I then tried -0.5 and something more interesting occurred, the layer was half visible, as if I’d selected 0.5 but the sunlight was still fully visible. Thinking I was onto something, I then tried -0.01 and bingo, the layer was now fully visible, as well as the sunlight. Hurray! This meant I could allocate fair weather cloud to the usual wispy layer, high cloud to the storm layer with the special -0.01 value and overcast to the thick layer.
The aim from this point forward then was to have a unique cloud layer for each season and cloud type, so 12 unique cloud layers overall. Whilst this would still barely scratch the surface of the almost infinite variety of clouds there are in reality, it would provide some much needed variety over the existing fair cloud and overcast cloud types that were identical regardless of season.
Part 2 coming soon where we explain how this project transformed from being one of the many new features of SWEP 2.0 to a whole pack of its own, and possibly one of the biggest undertakings to date in an Armstrong Powerhouse product.