Progress Update #15

   Atmosphere and Clouds in UE4


    This past week has been entirely dedicated to making atmospheres for the planets. After recently re-watching Sebastian Lague's Coding Adventure: Atmosphere, I had become inspired to do the same for my planets, but I wanted clouds too. (Also the Trello is now available here)


The Atmosphere:

    Making the atmosphere was actually incredibly easy, mostly because someone had already done exactly what I was trying to do. While doing research into atmospheres in game engines, I came across a GitHub repo called: Realistic Atmosphere in Godot and UE4. Suffice it to say, the materials included in this repo were perfect for my application. 
    Now, I didn't want to just Ctrl+C Ctrl+V because the purpose of this game is for everything to be done by myself, and I didn't really think that would count. However, I did spend a fair amount of time figuring out how it works, so by now I have a fair understanding. Also, with the bulk of the shader done in a custom hlsl node I had to learn that as well.


    Here's the actual graph but, like I mentioned before, most of the computation is done in the atmospheric scattering node.


    This behemoth of a shader node is 
functionally quite similar to the one made by Sebastian Lague and is based on this article which explains everything in far greater detail than I could here. But to give a brief overview of what's going on:
  • Lines 1-11 check if the current pixel is looking through the atmosphere
  • Lines 12-25 set up variables to be used later
  • The first loop steps through the optical depth ray
  • The nested loop steps from that point on the optical depth ray to the light source
  • Line 51 calculates the final opacity
  • Finally the color at the pixel is returned
    This material is decently performant with the base pass shader having 214 instructions, although this could be decreased in future with texture lookups for precalculated optical depth (cutting the outer loop entirely). 



The Clouds:

    Because the atmosphere was so quick to implement, I spent much of my time on the clouds. I started out trying to do volumetrics, but to make the deadline at the last second I switched to a 2d translucent noise panning across a sphere mesh. Not the most interesting solution but it got the job done and I can move on knowing that I can always come back to tackle volumetrics when I have more time. 

https://blueprintue.com/blueprint/50cwjp9j/

    For it being entirely 2D it is quite performance intensive with the base pass shader having 207 instructions and the vertex having 197. This is mainly because of the procedural noise and the Fresnel, both of which will not be needed for the volumetric version in the future.

    I did come across some resources while doing research for volumetric clouds that I would like to share:

The built-in Unreal Volumetric cloud:

    This looks great and is very optimized but even reverse engineering the source I couldn't get it to work with planets of smaller radii. It also depends on having a directional light in the scene which is not applicable for this game. It is quite apparent that this is meant for a more classic 3D game where the world is a flat plane.

Harry "deBug" Emelianov's UE4 Volumetric Cloud Shader:

    Absolutely beautiful and very well optimized. Same problem as the built-in clouds that it doesn't easily scale down to a planet of a small size. Also not as dynamic in terms of lighting.

Real-time Volumetric Clouds for Horizon Zero Dawn:

    "Holy crap it basically looks real" was my main reaction from reading this 2015 presentation by Andrew Schneider. I also knew that there is no way I, as one person (and not even an FX artist at that), would be able to pull something like this off in a timely manner.

Real-Time Rendering of Procedurally Generated Planets:

    Computer graphics student Florian Michelic from the Graz University of Technology wrote this amazing paper on all aspects of procedurally generated planets, not just clouds. This paper covers terrain and oceans too which tempted me to restart the project again from scratch o_o

Triplanar Mapping:

    When I had finally decided to put volumetrics on the backburner and proceed with the 2D method instead, I came back to a problem that I've had several times; projecting onto a sphere without obvious deformities. A Sebastian Lague video introduced me to this technique which blends textures projected onto a surface from every axis without seams. I scraped this idea for time as well, but I believe it will be useful to know of this method in the future.

Comments

Popular posts from this blog

Polishing the Foundation

Progress Update #13

A New Chapter