[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (2024)

This will be a long post so grab some snacks [WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (1)

I have been working on implementing a new godray technique:
[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (2)

[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (3)

[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (4)

[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (5)

Some of you might remember I used to have godrays in scatterer a while back, well that implementation was flawed and had many issues, here is a direct comparison between the old and new technique.

[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (6)

The old technique was only getting the "outer surface", and couldn't handle overlapping rays and get the real depth, it also often had gaps.

[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (7)

The new technique creates a light volume and handles overlapping rays and complex shapes, it uses shadow information so is directly tied to shadowmap resolution, shadow distance etc (now you understand why I was insisting on "fixing" shadows in the last update).

[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (8)

[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (9)

To put this new technique to the test, I built this huge monolith.

[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (10)

I call this: "The Temple of Godrays"

[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (11)

I boosted scattering exposure a bit here, you can see light columns formed by the holes in the ceiling

[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (12)

As you can see, it's a true volumetric effect and not screen-space

[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (13)

With this new technique I'm also able to inject any information I want to create godrays, I'm currently adapting it to have EVE clouds cast godrays, although it still needs a lot of work:

[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (14)

Laythe's surface looking magical:

[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (15)
[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (16)
webm: https://gfycat.com/poshuniformerne

I have to say though this looked simple to me going in, it's probably been one of the most complex features for me to implement and pretty much took everything I learned in the last few years about graphics programming and the unity engine to get it working.
These godrays will only work on Directx11 (they require the unified camera setup).


Moving on, a few versions back I added underwater caustics. The next logical step was to create underwater light rays:
[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (17)

Short video: https://gfycat.com/sillypeskybaldeagle

These use a completely different technique from the godray technique used for terrain and clouds, more adapted for short distances and semi-transparencies.

Here the lightrays are derived directly from the caustics textures and config, you can follow any light ray to the matching caustic.

[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (18)

Here are some beauty shots, as you can probably see, this is inspired by subnautica.

[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (19)

[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (20)

We can also do the same “temple test” as we did for godrays but underwater

[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (21)

[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (22)

[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (23)

Moving on, since the ocean shader was added, it has always looked nice, but any ships on the water surface were always static and not interacting with the waves, as if they were anchored in place.


Some will remember that I showed a prototype in 2016 were a ship was interacting with waves. Since the ocean was created and animated on the GPU, in the 2016 implementation I re-did all the ocean calculations on the CPU, so that the height info would be available on the CPU for physics, so it was slow (as it's a computationally heavy task that benefits from parallelization but that's the GPU's job) and had a very hefty CPU impact, moreover my knowledge was limited at the time, and the implementation was unstable and caused ships to disintegrate, often within seconds.
Well, here's the new version:

[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (24)
Webm: https://gfycat.com/splendidcelebrateddodobird

It appears stable even with multiple ships

[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (25)
Watch in HD: https://gfycat.com/evilexcellentbobwhite

Although it can of course destroy your ships if the waves are big.


Here is a boat caught in a massive storm (ridiculous buoyancy on the boat here):

[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (26)
Webm: https://gfycat.com/imaginaryjadedafricanaugurbuzzard

What's impressive, this runs with nearly no performance impact. How can it run so well when the old version destroyed performance? There is a big trick here, can you tell what is going on?

Wave interactions will only work on Directx11, if you haven't guessed, the magic feature that makes this work is async GPU readback which is sadly not implemented by unity for OpenGL.

With this, there are other limitations like jittering and cutting that become apparent in the ocean shader when the waves are bigger (there was never a reason before to have big waves when vessels stayed "anchored"), as well as how static the ocean config is, in a future update I will work on making the ocean dynamic, I will start with a simple weather system so the waves can change dynamically, we'll see where this goes.

Gameplay-wise, it makes moving against the waves difficult, the water seems to slow down ships a lot on every impact, however reasonable/small waves are a pleasure to navigate. I'm also looking forward to see the first guy to stabilize a boat by moving fuel in between tanks with a kOS script. Vessel recovery can be an issue too, although I have workarounds to test.

Moving on, RSS/Rescale users will be happy to know that I’ve fixed this issue where scattering is cut off in the distance (without changing the clip planes)

[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (27)

You might still be able to spot a discrepancy where local terrain and scaled terrain meet, but it's a small one.
Using the same technique I’ve also fixed this issue where mountains might look overbright white when ascending to orbit

[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (28)

And for OpenGL users who must be feeling left out by now due to no godrays and wave interactions on Opengl, at least I have something for you. Since unity added compute shader support outside Directx11: Config tool builds for Linux and Mac:

https://github.com/LGhassen/Scatterer/releases/download/0.1-mac-conftool/ConfigToolLinux.zip

https://github.com/LGhassen/Scatterer/releases/download/0.1-mac-conftool/MacConfTool.app.zip


Also, actual documentation for scatterer is here on the wiki, although still a work in progress

[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (29)

https://github.com/LGhassen/Scatterer/wiki


With that said, I really love modding and exploring what can be done, I feel like I'm close to "finishing" Scatterer, but the topics involved are increasingly complex and time-consuming to work on.


As I want to continue modding, I decided to set up a Patreon, hoping to make modding more sustainable for me. This doesn't mean my mods will become paid, they will be available for everyone of course, however patrons will get early access to in-dev features and previews, and I get to spend more time doing what I love and adding new features everyone can enjoy, and finally finding the time to work on some things that I never could, and fixing the layer of jankiness around my old code (nevermind that scatterer was my first real programming project). I will be uploading a first build shortly, so stay tuned:

[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (30)

Please consider supporting me there if you appreciate my work, and if you can't, that's alright too, releases will always be public.

Edited by blackrack

[WIP][1.9.x-1.12.x] Scatterer-atmospheric scattering (0.0838 - 14/08/2022) Scattering improvements, in-game atmo generation and multi-sun support (2024)
Top Articles
Latest Posts
Article information

Author: Msgr. Benton Quitzon

Last Updated:

Views: 5529

Rating: 4.2 / 5 (63 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Msgr. Benton Quitzon

Birthday: 2001-08-13

Address: 96487 Kris Cliff, Teresiafurt, WI 95201

Phone: +9418513585781

Job: Senior Designer

Hobby: Calligraphy, Rowing, Vacation, Geocaching, Web surfing, Electronics, Electronics

Introduction: My name is Msgr. Benton Quitzon, I am a comfortable, charming, thankful, happy, adventurous, handsome, precious person who loves writing and wants to share my knowledge and understanding with you.