blackrack

[WIP][1.6.1] Scatterer-atmospheric scattering (v0.0540 - 17/03/2019) FIXED TSUNAMI BUG !!!1!1!

Recommended Posts

@Poodmund

Quote

The flooded KSC bug still haunts so many people and constantly fills up the KSP sub-reddit.

If you want to see something interesting: switch all cameras to Deferred Shading. You'll notice that PQS draws the terrain of Kerbin precisely where KSC becomes flooded.

 

If you want to improve performance, the first step would be change how it renders: right now it moves with the camera and has to re-render every frame to keep up with that, but in fact you could render much less frequently against a non-rotating skybox instead (for the far scatter), so the camera moving around just show different parts of the skybox. Also, try not to ever copy any textures or renders. For example, a static skybox material can be used for the background galaxy; then each of the 6 atmosphere skybox cameras could have their own skybox object referenced to that same single galaxy material, and all 6 rendering each into 1 face of another skybox material. That atmosphere skybox material is then used as the full game skybox: i.e. RenderSettings.Skybox. Due to the location of main camera being the same location as the atmo camera cluster, even though the camera cluster rotation is static, it appears correctly due to the atmo shader rendering against the depth from the scaledspace objects. The last step is simply to change the main camera to have it's clearflags also using skybox (which is now a scattered atmosphere + galaxy skybox). The localscenery scatter will then be properly separated from the far scatter because the far scatter is part of the skybox anyway.

 

This setup means that nothing renders twice and nothing is copied (the 6 atmo cams render directly into the clearFlags of the live local camera), they all use reference memory down the hierarchy from Galaxy -> Atmo / Scaled Space -> Local Scenery, and since it's all done within cubemaps, the camera can pan however it wants and you only have to render local scenery with it: all of the galaxy and atmo scattering/shading can be done as infrequently as you choose and the player is none the wiser.

You could also put non-volumetric clouds in the atmo layer too, unless you want shadows cast from them onto local scenery (I'm unsure if the 2d clouds cast shadows, or if it's just the volumetric ones currently).

 

Far Scatter Re-render:

  • When on the ground, the far scatter only has to update to show the difference in time-of-day. So even once every 10+ seconds at no-time-warp is more than fine.
    • this also means you can stagger the camera renders to be 1 face per x seconds and go round-robin to reduce tick lag
  • When flying, the rate of re-render is dependent on the altitude change rate. At constant altitude, again, it only has to render maybe once every 10+ seconds for day/night.
  • In orbit, it mostly just needs to re-render for day/night; but needs to be more frequent: like once every 2 or so seconds due to you moving so fast and your position versus the scaled space position slides when in low orbit.
Edited by Electrocutor

Share this post


Link to post
Share on other sites

@blackrack Every time i see you come back to this mod it makes my inner child jump with joy. Great to see you wanna continue this onwards.

Share this post


Link to post
Share on other sites
17 hours ago, Tyko said:

The biggest thing I'd love to see would be removing the black line on the horizon when in the atmosphere of Kerbin. You see that line every time you launch or fly around Kerbin.

Yep, this is the only thing I see that could be improved. Im sure there is more, reading some of the stuff in here, but its looking pretty good on my machine.

 

Some of the latest mod updates have been awesome lately, this is certainly no exception.

Share this post


Link to post
Share on other sites
18 hours ago, Poodmund said:

 

Quote

-Adding proland trees in scatterer This would be very nice. I'm not sure how you specify which areas of the terrain are covered in the trees though, maybe link it to a per biome basis?

I was thinking per biome values for distribution/tree types or a density map or a combination of both

-Improving the localspace/orbit transition and getting rid of (or reducing the need for) configpoints Improving the transition is always good but it does work quite well already if you actually set up with good values in the config.

So actually I have a new approach in mind which should make the transition perfect by default (without finetuning), as well as fix the horizon effect you mention, and unify the shading method used in scaledSpace and localSpace (imo the colors look a bit better in localSpace right now)

-Integrating the precomputation code into the game (ie having the config tool functionality ingame instead) I wouldn't see this as much of a priority at all. I almost think it would be better to keep it separate as it is now. Implementing it into the game could cause further mod issues, perfomance issues etc.

Point taken, this is for modders only anyway so if it's not needed better implement something more useful.

-Doing the godrays correctly and adding them to clouds as well With reference to clouds, improving the ongoing Scatterer-EVE relationship is a battle I don't envy you for tackling.

Although hard to configure correctly, I'm pretty happy with the way the cloud integration has turned out so far and it wasn't so much trouble to implement

-Displaying all effects correctly in any camera (mod cameras, bdarmory cameras etc) Getting Scatterer to render using the in-game screenshot function would be nice as it currently does not when creating super-sampled screenshots.

I thought the supersampled screens were working correctly? Apart from maybe the sunflare shader?

-Underwater caustics Improving Scatterer's liquid rendering and performance is always welcome as the ocean effects are one of the main draws. ALSO! The flooded KSC bug still haunts so many people and constantly fills up the KSP sub-reddit.

Yep, that bug is still a pain and I find it impossible to reproduce on purpose


 

The main things I'd like to see potentially resolved are:

- Editing the Alpha values of the Scatterer atmo effects seems to not actually make the effect more transparent but actually just makes the body fade to a dark grey sphere. Is this intended? I've always thought that this behaviour is super weird as it is hard to implement Scatterer on a body that has a very thin atmosphere as you lower the Alpha setting a lot to reduce the Scatterer effect but then have to massively over-expose the effect to stop the body from become a dark-grey/black sphere.

I added my response in italic, regarding the alpha values, can you provide some screens of the behaviour in question? Since the shaders switched from alpha blending to additive/soft-additive we don't have alpha anymore and instead the value added is lowered I thought it was more or less equivalent, but I guess you have more experience playing with configs, please provide some visuals so I can get an idea of whta you'd like to have.

 

18 hours ago, Tyko said:

The biggest thing I'd love to see would be removing the black line on the horizon when in the atmosphere of Kerbin. You see that line every time you launch or fly around Kerbin.

The horizon line on the ocean or the one on the edge of terrain or the one in the middle of mountains? Please be specific and maybe provide screens if you can, they would help me.

13 hours ago, therealcrow999 said:

I am going to be the guy who ask this, is there a way to not use the stock icon settings? I was looking in the config file, but did not see anything.

Or have it use Toolbar Controller.

Is toolbar controller a mod? I thought there was another popular mod for toolbars? The name escapes me. Anyway, what do you want exactly? To disable the button?

13 hours ago, Electrocutor said:

@Poodmund

If you want to see something interesting: switch all cameras to Deferred Shading. You'll notice that PQS draws the terrain of Kerbin precisely where KSC becomes flooded.

 

If you want to improve performance, the first step would be change how it renders: right now it moves with the camera and has to re-render every frame to keep up with that, but in fact you could render much less frequently against a non-rotating skybox instead (for the far scatter), so the camera moving around just show different parts of the skybox. Also, try not to ever copy any textures or renders. For example, a static skybox material can be used for the background galaxy; then each of the 6 atmosphere skybox cameras could have their own skybox object referenced to that same single galaxy material, and all 6 rendering each into 1 face of another skybox material. That atmosphere skybox material is then used as the full game skybox: i.e. RenderSettings.Skybox. Due to the location of main camera being the same location as the atmo camera cluster, even though the camera cluster rotation is static, it appears correctly due to the atmo shader rendering against the depth from the scaledspace objects. The last step is simply to change the main camera to have it's clearflags also using skybox (which is now a scattered atmosphere + galaxy skybox). The localscenery scatter will then be properly separated from the far scatter because the far scatter is part of the skybox anyway.

 

This setup means that nothing renders twice and nothing is copied (the 6 atmo cams render directly into the clearFlags of the live local camera), they all use reference memory down the hierarchy from Galaxy -> Atmo / Scaled Space -> Local Scenery, and since it's all done within cubemaps, the camera can pan however it wants and you only have to render local scenery with it: all of the galaxy and atmo scattering/shading can be done as infrequently as you choose and the player is none the wiser.

You could also put non-volumetric clouds in the atmo layer too, unless you want shadows cast from them onto local scenery (I'm unsure if the 2d clouds cast shadows, or if it's just the volumetric ones currently).

 

Far Scatter Re-render:

  • When on the ground, the far scatter only has to update to show the difference in time-of-day. So even once every 10+ seconds at no-time-warp is more than fine.
    • this also means you can stagger the camera renders to be 1 face per x seconds and go round-robin to reduce tick lag
  • When flying, the rate of re-render is dependent on the altitude change rate. At constant altitude, again, it only has to render maybe once every 10+ seconds for day/night.
  • In orbit, it mostly just needs to re-render for day/night; but needs to be more frequent: like once every 2 or so seconds due to you moving so fast and your position versus the scaled space position slides when in low orbit.

The thing is, while this is all technically very nice, the sky shader is already using precomputed values, it's essentially a glorified texture lookup.

Out of all the effects in scatterer, the sky shader is by far the least expensive and you wouldn't see any noticeable performance improvements either by implementing this approach or even disabling the shader.

in fact in the early versions of the mod (before post-processing), I ran it on a low-tier laptop with a performance hit of 1 fps when the game was running at 35-40 fps.

Now on the other hand, post-processing has to render a depth buffer and the water shader has to do a LOT of math...

3 hours ago, Stevie_D said:

@blackrack Every time i see you come back to this mod it makes my inner child jump with joy. Great to see you wanna continue this onwards.

Thank you, of all the projects I work on in my free time, this is always one of the most meaningful and enjoyable.

Share this post


Link to post
Share on other sites
2 hours ago, blackrack said:

I added my response in italic, regarding the alpha values, can you provide some screens of the behaviour in question? Since the shaders switched from alpha blending to additive/soft-additive we don't have alpha anymore and instead the value added is lowered I thought it was more or less equivalent, but I guess you have more experience playing with configs, please provide some visuals so I can get an idea of whta you'd like to have.

 

The horizon line on the ocean or the one on the edge of terrain or the one in the middle of mountains? Please be specific and maybe provide screens if you can, they would help me.

Is toolbar controller a mod? I thought there was another popular mod for toolbars? The name escapes me. Anyway, what do you want exactly? To disable the button?

The thing is, while this is all technically very nice, the sky shader is already using precomputed values, it's essentially a glorified texture lookup.

Out of all the effects in scatterer, the sky shader is by far the least expensive and you wouldn't see any noticeable performance improvements either by implementing this approach or even disabling the shader.

in fact in the early versions of the mod (before post-processing), I ran it on a low-tier laptop with a performance hit of 1 fps when the game was running at 35-40 fps.

Now on the other hand, post-processing has to render a depth buffer and the water shader has to do a LOT of math...

Thank you, of all the projects I work on in my free time, this is always one of the most meaningful and enjoyable.

Yeah just to disable it. Toolbar Controller is something that tells the icon to go in Stock bar or Blizzy Toolbar or both. 

https://forum.kerbalspaceprogram.com/index.php?/topic/169509-151-toolbar-controller-for-modders/

Share this post


Link to post
Share on other sites
On 11/8/2018 at 4:05 PM, blackrack said:

I'm returning to the mod now and going to spend some more time on it, I have plenty of ideas and a lot of bugs on my list.

squeeeeee!!!

On 11/8/2018 at 5:54 PM, blackrack said:

Some ideas I have I think should have priority instead:

I'm still a big proponent of planetshine and I'm curious as to why it wasn't on this list given that you've posted some WIP shots before so I had hoped it was at least closer to being implemented than not.

Share this post


Link to post
Share on other sites
10 hours ago, blackrack said:

So actually I have a new approach in mind which should make the transition perfect by default (without finetuning), as well as fix the horizon effect

Man, for me thats the priority, and if it works, you should put that in your curriculum vitae.

Share this post


Link to post
Share on other sites
On 11/9/2018 at 9:01 PM, therealcrow999 said:

Yeah just to disable it. Toolbar Controller is something that tells the icon to go in Stock bar or Blizzy Toolbar or both. 

https://forum.kerbalspaceprogram.com/index.php?/topic/169509-151-toolbar-controller-for-modders/

I will look into it.

On 11/9/2018 at 11:56 PM, Drew Kerman said:

squeeeeee!!!

I'm still a big proponent of planetshine and I'm curious as to why it wasn't on this list given that you've posted some WIP shots before so I had hoped it was at least closer to being implemented than not.

Basically it added a lot of complexity in the interaction with other effects and I decided to finalize other things before going back to it. It also raises the question of how to interact with the planetshine mod which I haven't looked in enough to see what it can handle and if I should instead add my code to it and make scatterer compatible with it. I should get back to it.

Share this post


Link to post
Share on other sites

@blackrack Just a warning, that if you use the Toolbar Controller, it will be a hard dependence alongside with the Click Through Blocker. Another option is to add only ToolbarWrapper and implement a button placement yourself.

Share this post


Link to post
Share on other sites
13 hours ago, blackrack said:

It also raises the question of how to interact with the planetshine mod

interesting, I never thought that would be a consideration. Seemed to me implementation in Scatterer was just going to be a complete alternative to the current planetshine mod, not something to compliment it. It's not really under any active development at the moment and would better serve those people who have less-powerful computers and/or want planetshine but not all the bells and whistles of other visual mods

Share this post


Link to post
Share on other sites
13 hours ago, blackrack said:
On 11/9/2018 at 2:01 PM, therealcrow999 said:

Yeah just to disable it. Toolbar Controller is something that tells the icon to go in Stock bar or Blizzy Toolbar or both. 

https://forum.kerbalspaceprogram.com/index.php?/topic/169509-151-toolbar-controller-for-modders/

I will look into it.

FWIW, I would prefer not having to add two more functionally unrelated mods simply for the sake of using this mod.  It's not that difficult to add a checkbox config option to the mod's config dialog to say "Use Blizzy's Toolbar if Available".  I did that for Distant Object Enhancement.

Share this post


Link to post
Share on other sites
19 hours ago, Drew Kerman said:

interesting, I never thought that would be a consideration. Seemed to me implementation in Scatterer was just going to be a complete alternative to the current planetshine mod, not something to compliment it. It's not really under any active development at the moment and would better serve those people who have less-powerful computers and/or want planetshine but not all the bells and whistles of other visual mods

Hmm, I haven't really been up to date with the mod's development, but I was under the impression it had several features which I shouldn't bother reimplementing and instead should make them complement each other. Anyway, we will see, maybe it's better to do like you said.

19 hours ago, MOARdV said:

FWIW, I would prefer not having to add two more functionally unrelated mods simply for the sake of using this mod.  It's not that difficult to add a checkbox config option to the mod's config dialog to say "Use Blizzy's Toolbar if Available".  I did that for Distant Object Enhancement.

I also don't like dependencies, but I was under the impression the ToolbarWrapper linked above gets rid of the hard dependency and makes it a case of "use toolbar mod if available else use stock toolbar"

Share this post


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

I also don't like dependencies, but I was under the impression the ToolbarWrapper linked above gets rid of the hard dependency and makes it a case of "use toolbar mod if available else use stock toolbar"

You could put your interface into the settings window too, as usually, scatterer doesn't need a real-time gui: just something to set things up once how you want them.

Share this post


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

I also don't like dependencies, but I was under the impression the ToolbarWrapper linked above gets rid of the hard dependency and makes it a case of "use toolbar mod if available else use stock toolbar"

You can even have buttons in both toolbars simultanously. ToolbarWrapper is just the interface for a button in Blizzy's Toolbar (there is also a check, if toolbar is available).

Share this post


Link to post
Share on other sites

Noticed you picked up modding again, and this release has been really smooth for me! Thank you taking your precious time to keep improving this much loved mod!

Share this post


Link to post
Share on other sites

Bug report.

1. ksp x64 1.5.1

2. installed mods: scatterer only last version

3. problem: it is transparent hills.

what will I do? Can you fix it?

 

Spoiler

KSP-x64-2018-11-16-15-03-15-31.jpgKSP-x64-2018-11-16-15-17-34-77.jpgKSP-x64-2018-11-16-15-17-40-55.jpgKSP-x64-2018-11-16-15-18-08-64.jpg

 

Edited by alexus

Share this post


Link to post
Share on other sites
7 hours ago, alexus said:

Bug report.

1. ksp x64 1.5.1

2. installed mods: scatterer only last version

3. problem: it is transparent hills.

what will I do? Can you fix it?

 

  Hide contents

KSP-x64-2018-11-16-15-03-15-31.jpgKSP-x64-2018-11-16-15-17-34-77.jpgKSP-x64-2018-11-16-15-17-40-55.jpgKSP-x64-2018-11-16-15-18-08-64.jpg

 

Reproduction steps? This in dx11?

Share this post


Link to post
Share on other sites
6 hours ago, blackrack said:

Reproduction steps? This in dx11?

As far as I know, this has always been present on scatterer (might also be EVE related). At the very least both the last version and this, both dx11 and glcore. I rarely run d3d9, so am unsure if it too had the transparency on terrain. The amount of transparency changes with view angle.

Edited by Electrocutor

Share this post


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

As far as I know, this has always been present on scatterer (might also be EVE related). At the very least both the last version and this, both dx11 and glcore. I rarely run d3d9, so am unsure if it too had the transparency on terrain. The amount of transparency changes with view angle.

Only on Duna or everywhere?

I only see this on dx11 since I think 1.4

Share this post


Link to post
Share on other sites
1 minute ago, blackrack said:

Only on Duna or everywhere?

I only see this on dx11 since I think 1.4

That's actually a good question: I had only consciously noticed it on Duna since that is my go-to planet for testing things. It's not an especially noticeable effect unless you are looking for it.

I'll pay more attention when I install it again and see if I can see any specific patterns.

Share this post


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

Only on Duna or everywhere?

I only see this on dx11 since I think 1.4

everywhere.I am playing on dx11

Share this post


Link to post
Share on other sites
6 minutes ago, Electrocutor said:

That's actually a good question: I had only consciously noticed it on Duna since that is my go-to planet for testing things. It's not an especially noticeable effect unless you are looking for it.

I'll pay more attention when I install it again and see if I can see any specific patterns.

Thanks, and please look if toggling godrays affects it also.

Just now, alexus said:

everywhere.I am playing on dx11

It's broken on dx11, and I stopped supporting dx11 since it started to be unstable in KSP a few versions ago. Was that ever fixed?

Share this post


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

 Was that ever fixed?

What did you mean? dx11 is stable. can you fix it?

Share this post


Link to post
Share on other sites

dx11 is actually more stable than dx9, but the icons are broken unless you drop TU into your install.

opengl and glcore will CTD instantly if scatterer is installed and you even query all shaders (not even using them), but if in dx11 or dx12 there is no issue. (I suspect you may have a half-corrupt shader in your bundle or something that makes opengl angry when unity tries to look at it).

The most stable of all modes is glcore, but dx11 is a bit faster (both in load time and fps).

Share this post


Link to post
Share on other sites
5 minutes ago, Electrocutor said:

dx11 is actually more stable than dx9, but the icons are broken unless you drop TU into your install.

opengl and glcore will CTD instantly if scatterer is installed and you even query all shaders (not even using them), but if in dx11 or dx12 there is no issue. (I suspect you may have a half-corrupt shader in your bundle or something that makes opengl angry when unity tries to look at it).

The most stable of all modes is glcore, but dx11 is a bit faster (both in load time and fps).

Hmm, I ran opengl and glcore with no issues several times before uploading the last release...

For dx11, that's great news! It's my favourite video mode, so that means squad fixed the issue with frequent crashes in dx11 on scene changes?

Share this post


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.