Download

Controlling opacity with brightness (Of an orbiting planet in the sky).

Hi everyone,

I’m trying to implement an effect where an orbiting planet up in the sky appears properly lit. So the side facing the sun is lit, but the side facing away is transparent. I’ve figure out how to make it be “dark”, but that’s not what a celestial body really does on the dark side. On the dark side, the atmosphere of the planet you are on is brighter and so you can’t actually see it. Like the way the moon looks when you see it during the day.

This is what I currently have:

Imgur

But in reality, the dark part of that sphere should be ‘transparent’, while the side facing the sun is visible. When I use translucency, the whole thing becomes unlit and doesn’t pay attention to the sun. I’ve tried additive, but that just makes the whole thing unlit. What would work best is if I could use the brightness values as a transparency level. I’m using the standard sky sphere for the rest of the sky.

Thanks!

In UE4 you can’t represent that scale fully, I would just use a premade image

First off, that looks awesome.

Second I don’t know exactly how you would do it in Unreal but I’ve done this kind of thing in photoshop a lot. It’s essentially making a flat dark color on a layer, turn that layer to a lighten layer and gradually increase the value of the dark layer if that makes sense.

I’m not very fluent with Unreal yet but I believe you want to use a Blend_Lighten node on a texture that is between your camera and the planet orbiting.

Perhaps something like a sphere mesh with reversed normals that contains a translucent texture with the color of the sky that lightens anything behind it.
The issue im seeing with this method though is because the node takes in two textures and outputs the result but we want something from the camera instead of a texture on a material. Maybe if you could somehow get the rasterized image from your camera as a 2d texture? That might be overcomplicating things, there’s probably a simpler solution. Gonna have to do some thinking.

Ah! Figured out a simple solution. I placed in an exponential height fog object into the scene.
Put my fog density to 0.3, height falloff to 0.001
opacity to 0.9
and start distance to 5000
and then shot the transform up to 30k on the Z axis so the fog doesn’t affect the ground below but it does mask out the planets shadowed sides.
That in essence should get you the effect you want, you’ll have to do some tweaking of course but I think it’s a pretty simple solution.

There’s fog on the ground in that screenshot but that was taken before I figured out there was a start distance parameter.

Alternate Idea: Change your skybox material’s bend mode from Opaque to Additive, and then place your Moon object outside of it. This more accurately reflects what you’re seeing in real life.

Complex alternate idea: Set up a light actor and gather the suns position vector into a material parameter collection, then use that to drive a dynamic opacity map, leaving you with something like this (This was just a quick mock up)

Material Parameter Collection:
4d4cb7324ed13d0995254abad53d6caf01964ee3.png

Light Vector Actor:
– Construction Script
2c56fe5ff1467464a60c728f471da5c3a8685226.png

– Event Graph
4e4b6244ca71de17178285fe5b2120bf900302f7.png

Opaque Material:
6b8a58c015cbdf32e597bc1b3ba4261b20be0b2b.png

Material Instance Properties:

these are both awesome alternatives

Very cool. Thank you all so much for the input. I’ll let you know what ends up working best, and I’ll post a screenshot!

As promised - some shots:

Imgur

Imgur

Thanks everyone for the help!

:open_mouth: that looks awesome!

Awesome, just the right stuff I was also looking to get any idea and answer, thanks for that! :slight_smile: