Author Topic: Global Snow issues  (Read 810 times)

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 5137
    • View Profile
Re: Global Snow issues
« Reply #15 on: August 14, 2019, 06:00:29 AM »
Thanks for the additional info. A repro would be definitely great, although I understand it's not practical due to the size of your scene.

Try latest beta (b2) and check if:
- Flicker goes away.
- Performance of OnPreCull and CommandBuffer.BeforeReflections.

Also make sure your "Coverage Update" setting is not set to "Every Frame".

Regards

sebastianc

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Global Snow issues
« Reply #16 on: August 14, 2019, 02:51:24 PM »
The project with all assets is around 20G so a repro is not too practical.

The flicker definitively changed - now it only appears during camera movement and seldomly at that. Let's put that aside for a moment.

Here's a screenshot of a deep profile that also has the GS settings visible:
- the left side is with GS active, right side of the profile with it deactivated
- the actual GS times don't look too bad even with deep profile as this is ran on a pretty powerful station but they are closer to what I posted earlier on a more average PC
- side note - the total script time is inflated by Vegetation System going nuts in deep profile - besides the point, just in case you were wondering :)

Issue is with OnBeforeReflections and OnPreCull - now there may be some optimizations possible there (perhaps?) but I think the strategy used for deferred is wrong for my scenario - that is - at any time, on screen, I will have A LOT more objects that don't need to be snowed than objects that need to be snowed - and GS does work proportional with the excluded objects.

Now I have only 3 types of objects that I ever need to be snowed:
1. Terrain (where at worst I could replace the grass texture with a snow one)
2. Trees - I have about 20k on the map but at most a couple hundred visible at one time
3. Roofs - max 3-4 objects per building, so less than 100 visible at a time

I have lists and easy access to these objects in my code.

So I wonder if it isn't possible to forgo the main GS script altogheter and just change the material / shader on these objects when they need to be snowed. Or somehow else mark these objects to be snowed without GS having to do any work for all the other objects that it can safely ignore.

I'll admit, this issue is exacerbated by my game objects not being optimized and I do intend to merge a lot of gameobjects down the road but I still feel that this strategy will not be optimal long term.

Thanks!

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 5137
    • View Profile
Re: Global Snow issues
« Reply #17 on: August 16, 2019, 08:45:11 AM »
GS only spends time with visible objects. Any excluded object that's not visible in the frustum is not processed.

But yes, if you have hundred of trees in front of you and they're not being covered by snow, it can be a burden. In this scenario you may want to try Global Snow - Decal version. It's available from the beta board as well. Download it and try it on another simple project first, before replacing your actual Global Snow package in your project. Global Snow - Decal version uses a different approach. It adds  an additional snow material only to the desired objects. It does it automatically based on your inspector preferences (pretty much like Global Snow looks but internally works very differently).

I'm investigating the possibility to use direct Global Snow injection into the GBuffers using only the affected objects. That could be useful in your scenario, although it will be less performant than the natural solution which uses the GBuffer to render global snow on many objects using a single pass.

« Last Edit: August 16, 2019, 08:50:52 AM by Kronnect »

sebastianc

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Global Snow issues
« Reply #18 on: August 16, 2019, 09:41:46 AM »
Sounds good, I'll try the decal.

As to exclude/include I think it's ideal to support both. Some people will have many included objects visible, some will have many excluded objects visible.

My particular case is that I have house interiors which contain a lot of objects that are obviously excluded. Now when you have a village and zoom out to see 20 houses at a time that becomes problematic.

sebastianc

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Global Snow issues
« Reply #19 on: August 20, 2019, 04:35:45 AM »
Had a look at the decal version.

First issue I hit - is there a known way to make it work with Vegetation Studio?

Given the workflow, I expected GlobalSnow not to pick up the Vegetation Studio trees (which it doesn't). I then tried to add the prefab with snow applied to VS but VS didn't seem to pickup the snow extra material. I guess it might be related to the fact that if I try to save the prefab with snow applied Unity doesn't properly save the extra material either.

Trees are SpeedTree 8, Unity is 2019.1

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 5137
    • View Profile
Re: Global Snow issues
« Reply #20 on: August 20, 2019, 04:59:28 AM »
Not sure, perhaps you should send a simple repro to Lennart and see if it's just that VS doesn't allow multi-material objects or if it's something else.

sebastianc

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Global Snow issues
« Reply #21 on: August 20, 2019, 06:08:39 AM »
I think it's from the way the material is assigned.

- Tree on the left:
Speed tree that GS added snow to - looks good.

- Tree in the middle
Saved the previous tree as a prefab and added back. The GS material is lost.

- Tree on the right
Same as tree in the middle, added material manually - results not good :)

Think if it saves correctly as a prefab, VS will handle it properly as well.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 5137
    • View Profile
Re: Global Snow issues
« Reply #22 on: August 21, 2019, 12:54:23 AM »
Fixed a refreshing issue with GS Decals version and did a few more tests.

1.- Create a new scene.
2.- Add a sphere and mark it as static.
3.- Add GS2 to Main Camera. Press "Add Snow".
4.- Save sphere as prefab.
5.- Create a new scene.
6.- Drag & drop the prefab.
7.- Add GS2 to Main Camera.
8.- Snow appears on the sphere.

Let me know if it work on your end. I haven't tested this with trees.

sebastianc

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Global Snow issues
« Reply #23 on: August 21, 2019, 02:17:34 AM »
It does work on the sphere but not on the speed tree.

The difference is in the material used.

For the sphere it uses GlobalSnow Overlay which is saves okay in the prefab.
For the speed tree it uses GlobalSnow Overlay TransparentCutout(Clone) which doesn't get saved properly.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 5137
    • View Profile
Re: Global Snow issues
« Reply #24 on: August 22, 2019, 07:16:35 AM »
Umm. Not sure what could be the issue.

Just tested using a TreeCreator tree and also a SpeedTree. In both cases it worked fine. Remember that you still need to add Global Snow to the camera so certain global shader uniforms are properly set (like snow altitude).

Here's a video with my test. Hopefully you can spot the diferences:
https://youtu.be/WqIRmiiP08g


sebastianc

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Global Snow issues
« Reply #25 on: August 22, 2019, 07:36:48 AM »
Only 2 differences I can think about:

- I'm using Unity 2019.1
- The particular SpeedTree I use

If you give me an email address I can send you the tree (prob not a good idea to post it publicly). If it's not that I can give it a try in 2017 / you can see what happens in 2019.

sebastianc

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Global Snow issues
« Reply #26 on: August 23, 2019, 02:41:27 AM »
Hmm, wanted to try it in Unity 2017 but hit a snag - Speed Tree 8 is Unity 2018.3+ only. Let me know if you manage to try it in 2018.3 or 2019.1...