Jump to content

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


Recommended Posts

3 minutes ago, Shadowmage said:

@Agustin The error is not caused by TextureReplacer, but is being triggered by TexturesUnlimited; the code with the error would appear to be in the Scatterer code that disables scatterer for reflection cameras  (I say appear, as sometimes the root cause of a problem can be not what it would seem).  The solution will likely have to come on the Scatterer end of things, though I won't know more until I can setup the Scatterer repo/build environment and dig in for some testing.

(I am quite curious why I have not seen any of these problems during my debug/testing?  Are you using DX9 by chance? )

I am using DX11, and I can't reproduce because if I reload (f5 and f9) the errors dissapear.
EDIT: I am testing and it happens whenever the bug wants it to happen. It seems very random and a quickload solves it. But it happens quite often

Edited by Agustin
Link to post
Share on other sites
1 minute ago, Agustin said:

I am using DX11, and I can't reproduce because if I reload (f5 and f9) the errors dissapear.

Thanks for the confirmation.  Just had to check if it was yet another 'DX9' related problem.

 

After a bit of reading through the Scatterer source-code, the problem would appear to be this:

https://github.com/LGhassen/Scatterer/blob/master/scatterer/DisableEffectsForTextureReplacer.cs#L34

Where neither the array, nor the elements in the array, are being checked for null prior to access.  This may or may not be an 'error' (you shouldn't always need to check for null) in that particular line of code, but would at least point to there being an error -somewhere- (if null is not a valid value for the array, then why is the preCull() method being called before the array is initialized/populated?).

I would -infer- that what is happening is that TU is rendering reflections before Scatterer is fully initialized, and thus the arrays are not populated when the method is first called.  Either way, not something that I can readily solve in TU code; the solution will need to come from Scatterer (I could potentially work around the problem in TU...but I only resort to such hacks as a last resort).


@blackrack any opposition if I were to put together a quick PR to clean up this problem?  Seems that a boolean flag that is set at the time the arrays are populated would allow for a low runtime-cost for checking if things are setup or not (a null test in Unity is often far more than a simple reference check;  a boolean test is very quick).  Could probably be as small as ~3-4 lines of changes.

 

Link to post
Share on other sites
On 30/11/2017 at 5:22 PM, Shadowmage said:

Currently I'm able to capture the standard (non-scaled space) atmosphere scattering properly during cubemap creation (e.g. while on the surface/in the atmo) -- but the scaled space scatter appears to be done as a post-process effect rather than as a rendered mesh (e.g. no atmosphere/scattering in reflections when on-orbit).  Is this still the case / changing at all?

(On that note, I would love for there to be a method to properly capture the post-process effects (ocean/scaled-space scatter) in cubemap reflection cameras; could possibly put together a PR if there was interest in such a feature/support)

To my knowledge it should be the opposite, scaledSpace effects should be fine while local post-processing should be messed up or disabled. I would like to see some screens of the local post-processing actually being captured in the cubemaps.

On 01/12/2017 at 12:05 AM, Shadowmage said:

Well, currently if you give your camera the same name as the Texture Replacer camera -- it will should remove the visual artifacts ( name:  TRReflectionCamera  ).  This is some code built-into Scatterer that disables the post-processing anytime a camera with that specific name is doing any rendering, and it works great so far from my interactions with it.

But it does this by disabling post processing for those cameras -- which, by its nature, precludes any potential to use the effects from that post-processing (god-ray-shadows, ocean surfaces, probably more I haven't poked at).

If I've read the Scatterer code correctly -- it might be possible to properly setup the post-processing effects so that they are applied to the cubemap/other cameras properly.  I say -might-, because I'm not sure how resource/computation the setup is for the different camera location/perspectives/frustum setups.  Potentially it could be 'as simple' as pushing a camera location, orientation and near/far clip data into the post-processing setup.

You can set up the camera effects to do that, but yo would also need to re-render the scatterer depth buffer for each camera as well.

I'm currently doing a bit of a hack to render one single high-accuracy depth buffer to use with the far and near local cameras (since they both share the same viewpoint), you would need to re-render this buffer for each custom camera, it's feasible. You would need to do the same with the godray depth buffer, or just ignore it and disable godrays for the secondary cameras.

I would also advise against rendering the ocean for those cubemap reflections as I think the performance hit would be quite high for something you'd barely notice in the reflections.

On 01/12/2017 at 6:22 AM, Tynton said:

@blackrack I've been trying to use some of JadeofMaar's lensflares for a mod that adds a number of new stars. Well what happened is that I ended up running out of RAM almost with only two stars after testing his lensflares. I'm not certain entirely what is going wrong but I did use the stock scatterer lensflares without issue.

On 01/12/2017 at 6:48 AM, Tynton said:

Haven't looked at this log yet but if you could link me to the exact set of lensflares and the mod that adds stars as well it would help.

17 hours ago, Agustin said:

I am trying but it's difficult. Recently I launched a rocket and everything was okay. Then I reverted to the VAB and launched again, and full of constant nullreference messages. I reverted back and launched again(exact thing I did before, seconds after launchnig) and the errors were not there anymore. Maybe I am in space and it starts to happen again with no aparent reason...

Next time it happens I will save and try to make it reproducable or something

Please provide instructions and mods to reproduce it.

15 hours ago, Shadowmage said:

Thanks for the confirmation.  Just had to check if it was yet another 'DX9' related problem.

After a bit of reading through the Scatterer source-code, the problem would appear to be this:

https://github.com/LGhassen/Scatterer/blob/master/scatterer/DisableEffectsForTextureReplacer.cs#L34

Where neither the array, nor the elements in the array, are being checked for null prior to access.  This may or may not be an 'error' (you shouldn't always need to check for null) in that particular line of code, but would at least point to there being an error -somewhere- (if null is not a valid value for the array, then why is the preCull() method being called before the array is initialized/populated?).

I would -infer- that what is happening is that TU is rendering reflections before Scatterer is fully initialized, and thus the arrays are not populated when the method is first called.  Either way, not something that I can readily solve in TU code; the solution will need to come from Scatterer (I could potentially work around the problem in TU...but I only resort to such hacks as a last resort).
@blackrack any opposition if I were to put together a quick PR to clean up this problem?  Seems that a boolean flag that is set at the time the arrays are populated would allow for a low runtime-cost for checking if things are setup or not (a null test in Unity is often far more than a simple reference check;  a boolean test is very quick).  Could probably be as small as ~3-4 lines of changes.

I haven't investigated this, but my guess would be, after a planet is unloaded or a scene change, the destroyed ocean meshRenderers are not cleared from the array.

Go ahead with the PR.

Htw I haven't really been up to date with the KSP mod scene recently, but your Textures Unlimited mod looks great, I think I will go check it out.

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

To my knowledge it should be the opposite, scaledSpace effects should be fine while local post-processing should be messed up or disabled. I would like to see some screens of the local post-processing actually being captured in the cubemaps.

You are more than likely correct.  I had assumed it was the scaled-space stuff that was not being captured, as the reflections appeared to not have much atmosphere while in-orbit, but look fine while in-atmo.

But looking at things a bit more in depth (read:   just watching the reflections as MJ flies...), it actually seems to be capturing things fairly well...

Lower in atmo (oceans missing, but that is to be expected, and hardly noticeable:

8DR18ux.png

125km/LKO - seems to be working well here as well.  At least good enough for a reflection probe camera.

qWngujh.png

So I guess this is a 'nothing to see here'.

(there -might- have been some rendering order/layering issues in TU that I cleaned up recently that was causing me to think the from-orbit atmosphere was not being captured;  as it obviously is working fine in the screnshots above)

 

5 hours ago, blackrack said:

You can set up the camera effects to do that, but yo would also need to re-render the scatterer depth buffer for each camera as well.

Which was what I was kind of afraid of, and probably not worth it in the long run for these low(ish)-res reflections.  Normally these reflections are blurred / convolved, so the details like godrays/oceans would be obscured by the blurring anyway.

Thanks for the confirmation and information either way though.

6 hours ago, blackrack said:

I haven't investigated this, but my guess would be, after a planet is unloaded or a scene change, the destroyed ocean meshRenderers are not cleared from the array.

Go ahead with the PR.

Yeah, that seems like it could be a likely culprit.   I'll work on a PR as soon as I can find out how to duplicate/trigger the problem -- it doesn't seem to happen during any of my normal play/testing workflow, so need to find how to duplicate it first.  After that, should be relatively simple to fix it up in one place or another (depending on exactly what the cause is).

 

6 hours ago, blackrack said:

Htw I haven't really been up to date with the KSP mod scene recently, but your Textures Unlimited mod looks great, I think I will go check it out.

Thanks :)   Yeah, TU is quite new, only been released for a few weeks... still going through some growing pains and optimization work.

Its really not too much more than some Unity-Standard (PBR) shader analogues, a few config-based texture-set/texture-replacement handling functions, and a collection of hacks and workarounds to get reflection-probes working in KSP.  The PBR shaders though, once proper textures are created for them, can really be very visually stunning (and can even make the existing stock textures/parts much more appealing).

Link to post
Share on other sites
16 minutes ago, Shadowmage said:

Lower in atmo (oceans missing, but that is to be expected, and hardly noticeable:

rGVinF9.jpg

Notice also that there is no scattering effects on the mountains. As it requires depth information, I've disabled it for texture replacer so only the sky is visible.

Anyway, from my own testing with texture replacer I noticed that the atmosphere may not reflect at 100km altitude but will reflect in scaledSpace (160km+), not sure why here but maybe texture replacer stops rendering the local layers above a certain altitude (the sky is rendered in the background of the local camera until we switch to scaledSpace), if your reflections work everywhere however then all the better.

I figured as well that we can get away with just the sky being visible as it's mostly not noticeable for reflections.

Anyway, best of luck with your mod, and if you manage to reproduce the issue let me know so I can look at it as well.

Edited by blackrack
Link to post
Share on other sites

I'm having a bit of an issue, it's so dark! I have a picture of an early probe I'm launching, and even in full daytime, there's absolutely no sunlight on the probe. I actually wasn't having this issue until I upgraded to the most recent CKAN version of Scatterer. The two snags I can think of are that I am running KScale set to a 6.4 rescale, and I also have Stock Visual Enhancements, but I am not sure if I have a config conflict or what the specific problem could be.

Edit: I also have the Valentine star system installed. Could having two light sources be causing the issue?

Edit: Yup, it was the Extrasolar mod.

Two pictures showing my problem - https://imgur.com/a/ytagI

Edited by Javascap
Link to post
Share on other sites
2 hours ago, Javascap said:

I'm having a bit of an issue, it's so dark! I have a picture of an early probe I'm launching, and even in full daytime, there's absolutely no sunlight on the probe. I actually wasn't having this issue until I upgraded to the most recent CKAN version of Scatterer. The two snags I can think of are that I am running KScale set to a 6.4 rescale, and I also have Stock Visual Enhancements, but I am not sure if I have a config conflict or what the specific problem could be.

Edit: I also have the Valentine star system installed. Could having two light sources be causing the issue?

Edit: Yup, it was the Extrasolar mod.

Two pictures showing my problem - https://imgur.com/a/ytagI

Extra solar needs to update the star cfgs to work properly with the latest Kopernicus.

I also highly recommend not using Kscale, and not just because I made this mod. KScale is not as comprehensive as these cfgs and will make your scaled planets work seamlessly with SVE.

 

Edited by Galileo
Link to post
Share on other sites

Im not poking the bear :) Just wondering if there are any plans to make cfgs stable/compatible with galactic neighborhood? Currently kerbin is half blue(looks like a thick atmophere) im going to try the fix mentioned with the known issues. But just wondering. It may be a graphic issue with planetshine or sve..but im not sure just yet. Sigma states GN would need some custom cfgs to work properly. Possibly in the works for the future? Thanks!

Link to post
Share on other sites

Hello yes,

i would like to know what value in the config file is responsible for changing the colour of the atmosphere scatter. I'm trying to get Jool to be blue for Alternis planet pack (the one with kerbin orbiting aroud blue jool with bop as the moon).

Link to post
Share on other sites

Is there any way to improve performance with this?

I have a computer that can run basically any KSP mod and have a solid 40 FPS (albeit run out of memory) with the exception of scatterer which bogs me to 10-20, and it's really bumming me out.

Link to post
Share on other sites

Yeah, I'm also having some serious performance issues with this and 1.3. I just got a new Surface Book 2 13.5"  with an i7, 16GB RAM and GTX 1050, and the frame rate is terrible with Scatterer installed while running at 1900x1200 resolution. The specs on this machine should be more than sufficient to run smoothly at decent framerates with simple rockets.

Link to post
Share on other sites
14 minutes ago, Tandoori said:

Yeah, I'm also having some serious performance issues with this and 1.3. I just got a new Surface Book 2 13.5"  with an i7, 16GB RAM and GTX 1050, and the frame rate is terrible with Scatterer installed while running at 1900x1200 resolution. The specs on this machine should be more than sufficient to run smoothly at decent framerates with simple rockets.

Have you turned off water refraction..? that is what is getting most people.

Link to post
Share on other sites

Good morning,

Firstly, thanks Blackrack, and everyone else who has contributed to this mod, it is simply amazing and you should be proud of how much better you have made the game look.

However, I have a couple of minor graphics glitches that I have chased back to Scatterer I think. I don't think any of them are a problem with Scatterer itself, but could both be fixed by changing some settings in the Scatterer config menu... however, I am not sure which ones

Firstly, I have a thin darker line alongside the right side of all my craft in Kerbins atmosphere, it looks like there is a band a couple of pixels wide where the Scatterer effects aren't implemented and un-modded Kerbin is showing through. This seems particularly noticeable over water, and seems to fade away by the time my crafts are in space. Frustratingly, it is not present in screenshots so my vague description is all I have.

Secondly, the whitecap effect only shows when there is something behind it. If i have a Kerbal floating in the ocean, the whitecaps only appear overlaid on the parts of his body that are refracted and don't appear on water with nothing behind it.

Neither of these glitches is game breaking for me and are more likely a result of my creaky old laptop. If you think they are worth looking into and not issues that can be solved with the right settings tweaks, I can sort out a fresh install and submit logs, but don't worry about it if you are busy, have bigger problems to solve or cant be bothered!

Thanks again and happy xmas for those who celebrate it :)

BF

Link to post
Share on other sites
On 12/2/2017 at 11:55 AM, blackrack said:

rGVinF9.jpg

Notice also that there is no scattering effects on the mountains. As it requires depth information, I've disabled it for texture replacer so only the sky is visible.

Anyway, from my own testing with texture replacer I noticed that the atmosphere may not reflect at 100km altitude but will reflect in scaledSpace (160km+), not sure why here but maybe texture replacer stops rendering the local layers above a certain altitude (the sky is rendered in the background of the local camera until we switch to scaledSpace), if your reflections work everywhere however then all the better.

I figured as well that we can get away with just the sky being visible as it's mostly not noticeable for reflections.

Anyway, best of luck with your mod, and if you manage to reproduce the issue let me know so I can look at it as well.

Maybe this has something to do with the 3 layers of planet rendering. While on the ground, it uses terrain shader rendering; at KSC it uses PQS shader rendering, higher up it uses scaled-space shader rendering.

Edited by Electrocutor
Link to post
Share on other sites
On 18.12.2017 at 9:58 AM, Pavel ☭ said:

Is there any way to improve performance with this?

I have a computer that can run basically any KSP mod and have a solid 40 FPS (albeit run out of memory) with the exception of scatterer which bogs me to 10-20, and it's really bumming me out.

 

On 19.12.2017 at 7:07 PM, Tandoori said:

Yeah, I'm also having some serious performance issues with this and 1.3. I just got a new Surface Book 2 13.5"  with an i7, 16GB RAM and GTX 1050, and the frame rate is terrible with Scatterer installed while running at 1900x1200 resolution. The specs on this machine should be more than sufficient to run smoothly at decent framerates with simple rockets.

Can confirm. i7 2600K @ 4.4 GHz, GTX 970, 16GB RAM at 1920x1080 and my performance is also tanking like crazy with Scatterer installed on my modded KSP install. I get a solid 60fps without it and 30-40fps with it even though my CPU, GPU, RAM and VRAM are nowhere near maxed out*. Disabling ocean refractions as per @Galileo's instructions only gave me a few extra frames at most (I can't really even tell if it did anything because the framerate is all over the place).

*CPU ~45%, GPU ~40%, VRAM ~40%, RAM ~75%

Edited by CaptainKorhonen
Link to post
Share on other sites

Using Stock Visual Enhancements, for some reason the orange haze effect on the side of Kerbin and probably other planets is not present.

http://steamcommunity.com/sharedfiles/filedetails/?id=1241442497

Is there a way to fix this myself? (increase a value for orange haze)

Link to post
Share on other sites
On 25/11/2017 at 6:16 PM, blackrack said:

I think I may have fixed the halo issue for good, can you guys confirm?

https://mega.nz/#!nN4EGRQB!Vi_QanmE9XdOQ2IBPQn6UZExvXL_xAEUBCZx6gPZ9mM

paging @Epoxid

Hey everyone ! I just tested by replacing with this files and, yes the halo is gone but so is the water surface on Kerbin ... 

Why me ?
https://imgur.com/a/xK8Lc

Link to post
Share on other sites
On 01/10/2017 at 2:36 PM, Kearla said:

Hey y'all. Anyone know's what causes the white sky? I tried to remove all mods, only have scatterer and the Squad folder in GameData. When i removed Scatterer, it solved the problem, except i cannot use the mods that are using Scatterer.
https://imgur.com/a/t0in8

Was this question ever answered? I've been searching the pages, and either I keep missing the reply, or it was missed and left unanswered. I'm having this issue now too...

EDIT: I also had this issue when I tried SVE:

 

Using Stock Visual Enhancements, for some reason the orange haze effect on the side of Kerbin and probably other planets is not present.

http://steamcommunity.com/sharedfiles/filedetails/?id=1241442497

Is there a way to fix this myself? (increase a value for orange haze)

Edited by Errol
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...