Dimev / Realistic-Atmosphere-Godot-and-UE4

A realistic atmosphere material for both the Godot game engine and Unreal Engine 4

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiple Light Sources

setg2002 opened this issue · comments

There is currently no way to get the material to be "lit" by multiple light sources.

commented

This will probably stay like this because I think it's not really needed (two suns like Tatooine can be done with just one light direction)

If you want some ambient lighting you can use the ambient term for some artistic tweaking.

If you do want to add multiple lights, you can modify this shader: https://www.shadertoy.com/view/wlBXWK, then port it back to the engine you are using (copy-paste for godot, for unreal I'm making this guide: https://github.com/Dimev/shadertoy-to-unreal-engine/blob/main/README.md

You can do the light loop part of the shader several times, but from there I'm also not entirely sure what the best way of doing it is.

So I got it working, but I would like to preface by saying that I am quite new to shaders.

Basically I was able to get the SHADERed version of the atmosphere working with multiple lights by duplicating col += calculate_scattering() inside mainImage() and changing light_dir. I then looked for a way to port this into the Unreal material graph using an array of light directions. I wasn't able to find any way to use arrays in the graph so I resorted to declaring 5 variables, light_dir0-light_dir4, and another variable num_stars to dictate how many of the variables to use. This is the part I'm least happy with as it does still limit to 5 light sources but 5>1 so ¯_(ツ)_/¯

Inside the custom material node it uses the exact same code as your proportional atmosphere, adds to a final color variable, and at the end of the loop returns the value. I've uploaded the graph here and use a material parameter collection to store the values for the light directions.

I also want to thank you for writing the shadertoy to Unreal guide and all the comments in the SHADERed version, they really helped a lot :)

commented

Ah, np!

The guide is not finished yet, but any feedback is appreciated!