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.

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.

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

Awesome work.

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.

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

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.

@riuthamus That’d be great. I’m just having difficulty getting it to react to anything when placed in the World. It looks great, just doesnt change based on anything it seems.

Any examples would be great to help me click how to get this going.

Please do.

So I’ve been playing with this shader for a few weeks now and am totally lost at where/how to hook it up to receive whatever information it requires.

I’ve tried setting it as a DynamicMaterialInstance and getting world info (such as world position) to set in Eclipse_Position_A etc.

Any insight would be fantastic and much appreciated (I’d even love to spitball some ideas for alternate methods to achieve this if anyone has ideas)

Left: my material preview window, Right: the object in the world
3fe62705457903955cf3cc943513a44b98feb891.jpeg

Have you tried using the camera’s position?

I am too having difficulties with this aswell.

In what sense? The Material utilizes the Camera Vector (I assume to draw the eclipse correctly which is where I am having the problem) - I have looked in Blueprints for a way to get camera location in another way but so far nothing has worked.

Did you have a specific place in mind to send the cameras position to?