visualdesigncafe / nature-renderer

Nature Renderer is a plugin for the Unity game engine to efficiently render vegetation on your terrains.
https://visualdesigncafe.com/nature-renderer/
0 stars 0 forks source link

Vegetation (details) flicker on details layer(s) edition #4

Open valentin56610 opened 9 months ago

valentin56610 commented 9 months ago

Describe the bug Whenever I edit the details layer on the terrain and call for a refresh from nature renderer, the vegetation flickers

To Reproduce Code used: https://pastebin.com/ncnJ2sj6

Expected behavior The details changes should simply happen without having the entire terrain's vegetation flicker.

Screenshots

Project(please complete the following information): Nature Renderer version 2022.0.2 Unity version 2022.3.5f1, Standard Render Pipeline, Silicon version

System (please complete the following information):

Additional context The changelog of version 2022.0.2 states that the flicker issue has been fixed, but it has not

maxplooi commented 8 months ago

Thank you for reporting this. Could you share a short video of the flickering? I am looking into it for your but I can't seem to reproduce any flickering.

One thing you could verify is that there are no other terrain settings changed by any scripts. Nature Renderer uses the TerrainChangedFlags to determine if the terrain changed. If it receives the FlushEverythingImmediately flag then Nature Renderer will restart, which can cause flickering because all the existing data is disposed and then reloaded. This flag should only be used when changing terrain settings but it is possible that some script in your project is using that flag for other reasons. The same happens when changing terrain settings such as detail resolution or density, because they require a full reload.

(You can use the example code in the TerrainChangedFlags page to check what flags are being received by the terrain and Nature Renderer, just add that script as component to the terrain and log all the flags)

valentin56610 commented 8 months ago

Hello Max,

Thanks for getting back to me

Sure thing, here you go, video 1: https://youtu.be/PDhMdAVUq7c And video 2: https://youtu.be/Lk1Kh9q51GA

Normal frame: Capture d’écran 2024-01-31 à 13 59 48

And now frame where I edit the details layer and the natureRenderer.Refresh(TerrainChangedFlags.RemoveDirtyDetailsImmediately) is running: Capture d’écran 2024-01-31 à 13 59 02

I have shared more videos and screenshots using your support site through the form, at least 2 videos were shared using your support site, as well as all the code I'm using

Also, I made sure to turn OFF the 'AutoRefreshTerrainAtRuntime' property on the NatureRenderer component on all my terrains (done during 'Awake')

Here is what the console is giving me whenever I make a crater in my terrain Capture d’écran 2024-01-31 à 13 41 55

As for the code I am using, here it is: https://pastes.io/hfxz4vzxxf

maxplooi commented 7 months ago

Thank you for sharing the video. Based on the video, it seems to be caused by Nature Renderer reloading due to a change in the terrain settings. I have included additional informative warning messages in the latest version when Nature Renderer is forced to reload at runtime due to a change in settings or a forced refresh. Could you download the latest version (2022.0.3) and check if you see any warning messages in the console when editing the terrain at runtime? You can update by going to Help > Nature Renderer > Check for Updates in the Unity editor.

If Nature Renderer is indeed restarting then you will see some variation of this message: Restarting Nature Renderer because the terrain settings changed. This causes flickering and may not be intentional.

The message will include a more specific reason why Nature Renderer is restarting. Please let me know the exact message and I'll be able to guide you to a solution.

If there is no message then let me know and I'll to look into this further and may require a small test project from you to reproduce this issue as I can't reproduce it in any of my projects.

valentin56610 commented 7 months ago

Hello Max,

Just performed the update (2022.0.3)

I am still experiencing the flicker, but I have nothing debugged in my console (No warning or anything)

Video from today after the update: https://youtu.be/xyBGKB5_zF4

One thing to note: I am using TVE (The Vegetation Engine) for all my vegetation

maxplooi commented 7 months ago

Thank you, I am still looking into this but so far no luck in reproducing anything that causes flickering. Is there any chance you could send a small test project to reproduce this issue?

On a side note, the next update contains large changes to the spawning algorithm to add support for spawn rules. This may also solve the issue you are having. If you can contact me via the Business Inquiry form then I can send you a preview release to try out.