Isolating clouds while preserving atmosphere color contribution

Started by N59, November 12, 2019, 05:21:02 pm

Previous topic - Next topic


Hello there!

I'm fairly new to Terragen and can't figure out how to isolate clouds from the rest of the scene. I'm looking into creating a layered sky system for a game that would need the background atmosphere and the clouds separated from each other, in order to accommodate independently rendered stars and auroras. These effects are both animated shaders, and for obvious reasons need to be behind the clouds, so isolating the clouds from the background atmosphere is a must. (and combining everything into one normal skybox texture unacceptable)

Now onto my problem. The obvious answer would be to uncheck Enable Primary on the atmosphere layer, but as per the title this gets rid of any contribution the atmospheric haze and such has on the clouds' final color. Another solution would be to do that, make the clouds white, and then use that as an alpha mask for the full rendered sky with clouds, and render the atmosphere without clouds separately. However this is less than ideal, because it means changing the properties of each cloud layer every time I want to create the mask, increasing render time due to having to render two extra images, and also losing out on some of the fine detail in the shapes of the clouds.

So the ideal solution would be to have Terragen natively render the clouds without the background atmosphere, or essentially only rendering the atmosphere if the raytrace hits something that isn't the actual scene background. But I can't seem to figure out a way to do this? And the more I investigate it, the more I'm worried it's not possible.

Any advice or suggestions would be appreciated.


Terragen lets you render separate atmosphere passes, which you can then combine in the game engine with Additive and Multiply blending modes. You need to add a Render Layer node into your scene and connect that to the Render node, then enable the Extra Output Images.

In the Render Layer node you'll find check boxes for the passes you want to output in the Render Elements tab, which will be saved in individual directories to where ever you've set the render path in the Render node.

Terragen works best with Add and Multiply rather than a 'traditional' Alpha Channel due to the way semi transparent layers interact, which will be important to get soft edge masking with atmospherics. Think of it the way stained glass masks and lets through certain colours of light, so the alpha channel in TG is 3 colour rather than 1 channel.

In your case, I would render a plain atmosphere, ie no clouds which you would use as your base layer. Then render out your cloud passes. Cloud Alpha you would multiply blend over your base layer, then add blend both Cloud Direct and Cloud Indirect over the top of that. You can probably combine those last two passes into one pass to save texture and geo memory space.

These passes are supposed to be used in a Linear light workflow, so if you're using a typical non-linear workflow, you'll need to gamma correct your passes to look right.

And if you want to be clever with objects flying through those clouds, you can use the Cloud Depth pass to determine z-depth.


Ah, thank you! Render layers were exactly what I needed, just didn't know what to look for/what to google. Thanks for the technical info as well, that'll be really helpful later on.


Quote from: Hetzen on November 12, 2019, 05:45:35 pmCloud Alpha you would multiply blend over your base layer, then add blend both Cloud Direct and Cloud Indirect over the top of that.
Actually I think I'm missing something here. Cloud alpha is three b/w opacity masks mapped to rgb with no alpha. Multiplying the black parts is just gonna make the sky underneath black. How is that useful?

Yeah there's something I'm not getting. This is the result of the base * alpha + direct + indirect calculation:

Whereas this is the actual image:


Do you need to combine the Terragen sky with any other game elements inside the atmosphere, or will they all be outside the atmosphere (moons, planets, stars etc.)? If they are all outside the atmosphere there is a simple way to make this work. You can render your sky as normal in Terragen, and make sure to output the Alpha element. Not the cloud or atmosphere alpha images, but the main Alpha element that includes cloud, atmosphere and anything else in the scene. If you invert this Alpha image you have an image that is the transparency of the clouds and atmosphere. It'll be black where the clouds are, orange/yellow near the horizon, and close to white at the zenith. You can multiply your stars by this transparency image. Then you can add the Terragen render on top of the multiplied stars (or add the multiplied stars on top of the Terragen render), you just need to make sure they are combined using addition.
Just because milk is white doesn't mean that clouds are made of milk.


Yep, sorry, missed you need to invert the Cloud Alpha pass. And also didn't get into how to deal with objects beyond the planet atmosphere, which Matt's just covered.

Edit: I also didn't get into compositing the atmosphere correctly either. Because the atmosphere will add haze to distant clouds.

It's been a long day.


Here's an example:
Just because milk is white doesn't mean that clouds are made of milk.


Yeah so inverting the alpha textures definitely makes them a lot more useful. Surprised I didn't figure that out already, but I haven't slept in 19 hours so I probably shouldn't be trying to learn rendering software anyway ha (I'm more on the art side than the technical)

I am a little worried about having to dedicate entire RGB textures to just masking/multiplication given our performance budget, but the inverted main alpha mask seems to work well as a gray scale. Cloud alpha not so much, I'll have to play around with that. But in any case this certainly seems a lot more doable now, thanks for the help guys