Realistic atmosphere

The package has released and is now available for purchase!
https://www.unrealengine.com/content/6943478c79ab4b758472123d0f1700e0
Please rate!

Thanks everyone who helped it to get through! :slight_smile:

Well, I eat my own words then! Purchase made :slight_smile: Looking forward to this.

I was also looking at the scratchapixel one for a while, I eventually got lost in a haze of different functions talking to each other. I also only just found out that Custom HLSL nodes can be made to talk to and call each other from within the same material graph, which is quite cool. However, since your method works all on nodes - I won’t have to :slight_smile: Thanks for this!

EDIT: Just checked it out. It’s quite performance intensive, which I kind of expected to be fair. What’s weird though is that the performance seems to climb up and down even if I’m sitting in the same spot in a scene. Haven’t tried it with a totally blank project so I’ll give it a go. Just wondering what kind of performance you get with this? I’m on a GTX 980 with i7. Could just be my end being odd.

EDIT #2: Yeah, definitely my end being weird. If I open the level AND open the material, then close the material, the frames go straight back up again. Seems a bit eratic, but who knows. Probably won’t happen in a packaged game.

Hey TheJamsh!
Thank you for purchasing!

I was considering using the Custom Node…
Simple code implementation of loops would be much cleaner than those long chains of sample nodes…
However, Custom Nodes are platform dependent. Besides, the process of editing code for the CN is currently awful. :stuck_out_tongue:
So, I decided that implementing everything with regular nodes is a more reliable way.

Unfortunately, yes. But I’m afraid this is as much as I can get from the realtime implementation. My first implementation had about twice greater instruction count and I spent some time reducing it as much as possible. Also, I created different material instances with different sets of enabled features. Take a look at the MaterialInstances folder’s content: R = Rayleigh enabled, M = Mie enabled, S = Volumetric Shadow enabled, T = Translucency enabled (skies only). If you want further improve performance, you can decrease number of samples taken in AtmoSampleDensity and AtmoSampleScatter functions, but quality can suffer a bit.

I’ve tested performance on several machines and even got good performance on a laptop with i7 + GT 650 (but with 1366x768 resolution). Never noticed performance changes with static camera. Performance mainly depends on how many pixels on the screen are covered by the material, as the pixel shader is especially computationally-heavy.

No problem!
Have a nice day! :slight_smile:

I’m having one issue in regards to object scale with the Shader.

If my objects scale is too large, the Shader seems to stop working correctly - most notably the Sky Shader one. I basically have an inverted Sphere that I’m trying to apply one of the Atmosphere / sky shaders too, preferably the translucent one. As I move closer and further to/from the object for example, the atmospheres grows and shrinks and goes ‘inside’ the planet. (The mesh remains the same size of course).

I’ve just about got the Surface shader to work on my own planet surface, but the atmosphere not so much.

Do you scale it using scale transform or by changing InnerRadius/OuterRadius? Scale transform may not work correctly, so you should always use Radius properties on the blueprint. This is because the blueprint has to update corresponding variables in the material instance.

Gotcha, fixed it eventually. Looks bloody marvellous!

Hey Robert,

your atmosphere shader looks ! There’s only one thing I wondered. Do you use a 2nd spherical mesh for the atmosphere so it surrounds the planet?

Yes. Actually, the atmosphere mesh is an inverted sphere.

Hi Man, I Buy Realist Athmosphere Now, Great Job…

Now, I would like to be able to use these materials within a Map in SkySphere style, to add objects to the scene … there is a possibility to do this ?? if not, I would have to change a lot?

If you want to use it as a replacement for the SkySphere, then you’ll probably need to create a giant inverted sphere (or hemisphere) on your map and cover it with a Sky Material. You’ll also have to include an atmosphere node to all materials that you use inside your scene and that are supposed to be placed inside the atmosphere and being observed from a distance. This is necessary for proper attenuation of light that comes from these objects to the camera. But you can also try to emulate this using standard skylight and atmosphere fog.

Note, that using this shader only makes sense if you want to show a transition between the atmosphere and the space: for example if you are making a flight simulator or building space scene. If you just want to show your scene from the surface, then standard UE4 atmosphere effects will be much better in terms of performance and flexibility.

Hi,

I would love to use it but I can’t find any documentation how to implement a planet to a project? Can you please provide me (and likely many other people who purchased the item) with step-by-step guide how to implement a planet with the shader effect to an existing level?

Edit: After tinkering with it a while, its not that hard to add it to the level and customize it! However, some documentation, even a very rudimentary one, would still be great to have.

@TheoT

For now the best way of learning is to explore existing demo maps and see how they are made. To get started just place the atmosphere blueprint on your level and set its properties (you can copy them from existing maps).

Right now I am trying to understand what kind of difficulties users have with the package. If you could tell me what exactly seems difficult to you, it would help a lot with future documentation!

This is really cool and all, but I’d like to see how it could be implemented for a realistic Earth-like planet. If the materials are unlit, doesn’t that mean the planet surface can’t use specularity, bump, night side lights, ect?

@AurelTristen

Night side lights are definitely possible (and easy to implement), bump is also possible but I guess you’d have to implement it yourself.

Great job Robert on implementing that from the link you posted above! I’m currently working on implementing the same technique but from O’Neil example from NVidia’s GPU Gems 2. Nearly there getting all the math correct but still not 100%.

That’s a bummer Eric Bruneton’s multi-scattering technique looks challenging due to the 3D Texture support in UE4. Considering you’ve already looked at trying to implement it, what was lacking w/ 3D Textures UE4 to allow you to do this? You mentioned it’s not that easy but I was curious if its a limitation or just a massive workaround to get that to work? I looked at his article a week back when I started working on this but wanted to start w/ O’Neil’s example first before moving forward.

But keep up the great work buddy! :smiley:

Saw a couple of the vids of your progress and it’s looking great!

Hey Aurel,

I’ve done this pretty easy. In UDK, you could simply get the “Light Vector” but since UE4 is working w/ a Deferred Renderer, this node isn’t accessible. You can pass through a Vector parameter that you get from your Directional Light in the scene. Maybe in your BP, on the Event ‘Begin Play’, use a ‘Get All Actors Of Class’ and pull down the Directional Light and store the reference from that. Note: There is no need to store the reference if the light does not ever move and in that case you can store the Forward Vector from the first light you find.

In order to do the math, I don’t have my shader in my primary project handy as I’m posting this but here is a link to an old UDK example that will help you create a mask that you can lerp against your ‘Night Lights’ texture to make that happen.

UDK Planet Shader: https://www.youtube.com/watch?v=xS8vDVCHF9c

Best of luck!

Hello Robert, nice job and thanks for sharing this :smiley: I have some question if you want to answer it’s would be appreciate.

What will happen If I try to start playing with my character on the planet? What I mean is, did this include king of gravity so I can run every where on the planet? If yes, when you are out of the atmosphere, the player will be attract by the gravity or out of range? I plain to have 8 planets so if there a kind of gravity (It’s realy important to have a gravity in my case) I don’t want them to kill each other.

Also, I want to know if I can create a little real planet, exemple: have many lod’s (1000 polygon , 4000, 15 000, 60 000, 250 000 and maybe for a bigger planet 1 000 000 [Divide in many piece so we only see a maximum of polygon]) and have acceptable performance (For a non-realistic scene like a cartoon game and basique material that fade quality with distance, etc)?

Last question hehe, Do you know if there is a trick to create a spherical landscape, if no, maybe a trick to gradually fade the polycount of an object like the landscape do (base on distance). That would be !

Thanks for the answer and I apologize for my poor english, I learned english as a second language.

Hi, Xosh project,

Thank you for your interest!

No, there’s no gravity. The package just contains a material that simulates visual effects of the atmosphere. It’s not intended to be a full-featured planet simulation. Sorry.

I can’t really answer your questions regarding LODs/polygons/landscapes because they are not part of this package. I suggest creating a separate thread and ask the community about that. I am sure that someone will help you. Sorry again.

Robert.

Thanks for your quick reply, I’ll maybe open a subject :p. I’ll try to create something with your content and if it’s working well I’ll show you :slight_smile:

Please excuse the ignorance, I haven’t read the entire thread. In the first post, it says that this is viewable from the surface, does this mean that if I am not dealing on a galaxy scale, but instead my game is based on the surface of a planet, then the atmosphere will be a skysphere?