Jump to content

[WIP][1.9.x-1.10.x-1.11.x] Scatterer-atmospheric scattering (v0.0723 - 31/12/2020)


Recommended Posts

Hi. I need help. When i install the mod wth the shaders im dropping from 75 to 25fps. Why is that happening. Im running Beyond Home and Parallax but when i delete Scatterer its all fine. Also same with the stock solar system. Why is it dropping more than twice. I have a GTX 1060(3GB) and it goes all 100% out at 70°C is there a problem or is this the way it will be? Can someone please help me????

Link to post
Share on other sites

 

7 minutes ago, BlackEyedPhantom said:

Hi. I need help. When i install the mod wth the shaders im dropping from 75 to 25fps. Why is that happening. Im running Beyond Home and Parallax but when i delete Scatterer its all fine. Also same with the stock solar system. Why is it dropping more than twice. I have a GTX 1060(3GB) and it goes all 100% out at 70°C is there a problem or is this the way it will be? Can someone please help me????

Do you have other mods? What kind of CPU do you have?

Edited by Spaceman.Spiff
Link to post
Share on other sites
10 minutes ago, Spaceman.Spiff said:

 

Do you have other mods? What kind of CPU do you have?

My main game is running with Beyond Home, Parallax, TUFX, engine lighting, Real Plume stock and no part texture mods. My rig is:

CPU: Intel Pentium G4560 3.5GHz

8GB DDR4 2100MGHz RAM

GPU: GTX 1060(3GB)

Link to post
Share on other sites
37 minutes ago, BlackEyedPhantom said:

My main game is running with Beyond Home, Parallax, TUFX, engine lighting, Real Plume stock and no part texture mods. My rig is:

CPU: Intel Pentium G4560 3.5GHz

8GB DDR4 2100MGHz RAM

GPU: GTX 1060(3GB)

Ah. Maybe try uninstalling Parallax? (can you do that with BH?) I know that's running an older version of the mod which has pretty bad performance TBH. I may be wrong, but I think the ocean shader is the most intensive part of the mod. I think it can be disabled in the config but I don't know how. 

Also logs might help

 

Link to post
Share on other sites
Posted (edited)
13 hours ago, BlackEyedPhantom said:

Well i dont really wanna turn off water shaders. But i wanna desable parts that are casting shadows from so far away and godrays that are casted by parts but not the mountain and stuff. How can i do that? Any idea?

You can't disable one and keep the other, unless you want parts to stop casting regular shadows too, besides parts don't really add much performance hit to the godrays, the bulk of the hit comes from the shadows and the godrays covering 50km distance. And godrays are somewhat less expensive than the ocean.

Anyway, I'm a bit skeptical about your performance figures, you claim that scatterer takes the performance from 70 fps to 25 on a GTX 1060 3gb. I had the exact same card (in fact I still have it, but a friend lent me his old 1080 which I'm using for now) and it ran much better. What resolution are you running? Can you test scatterer alone with no other mods?

Edited by blackrack
Link to post
Share on other sites
3 hours ago, blackrack said:

You can't disable one and keep the other, unless you want parts to stop casting regular shadows too, besides parts don't really add much performance hit to the godrays, the bulk of the hit comes from the shadows and the godrays covering 50km distance. And godrays are somewhat less expensive than the ocean.

Anyway, I'm a bit skeptical about your performance figures, you claim that scatterer takes the performance from 70 fps to 25 on a GTX 1060 3gb. I had the exact same card (in fact I still have it, but a friend lent me his old 1080 which I'm using for now) and it ran much better. What resolution are you running? Can you test scatterer alone with no other mods?

I will do my best! Im not saying that the mod is bad intact its great. And yea i will try my best of testing the mod. With stock and BH game saves! Ow yea also 1920x1080 resolution.

Edited by BlackEyedPhantom
Link to post
Share on other sites
6 hours ago, BlackEyedPhantom said:

I will do my best! Im not saying that the mod is bad intact its great. And yea i will try my best of testing the mod. With stock and BH game saves! Ow yea also 1920x1080 resolution.

 

9 hours ago, blackrack said:

You can't disable one and keep the other, unless you want parts to stop casting regular shadows too, besides parts don't really add much performance hit to the godrays, the bulk of the hit comes from the shadows and the godrays covering 50km distance. And godrays are somewhat less expensive than the ocean.

Anyway, I'm a bit skeptical about your performance figures, you claim that scatterer takes the performance from 70 fps to 25 on a GTX 1060 3gb. I had the exact same card (in fact I still have it, but a friend lent me his old 1080 which I'm using for now) and it ran much better. What resolution are you running? Can you test scatterer alone with no other mods?

This is also heavily dependent on the number of parts in your craft; it could be your frame rate is low because you have very high part count craft?

Link to post
Share on other sites
1 hour ago, Avera9eJoe said:

 

This is also heavily dependent on the number of parts in your craft; it could be your frame rate is low because you have very high part count craft?

Yea i know thats why im bothered cuz im playing science mode and only the half of my teach tree is unlocked so i dont have many parts and i cant build huge rockets.

Link to post
Share on other sites

So, I’ve been working on some performance and rendering improvements.
If you remember earlier versions of Scatterer, they used used the depth buffer to apply the main scattering effect. This was a big source of issues, low depth-precision, no anti-aliasing support, depth artifacts etc… Let me just jog your memory with this one image:

lbYmqLu.png

A few versions back I switched to using a “projector” and got rid of the depth buffer. It’s essentially just a way to re-render all opaque objects in the scene with a different shader, in this case, the scattering shader. This fixes aliasing and depth related issues, but it is wasteful of CPU and GPU power (re-rendering opaque objects is expensive, this was one of the things I fixed in EVE-redux that boost performance) and couldn’t handle special cases, like terrain scatters/trees and Parallax displaced terrain causing them to not have scattering on them or only partly:

khEYeUG.png

gCfY7h8.jpg

While trying to fix these issues, I decided to re-visit the depth buffer approach as it doesn't have those issues and could help improve performance.

First attempt using the depth buffer came out as broken as expected:

iqERR40.png

I won’t get too deep into the technical details but there is two main methods to reconstruct the world position from the depth buffer and both have issues with large distances.
If you’ve ever seen this issue in EVE-Redux:
NLmFigA.jpg

This is the same issue. I work around it in EVE-Redux by fading out shadows in the distance, but this can’t really be done here.
At first I thought it must be the depth buffer precision that just sucks, as it always has. But how could this be? Unity switched to reverse-Z buffer recently which is renowned for good precision, and used in pretty much every large open-world or planetary rendering engine.

I decided to take a closer look at the depth buffer, and it looked completely fine, precision looked good, so the position reconstruction methods must be flawed somehow. Initially I came up with two over-engineered reconstruction methods, one involving an iterative search, and the other involving emulated double precision in the lossy operations. One of these worked very well (I’ll let you guess which one). However I later thought of just combining the two original methods from above, simply using one to get the direction and the second for the distance. This ended up working perfectly and being very simple and cheap.

So now we have precise positions reconstructed from depth, this means that the main scattering shader will get much cheaper, and won’t have to re-render god knows how many objects, reducing both CPU and GPU usage. Added bonus is it now works with Parallax and the terrain scatters so they get correct scattering as long as they write correctly to depth:


hTna0rT.jpg

58mXdIy.jpg

It also gets rid of these z-fighting artifacts which sometimes appear in the distance with the current method:

Hq5W8IV.jpg
Tested it with RSS and Rescale and it seems to hold up as well.

For long-distance shadows also there is the partial depth buffer which I was rendering to cover the areas where depth reconstruction precision of the old method degraded for shadows, though in practice that was relatively fast, we can get rid of it now as well. This method can also be used in EVE-Redux as well so cloud shadows can cover the whole scene and not just ~5 km around the camera.

Another advantage is that we can now use the same method as EVE-Redux’s volumetrics: Render the scattering effect at ¼ the screen resolution for performance.

On the left is is how it is really rendered at low resolution, on the right is the final result after doing depth-aware upsampling and compositing with the rest of the effects:

YfrjXJO.png

This approach (1/4 resolution scattering) is however incompatible with godrays (at least for now), so it will auto-disable when using godrays, I’d also argue that if you can afford godrays you probably won’t need this.

Now there remains the issue that the depth buffer can’t be anti-aliased, while the main scene does, resulting in these lines around the scattering effect if AA is used:
aTuPnlf.png

Unity doesn’t expose a multi-sampled depth buffer, and while I managed to find a way to force it to render to one, and to resolve it manually in my shader, this pretty much broke other mods that use depth effects or image effects. The only other solution available was to disable hardware MSAA and use a post-processing AA. If you care about MSAA though don’t worry, depth-buffer mode can be disabled and you can keep the old MSAA-friendly mode, though that means giving up on the performance and compatibility improvements.

So, my first choice was to go with temporal Anti-aliasing. TAA is pretty good these days, in some cases better than MSAA because it offers temporal stability which MSAA does not. I got it working pretty well and was happy with how it looked, however due to a bug in unity when setting custom projection matrices (which TAA needs for slightly offsetting temporal samples) with a high far/near ratio such as in KSP, shadows flicker from some angles:

ShockingGreedyDarwinsfox-size_restricted

So that makes TAA not really usable, until Unity fixes this at least, though I will keep the option available for those who want to try it anyway.

My second choice was Subpixel Morphological Anti-Aliasing (SMAA). It is quite good and has different quality levels, in some regards it is better than TAA, and in every regard better than FXAA as it never blurs over details or textures. Overall I feel it looks very similar to 2x MSAA, which is mostly sufficient if you play at high resolution.
Here are two screens, one using the new method with SMAA, and one using the old method with 2xMSAA, can you tell which is which?

yodloiE.jpg

VYak2Mu.jpg

The second one is SMAA, and in this particular instance the SMAA image looks cleaner:

NYPhgnK.png

May be it would be better compared with 4xMSAA, though it varies a bit in motion.
An added bonus is that it also fixes the aliasing that the volumetrics of EVE-Redux introduce around crafts (if you’ve ever noticed that).

So now we can put it all together and see how it runs.

Let’s test something really low-end, here we have a weakly i3-3217U @1.8 Ghz and and its integrated HD graphics 4000, this is an old laptop, and it struggles just loading up KSP. Though it has a gt 740m (which is a bit faster but still slow) I'm going to test it on the integrated graphics.
Testing with just the scattering shader + sunlight extinction (which isn’t expensive), everything else disabled. Stock terrain at low. Running at 720p with no AA (because let’s be honest here we can’t afford much with integrated), running with these settings (hard shadows and all):

JEsMy46.jpg

Stock gets ~30 fps with these settings, so we’re off to a bad start.

dUXY6W5.jpg

Previous release of scatterer gets 23 fps

6xVvvbM.jpg

New version gets ~24 fps (though I forgot SMAA enabled here but it barely removes 0.5-1 fps)

VrsgpGt.jpg

That's barely an improvement over last version. However now we can enable 1/4 res scattering and get 27 fps, that's already much closer to stock's 30 fps, and a 17% improvement over last version.

ZIsCeXX.jpg

So there you have it, much closer performance to stock on the low-end settings.

Alright now something faster

On a GTX 1080 at 1440p and everything enabled, we go from 85 fps to 108 fps on the ocean surface with no AA, a 27% improvement

s26GBEy.jpg

84 fps to 102 fps when zoomed out, a 21% improvement

R8CvSBe.jpg

And although it’s not a completely fair comparison, let’s look at 2x MSAA on the old version, and SMAA on the new one: 75 fps to 106 fps, a 41% improvement. MSAA is expensive :o

n72VKi0.jpg

Oh and also, I tested with OpenGL on my main PC and it went from 35 fps to 64 fps (makes sense since this frees up some CPU overhead as well and OpenGL KSP is running on a single core for some reason), but I didn't take screens so the two guys playing on OpenGL will just have to try it for themselves :p

Now with all these new settings, it can become complicated to pick and tune your settings, so I’ve added the ability to load quality presets from config files:
9UJ8Tlk.png
I defined a few logical presets, each one tries to aim for the best quality/performance ratio, in increasing quality. The mod will default to “Low” from now on, which is just the ocean (with transparency and foam), the scattering at 1/4 res, and the non-expensive effects. Feel free to pick the preset that suits you best from the UI, you can go lower or higher, and a restart is no longer needed when changing some settings like ocean or terrain shadows. A few effects like long-distance shadows might be completely fine with stock but scale badly with with other mods, so keep that in mind.

Thank you for everyone who read this wall of text, I still have a few things to fix/test but I will be posting a build on Patreon soon, and making a public release as soon as this is all polished and ready :)

10 hours ago, klancy1o said:

how i can make my own config? for atmosphere

Check the links in the OP, there is a section about the Config Tool you can use to export atmosphere files, and the rest is in the wiki.

Edited by blackrack
Link to post
Share on other sites

 

 .    .                                                                                                                     O             :o

Link to post
Share on other sites
On 1/9/2021 at 1:07 PM, blackrack said:

You can't disable one and keep the other, unless you want parts to stop casting regular shadows too, besides parts don't really add much performance hit to the godrays, the bulk of the hit comes from the shadows and the godrays covering 50km distance. And godrays are somewhat less expensive than the ocean.

Anyway, I'm a bit skeptical about your performance figures, you claim that scatterer takes the performance from 70 fps to 25 on a GTX 1060 3gb. I had the exact same card (in fact I still have it, but a friend lent me his old 1080 which I'm using for now) and it ran much better. What resolution are you running? Can you test scatterer alone with no other mods?

Hello im here with numbers for you that i tested. 

Space center: 35fps with Scatterer and 55fos WO

Launch pad: 25fps with 40fps wo

Launch same craft: 26fps with and 32fps wo

High altitude/in clouds: 26fps with 34fps wo

Map screen: 33fps with and 47fps wo

So now i have tested Scatterer in my main game with all the other mods that i mention before (i forgot you told me to test only Scatterer). These are the numbers that i got. Over all 10-15fps lower in regular gameplay and around 20 in space center.

Edited by BlackEyedPhantom
Misspell
Link to post
Share on other sites
22 hours ago, eberkain said:

Holy Shazbot man, I wish I could like a post more than once.  Amazing work. 

22 hours ago, Brigadier said:

Remarkable stuff.  You are a wizard @blackrack.  Thanks for the extraordinary work you do for KSP.

21 hours ago, Spaceman.Spiff said:

 

 .    .                                                                                                                     O             :o

20 hours ago, Drew Kerman said:

very much enjoy reading these walls of text

Thank you guys

1 hour ago, BlackEyedPhantom said:

Hello im here with numbers for you that i tested. 

Space center: 35fps with Scatterer and 55fos WO

Launch pad: 25fps with 40fps wo

Launch same craft: 26fps with and 32fps wo

High altitude/in clouds: 26fps with 34fps wo

Map screen: 33fps with and 47fps wo

So now i have tested Scatterer in my main game with all the other mods that i mention before (i forgot you told me to test only Scatterer). These are the numbers that i got. Over all 10-15fps lower in regular gameplay and around 20 in space center.

Hmm well now that I think about it that sounds about normal with those mods. All I can suggest is lowering the settings for both Scatterer and Parallax a bit, and switch to EVE-Redux if you are using EVE, also lower the settings for the stock reflection probe. If I remember correctly, BH uses the previous version of Parallax, which has improved in performance since, and the next version of Scatterer will give a performance bump as well (see above post).

Edited by blackrack
Link to post
Share on other sites
1 hour ago, BlackEyedPhantom said:

Hello im here with numbers for you that i tested. 

Space center: 35fps with Scatterer and 55fos WO

Launch pad: 25fps with 40fps wo

Launch same craft: 26fps with and 32fps wo

High altitude/in clouds: 26fps with 34fps wo

Map screen: 33fps with and 47fps wo

So now i have tested Scatterer in my main game with all the other mods that i mention before (i forgot you told me to test only Scatterer). These are the numbers that i got. Over all 10-15fps lower in regular gameplay and around 20 in space center.

Hey, I know you!

Link to post
Share on other sites
43 minutes ago, blackrack said:

Thank you guys

Hmm well now that I think about it that sounds about normal with those mods. All I can suggest is lowering the settings for both Scatterer and Parallax a bit, and switch to EVE-Redux if you are using EVE, also lower the settings for the stock reflection probe. If I remember correctly, BH uses the previous version of Parallax, which has improved in performance since, and the next version of Scatterer will give a performance bump as well (see above post).

Ok thank you. Can you tell me when is that update coming?

34 minutes ago, kerbalxploder said:

Hey, I know you!

Hey, i guess same? On Instagram if im not mistaken you with someone else.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...