Planetary atmosphere shader

How can I achieve this effect in blueprints?

.shadertoy.com/view/lslXDr

Ideally I would like to co-op the existing atmospheric shader in UE but I only see the atmospheric fog and it doesn’t show anything when I apply it to a mesh.

You can create a distortion effect with world vector transform refraction.

Give me a few minutes and I will get something up for you.

So I looked at the behavior in the link you posted and built my own version using just the math nodes. (Trying to stay away from any code whatsoever).
Hope you enjoy it :slight_smile:

The eclipse parameters work in world space, so they will need to be hooked up to your blueprint to work with your views.
P.S. - All parameters and values may be changed to achieve different atmosphere colors, falloff, power, influence, shadow blend, and more.

5 Likes

I think I just fell in love with you. I needed this, thanks!

JBaldwin strikes again lol ;). I also needed this. Thanks a million for the great community support :D.

No problem :stuck_out_tongue:
Glad you are finding it useful.

Now we just need a multi-scattering solution for when the camera is inside the atmosphere :stuck_out_tongue:

Awesome work.

@n00854180t - You mean like height fog? o.o Cause that is a good solution (Unless you want to create a planet where you can enter and leave the atmosphere).

Wouldn’t it work if you increased the multiplier for atmospheric fog depending on your distance to the surface of the planet?

Btw, thanks a lot Jeremy! :slight_smile:

Yeah I meant for the case where you are inside the atmosphere standing on the surface.

I’d have to look into the whole thing again, but when I implemented a scattering sky the last time, it seemed like there were some differences between the calculations for in-atmosphere vs out-of-atmosphere which were more than just the camera position/view vector.

@Jacky - Anytime :slight_smile:

You guys may find this useful. There should be a material function in engine called SphereGradient-3D. it has a Boolean to do extra math checks for when the camera is inside of the sphere. I am sure it would take some minor fiddling to make it work with JBaldwin’s eclipse (very nifty by the way sir!).

It is based off standard sphere-camera intersection math. I sometimes use it combined with the ExpentialDensity material function which gives a nice natural looking fog sphere.

1 Like

@RyanB - Very interesting! I will have to fiddle with that and see what I can come up with :slight_smile:

Hey guys, sorry to bump the thread again.

JBaldwin - Thanks for implementing that shader, I was about to try and take it on but I still struggle converting Math into Nodes :frowning:

If you don’t mind I’d like to pinch it for something similar, but I need to make some changes that I need help with. In my situation, I’m always going to be above the Earth orbiting around it. The Earth is always going to be at 0, 0, 0 in my world, while my ‘Sun’ object is at 500,000 units in the X Direction. How can I set-up either the Blueprint or the Material so that the eclipse is always in the correct position? My world IS a Multi-Player one, so doing all the maths in the Material would suit me better.

I’m also getting some strange banding on the sphere when it reaches a certain radius, not entirely sure where they’re coming from. I’m also assuming you’re applying the material as an additive one to a sphere slightly larger than the one you want to create the atmosphere around? That’s how I’m doing it right now, see below for the issues I’m having. (I’m using the default material sphere for the Atmosphere, setting the Scale to 150.0 Units to give you some size reference).

You can see the banding on the bottom left area of the sphere, perhaps I’m just setting the material settings wrong… if you could check them over that’d be ace :slight_smile:

Trying to base mine off of this, but having a hard time understanding how to translate it into nodes.
http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter16.html

I seem to be missing the glow, I did exactly what you did but have 0 glow.

dab7be39980aab04e95d34b740497b23d1150d50.jpeg

Did you ever sort that out? Have precisely the same problems you are and what you’ve posted from Nvidia may as well be written in yiddish, as far as I’m concerned :slight_smile:

Not sure how this is set up, but banding can be caused by sample count being too low.

Edit: Also as an aside, I’d look at Eric Bruneton’s paper for multi-scattering, as that’s what the Atmospheric Fog is based on, and it gives nicer results than O’Neil’s method (i.e., the NVIDIA GPU Gems link, which is single scattered).


Also, regarding my previous posts - I didn’t realize that UE4 already had atmospheric scattering from the ground perspective (i.e., Atmospheric Fog), so that’s why those posts make zero sense. Sorry about that.

Just found this post and wanted to say thank you, its been incredibly useful! :slight_smile:

However, could you elaborate a little on the “…will need to be hooked up to your blueprint to work with your views.”
I’m working on a simple space scene with a planet off in the distance, which blueprint should I integrate this with and what do I reference?

(Sorry if its a nooby question, still trying to grasp the blueprint/material behavior stuff)

I actually got it working, although I use a very different value setup than he did in his link. I can post a high resolution screenshot if that would help.