Jump to content

[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


blackrack
 Share

Recommended Posts

I'm trying to track down the cause of a graphics anomaly and some think it might be Scatterer related.  I have previously moved my save file and deleted then reinstalled KSP  with no change.  Just deleted and reinstalled Scatterer with no change.  If not Scatterer, then what else could be doing this?   Graphics mods are:  Scatterer, Waterfall, and EVE.

u4tsmEF.jpg

Link to comment
Share on other sites

On 5/29/2022 at 10:01 PM, Rakete said:

I guess, i found an incompability between Scatterer and Waterfall. Sorry in advance.

See in the picture below. As soon, as Scatterer is installed (tested with Spectra and also with Astronomer's Pack - both the same) the plumes of waterfallized engines tend to show less beautiful flickering shadows around the end of the engine bells. It gets visible as you reach the upper atmosphere and beyond. Here you see the waterfallized Wolfhound engine from stock KSP.

@Knight of St John @blackrack

Removing Scatterer restores the flickering-shadow-free engine plumes by Knight of St. John using Waterfall.

 

wK4Fy8C.png

Yes I've noticed this too. it's caused by the mesh being very close to the engine bell wall. it also happens with other configs.
this issue will be fixed on my end with the newer plumes I've been configuring (vector, mammoth, rcs, nerv, and more to come), because those use a different effect for engine bell glow.

Link to comment
Share on other sites

There is something else for which I would love some input from the developers of Scatterer.
With one of the effects in waterfall, a shader more specifically, I'm using a custom depth test in the pixel shader.
This is necessary for detecting plume collisions with solid objects, and subsequently adjusting the visuals of the plume so that you don't get ugly clipping effects, much like the one Rakete encountered above.

For this, I need access to the _CameraDepthTexture resource in my shader. This works fine in KSP, unless when the craft is in a planet's shadow, like at night.
Then, the KSP rendering pipeline suddenly changes and the _CameraDepthTexture becomes unavailable, and the shader receives a default grey texture instead, bugging out the effect.
I believe this is because KSP doesn't need to render shadows anymore at night (or behind planets) and therefore drops a number of render passes, including the one where the _CameraDepthTexture is created. (probably because thats necessary for creating shadows).

here is an illustration of the bug happening in a renderdoc capture, just before sundown:

Spoiler

unknown.png

and this is right after sundown:

Spoiler

unknown.png


In order to fix this bug, I somehow need a way of reintroducing a pass where the _CameraDepthTexture is created. However, I've noticed that when Scatterer is installed, this issue is fixed, since Scatterer also needs the _CameraDepthTexture, even at night (or that is my conjecture). So I guess yay for Scatterer :D . However, I would love to know how I could fix this on my end as well. I'm rather new to working with the rendering pipeline, so I thought to ask the experienced people for some guidance.

Link to comment
Share on other sites

14 hours ago, Knight of St John said:

There is something else for which I would love some input from the developers of Scatterer.
With one of the effects in waterfall, a shader more specifically, I'm using a custom depth test in the pixel shader.
This is necessary for detecting plume collisions with solid objects, and subsequently adjusting the visuals of the plume so that you don't get ugly clipping effects, much like the one Rakete encountered above.

For this, I need access to the _CameraDepthTexture resource in my shader. This works fine in KSP, unless when the craft is in a planet's shadow, like at night.
Then, the KSP rendering pipeline suddenly changes and the _CameraDepthTexture becomes unavailable, and the shader receives a default grey texture instead, bugging out the effect.
I believe this is because KSP doesn't need to render shadows anymore at night (or behind planets) and therefore drops a number of render passes, including the one where the _CameraDepthTexture is created. (probably because thats necessary for creating shadows).

here is an illustration of the bug happening in a renderdoc capture, just before sundown:

  Reveal hidden contents

unknown.png

and this is right after sundown:

  Reveal hidden contents

unknown.png


In order to fix this bug, I somehow need a way of reintroducing a pass where the _CameraDepthTexture is created. However, I've noticed that when Scatterer is installed, this issue is fixed, since Scatterer also needs the _CameraDepthTexture, even at night (or that is my conjecture). So I guess yay for Scatterer :D . However, I would love to know how I could fix this on my end as well. I'm rather new to working with the rendering pipeline, so I thought to ask the experienced people for some guidance.

I think it was as easy as enabling the camera's depth texture via https://docs.unity3d.com/ScriptReference/Camera-depthTextureMode.html

So find every camera you apply the effects to and apply it like this https://github.com/LGhassen/Scatterer/blob/1bca4720cf9bad0062aa6fc11c894b90622de7f6/scatterer/Effects/Proland/Atmosphere/Utils/ScreenSpaceScatteringContainer.cs#L124

 

On 7/19/2022 at 7:01 PM, miklkit said:

I'm trying to track down the cause of a graphics anomaly and some think it might be Scatterer related.  I have previously moved my save file and deleted then reinstalled KSP  with no change.  Just deleted and reinstalled Scatterer with no change.  If not Scatterer, then what else could be doing this?   Graphics mods are:  Scatterer, Waterfall, and EVE.

u4tsmEF.jpg

I can't really tell which anomaly you are referring to

Link to comment
Share on other sites

On 7/23/2022 at 8:03 AM, blackrack said:

Ah thank you so much. I was looking around the whole day yesterday, and arrived at that solution as well, but didn't know if it was correct. the syntax example is also really helpful.

UPDATE: this was indeed the fix we needed. thanks again!

Edited by Knight of St John
Link to comment
Share on other sites

Hello @miklkit, this issue is due to "adjustScaledTexture" set to on. Personally, I set it to off (adjustScaledTexture = False) and I use another texture to Kerbin. I adjust brightness, contrast and saturation directly on this new texture and load it in game by a texture replacer mod named DiRT.

Link to comment
Share on other sites

15 minutes ago, Vandest said:

Hello @miklkit, this issue is due to "adjustScaledTexture" set to on. Personally, I set it to off (adjustScaledTexture = False) and I use another texture to Kerbin. I adjust brightness, contrast and saturation directly on this new texture and load it in game by a texture replacer mod named DiRT.

Specifically it's due to different land and ocean settings for this feature and the detection of coasts being a bit off.

So a simpler way is to have the same settings for both.

Link to comment
Share on other sites

Do second suns add any noticeable lag? I'm experimenting with making Jool a second sun to reflect on Laythe:
V2WRAig.png

If it doesn't add any additional lag I might include it by default

Link to comment
Share on other sites

On 7/27/2022 at 4:42 AM, HafCoJoe said:

Do second suns add any noticeable lag? I'm experimenting with making Jool a second sun to reflect on Laythe:
V2WRAig.png

If it doesn't add any additional lag I might include it by default

Not at all noticeable. It only applies to atmo/clouds though. If you add an actual sun with kopernicus (so that it will light up ships and terrain) it will be a bit slower.

Link to comment
Share on other sites

On 7/26/2022 at 6:28 AM, Vandest said:

Hello @miklkit, this issue is due to "adjustScaledTexture" set to on. Personally, I set it to off (adjustScaledTexture = False) and I use another texture to Kerbin. I adjust brightness, contrast and saturation directly on this new texture and load it in game by a texture replacer mod named DiRT.

Hi!  I've been away for a while and just got back.  I have gone into steam->steamapps->common->Kerbal space Program->GameData->Scatterer->config->Planets->Kerbin and found the atmo.cfg and ocean.cfg.  In atmo.cfg I found "adjustscaledTexture" and set it to "False".  It is not in ocean.cfg.  so after that one change I saved and started KSP and the problem is solved! 

As a humble end user I have never touched any of the settings before and am now wondering why it is set to "True" in the first place.  This has been bothering me for well over a year now. 

Link to comment
Share on other sites

  • 3 weeks later...
4 hours ago, blackrack said:

Just pushed a small bugfix update, most notably fixing jittering UI elements with TAA and the above mentioned seams/artifacts caused by "adjustScaledTexture". Enjoy.

I don't know what, but something seems to have broken since last version.

Log: https://drive.google.com/drive/folders/1fxVzz0yXvo_dzl9Q0O6k2klkxdcpqM_b?usp=sharing

1KyAdXY.png

Link to comment
Share on other sites

There's still some exceptions regarding EVE:
 

Spoiler

[EXC 18:55:16.455] NullReferenceException: Object reference not set to an instance of an object
    Atmosphere.CloudsPQS+<DelayedCheckForSphereInactive>d__28.MoveNext () (at <344479ccb68743409608815de7dc27b3>:0)
    UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <5aeafee3fea24f37abd1315553f2cfa6>:0)
    UnityEngine.DebugLogHandler:LogException(Exception, Object)
    ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
    UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)
[EXC 18:55:16.455] NullReferenceException: Object reference not set to an instance of an object
    Atmosphere.CloudsPQS+<DelayedCheckForSphereInactive>d__28.MoveNext () (at <344479ccb68743409608815de7dc27b3>:0)
    UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <5aeafee3fea24f37abd1315553f2cfa6>:0)
    UnityEngine.DebugLogHandler:LogException(Exception, Object)
    ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
    UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)
[EXC 18:55:16.455] NullReferenceException: Object reference not set to an instance of an object
    Atmosphere.CloudsPQS+<DelayedCheckForSphereInactive>d__28.MoveNext () (at <344479ccb68743409608815de7dc27b3>:0)
    UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <5aeafee3fea24f37abd1315553f2cfa6>:0)
    UnityEngine.DebugLogHandler:LogException(Exception, Object)
    ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
    UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)

And also it seems in the latest update these ones started happening: 
 

Spoiler

[LOG 18:55:17.300] [Scatterer][Debug] Raymarched volumetric clouds error on planet: KerbinSystem.NullReferenceException: Object reference not set to an instance of an object
  at scatterer.EVEReflectionHandler.mapEVEVolumetrics (System.String celestialBodyName, System.Collections.Generic.List`1[T] EVEvolumetrics) [0x00156] in <239e845189cf4197ad041de3c91e4987>:0 
[LOG 18:55:17.300] [Scatterer][Debug] Raymarched volumetric clouds error on planet: KerbinSystem.NullReferenceException: Object reference not set to an instance of an object
  at scatterer.EVEReflectionHandler.mapEVEVolumetrics (System.String celestialBodyName, System.Collections.Generic.List`1[T] EVEvolumetrics) [0x00156] in <239e845189cf4197ad041de3c91e4987>:0 

Don't know how serious these are. 

Link to comment
Share on other sites

Posted (edited)
49 minutes ago, dok_377 said:

There's still some exceptions regarding EVE:
 

  Reveal hidden contents

[EXC 18:55:16.455] NullReferenceException: Object reference not set to an instance of an object
    Atmosphere.CloudsPQS+<DelayedCheckForSphereInactive>d__28.MoveNext () (at <344479ccb68743409608815de7dc27b3>:0)
    UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <5aeafee3fea24f37abd1315553f2cfa6>:0)
    UnityEngine.DebugLogHandler:LogException(Exception, Object)
    ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
    UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)
[EXC 18:55:16.455] NullReferenceException: Object reference not set to an instance of an object
    Atmosphere.CloudsPQS+<DelayedCheckForSphereInactive>d__28.MoveNext () (at <344479ccb68743409608815de7dc27b3>:0)
    UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <5aeafee3fea24f37abd1315553f2cfa6>:0)
    UnityEngine.DebugLogHandler:LogException(Exception, Object)
    ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
    UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)
[EXC 18:55:16.455] NullReferenceException: Object reference not set to an instance of an object
    Atmosphere.CloudsPQS+<DelayedCheckForSphereInactive>d__28.MoveNext () (at <344479ccb68743409608815de7dc27b3>:0)
    UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <5aeafee3fea24f37abd1315553f2cfa6>:0)
    UnityEngine.DebugLogHandler:LogException(Exception, Object)
    ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
    UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)

And also it seems in the latest update these ones started happening: 
 

  Hide contents

[LOG 18:55:17.300] [Scatterer][Debug] Raymarched volumetric clouds error on planet: KerbinSystem.NullReferenceException: Object reference not set to an instance of an object
  at scatterer.EVEReflectionHandler.mapEVEVolumetrics (System.String celestialBodyName, System.Collections.Generic.List`1[T] EVEvolumetrics) [0x00156] in <239e845189cf4197ad041de3c91e4987>:0 
[LOG 18:55:17.300] [Scatterer][Debug] Raymarched volumetric clouds error on planet: KerbinSystem.NullReferenceException: Object reference not set to an instance of an object
  at scatterer.EVEReflectionHandler.mapEVEVolumetrics (System.String celestialBodyName, System.Collections.Generic.List`1[T] EVEvolumetrics) [0x00156] in <239e845189cf4197ad041de3c91e4987>:0 

Don't know how serious these are. 

No idea about the first one but the second one is harmless (integration code for upcoming volumetric clouds that just disables for now without any side effects).

Edited by blackrack
Link to comment
Share on other sites

can you please add something to the settings for creating new worlds? I'm not a huge fan of the graphics in this mod, the stock graphics are more my jam, and my brother likes the graphics in this mod. its a conflict of interest.

sorry if I sounded rude.

Edited by Kerbal410
Link to comment
Share on other sites

Hi there!
I've been trying to convert BallisticFox's Beyond Home repo to use the old Scatterer sunflares so that I could edit the Ghost1 on Destiny to get rid of the baked in lens dirt of the included Unity3D sunflare.  I've gotten like... 99% of the way there I think.  When loading in game, everything looks right, lens dirt gone, Destiny Fate and Kerbol all have their sunflare, and the barycenter is transparent as it should be.  However I'm getting unrelenting NRE spam.   I managed to diagnose some of it, it was complaining about a bad path, and then a missing ghost3 texture for the transparent barycenter (or Sun).  After sorting those it's still complaining about something and I'm completely stumped.

Here's an excerpt from player.log
 

Spoiler


[Scatterer][Debug] Disabling stock sunflare for Destiny 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 35)

Uploading Crash Report
NullReferenceException: Object reference not set to an instance of an object
  at scatterer.SunFlare.updateProperties () [0x00006] in <684aa87c0d2345f8a9e4739403f4afff>:0 
  at scatterer.SunflareCameraHook.OnPreRender () [0x00008] in <684aa87c0d2345f8a9e4739403f4afff>:0 
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)
 
(Filename: <684aa87c0d2345f8a9e4739403f4afff> Line: 0)

Cobbling together configs to try and make this work is already pushing the extent of my capabilities, trying to diagnose what's leading to this NRE spam has me entirely lost.  It's pretty frustrating because visually I've accomplished my goal but clearly I've broken something.  Any help that anyone can provide would be greatly appreciated.

Here's a link to a google drive folder with the sunflare.cfg, as well as my KSP.log and player.log

If you need me to provide anything else just ask.   Thanks in advance for any help!

Link to comment
Share on other sites

11 hours ago, DeliriumTrigger said:

Hi there!
I've been trying to convert BallisticFox's Beyond Home repo to use the old Scatterer sunflares so that I could edit the Ghost1 on Destiny to get rid of the baked in lens dirt of the included Unity3D sunflare.  I've gotten like... 99% of the way there I think.  When loading in game, everything looks right, lens dirt gone, Destiny Fate and Kerbol all have their sunflare, and the barycenter is transparent as it should be.  However I'm getting unrelenting NRE spam.   I managed to diagnose some of it, it was complaining about a bad path, and then a missing ghost3 texture for the transparent barycenter (or Sun).  After sorting those it's still complaining about something and I'm completely stumped.

Here's an excerpt from player.log
 

  Reveal hidden contents

 

 

[Scatterer][Debug] Disabling stock sunflare for Destiny 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 35)

Uploading Crash Report
NullReferenceException: Object reference not set to an instance of an object
  at scatterer.SunFlare.updateProperties () [0x00006] in <684aa87c0d2345f8a9e4739403f4afff>:0 
  at scatterer.SunflareCameraHook.OnPreRender () [0x00008] in <684aa87c0d2345f8a9e4739403f4afff>:0 
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)
 
(Filename: <684aa87c0d2345f8a9e4739403f4afff> Line: 0)

Cobbling together configs to try and make this work is already pushing the extent of my capabilities, trying to diagnose what's leading to this NRE spam has me entirely lost.  It's pretty frustrating because visually I've accomplished my goal but clearly I've broken something.  Any help that anyone can provide would be greatly appreciated.

Here's a link to a google drive folder with the sunflare.cfg, as well as my KSP.log and player.log

If you need me to provide anything else just ask.   Thanks in advance for any help!

I see on discord that you found the issue. Next time try to update the flare settings from the UI, that should save you a lot of time when testing configs.

Link to comment
Share on other sites

11 hours ago, blackrack said:

I see on discord that you found the issue. Next time try to update the flare settings from the UI, that should save you a lot of time when testing configs.

That discord message was a bit premature, I did find and fix the texture path issue that was causing the sunflare to not work at all.  And then a missing texture issue which was causing some NRE spam, as I said above.  And then I got stumped by mystery NRE spam which is ongoing and doesn't have an obvious (to me) source that's outlined in player.log like the other two problems I solved on my own.

Also, I've tried to use the in-game editor but pressing the key combination just brings up the same menu that pops up when I click the menu icon at the KSC.  The only thing I can change under "sunflare" in that menu is a single toggle.

Edited by DeliriumTrigger
Link to comment
Share on other sites

6 hours ago, DeliriumTrigger said:

That discord message was a bit premature, I did find and fix the texture path issue that was causing the sunflare to not work at all.  And then a missing texture issue which was causing some NRE spam, as I said above.  And then I got stumped by mystery NRE spam which is ongoing and doesn't have an obvious (to me) source that's outlined in player.log like the other two problems I solved on my own.

Also, I've tried to use the in-game editor but pressing the key combination just brings up the same menu that pops up when I click the menu icon at the KSC.  The only thing I can change under "sunflare" in that menu is a single toggle.

Do it in flight and not at the ksc scene

Link to comment
Share on other sites

5 hours ago, DeliriumTrigger said:

I don't see how this will help me with the NREs but okay i guess

The configs look good and the log is humongous with no immediately visible issues. Your best bet is removing flares one by one to narrow it down and then just changing stuff and seeing what happens.

Link to comment
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.

 Share

×
×
  • Create New...