Search Unity

Nature Renderer: Better terrain detail rendering ✅ PBR ✅ Custom Shaders ✅ Shadows ✅ Wind ✅ SRP

Discussion in 'Assets and Asset Store' started by Visual-Design-Cafe, Oct 3, 2019.

  1. jjejj87

    jjejj87

    Joined:
    Feb 2, 2013
    Posts:
    351
    I just tried to add grass in HDRP, but it doesn't look like its working. I've updated to the latest via the Asset store (HDRP 7.1.2, 19b8), am I doing something wrong?
     
  2. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    2,426
    I just tried your suggestion for map magic with terrain component disabled.
    But I got an error

    NullReferenceException: Object reference not set to an instance of an object
    VisualDesignCafe.Rendering.Nature.TerrainDataCache.CopyFrom (UnityEngine.Terrain terrain, System.Boolean& flushEverything) (at C:/Compiler/TerrainDataCache.cs:154)
    VisualDesignCafe.Rendering.Nature.TerrainDataCache..ctor (UnityEngine.Terrain terrain) (at C:/Compiler/TerrainDataCache.cs:114)
    VisualDesignCafe.Rendering.Nature.TerrainCells.RebuildTerrainData (System.Boolean& flushEverything) (at C:/Compiler/TerrainCells.cs:215)
    VisualDesignCafe.Rendering.Nature.TerrainCells.Start () (at C:/Compiler/TerrainCells.cs:154)
    VisualDesignCafe.Rendering.Nature.NatureRenderer.Initialize () (at C:/Compiler/NatureRenderer.cs:212)
    VisualDesignCafe.Rendering.Nature.NatureRenderer.Awake () (at C:/Compiler/NatureRenderer.cs:159)
     
  3. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    381
    I just gave it a try in a new project with HDRP 7.1.2 and everything works fine here.
    What exactly is not working for you? Are there any errors? Or are the terrain details not showing? And does the demo scene that comes with Nature Renderer work correctly?
     
  4. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    381
    I am working on an update that should fix compatibility with MapMagic, I'll send you a preview build soon so that you can give it a try.
     
    Lars-Steenhoff likes this.
  5. brainchild-pl

    brainchild-pl

    Joined:
    Jun 6, 2013
    Posts:
    109
    Does it work in Unity 2019.2?
     
  6. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    381
    Yes, Nature Renderer has been tested from Unity 2018.3 up to Unity 2020.1 Alpha and works fine in all versions.
     
    Lars-Steenhoff likes this.
  7. r3ndesigner

    r3ndesigner

    Joined:
    Mar 21, 2013
    Posts:
    108
    StevenPicard and Lars-Steenhoff like this.
  8. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    381
    Thanks! It is on the roadmap, but no specific timeline yet. I'll let you know when I have more specifics.
     
    dsilverthorn and Lars-Steenhoff like this.
  9. r3ndesigner

    r3ndesigner

    Joined:
    Mar 21, 2013
    Posts:
    108
    I ll buy it soon anyway, it just to know that in some point ll have it , thanks for your feedback ^^.
     
    Visual-Design-Cafe likes this.
  10. SeymourGutz

    SeymourGutz

    Joined:
    Aug 9, 2019
    Posts:
    7
    Is this compatible with Vegetation Studio Pro?
     
  11. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    381
    The shaders are compatible but the rendering system is not (Nature Renderer has its own rendering system). So you can use the shaders that come with Nature Renderer on your assets and then use them with Vegetation Studio. But if you want to render your terrain details with Nature Renderer then you won't be able to use Vegetation Studio.
     
    DrOcto likes this.
  12. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    381
    Version 1.1.4 is now available for download through the Package Manager and will be available on the Asset Store within the next few days. You can go to Help > Nature Renderer > Check for Updates to download the update.

    Changes:
    • Fixed: Occasional crash when entering playmode or in build.
    • Fixed: Issue where newly added terrain details would not render until the scene is reloaded.
    • Fixed: Terrain Details now render correctly on non-square terrains.
    • Fixed: Error causing terrain details to be invisible in Unity 2019.1
     
    jjejj87 likes this.
  13. Quique-Martinez

    Quique-Martinez

    Joined:
    Oct 1, 2013
    Posts:
    111
    Hi I just discovered this asset and definitely it is on my shopping list. Is there any video? Thanks!
     
  14. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    381
    Thanks!
    There is a very short video on this page: https://www.visualdesigncafe.com/nature-renderer/
    But since all you have to do is add a component we have mostly screenshots of the results.

    You can read through the documentation (https://support.visualdesigncafe.com/hc/en-us/categories/360000055921-Nature-Renderer) if you want to know how to work with Nature Renderer. Every step and feature is described one-by-one. We are still working on adding some more screenshots to the docs :)
     
    Quique-Martinez likes this.
  15. Quique-Martinez

    Quique-Martinez

    Joined:
    Oct 1, 2013
    Posts:
    111
    Hi, I'm using URP and getting a weird displacement. Any hint?
    upload_2019-12-20_16-14-36.png
     
  16. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    381
  17. Quique-Martinez

    Quique-Martinez

    Joined:
    Oct 1, 2013
    Posts:
    111
    It works in all modes if I move the RandomVariation slider to 1
    Thanks
     
  18. unity_dev3194

    unity_dev3194

    Joined:
    Apr 17, 2017
    Posts:
    58
  19. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    2,426
  20. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    381
    Version 1.1.5 is now available for download through the Package Manager and will be available on the Asset Store within the next few days. You can go to Help > Nature Renderer > Check for Updates to download the update.

    Changes:
    • New: Added smoothness and metallic support to shaders in Standard Render Pipeline.
    • New: Performance improvements.
    • Fixed: Issue where some strips of grass were not placed on large terrains.
    • Fixed: MissingMethodException when building for AOT platforms. Caused a black screen or grass not rendering in Scriptable Render Pipelines.
    • Fixed: MissingMethodException in Unity 2020 Alpha.
    Note: It is possible that you will have to tweak the Smoothness settings for your materials after downloading this update. Unity sets the smoothness value to 0.5 by default for new materials, which is usually not the value that you want to use for your vegetation.
     
    r3ndesigner, Mauri and Lars-Steenhoff like this.
  21. Acissathar

    Acissathar

    Joined:
    Jun 24, 2011
    Posts:
    503
    Would someone be able to detail how this compares to Vegetation Studio Pro? This seems much easier to work with, but I'm wondering what else there might be.

    Thanks!
     
  22. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    381
    In terms of rendering it is indeed similar but easier to work with :) But please note that Nature Renderer was build to render vegetation and does not place it. You can place vegetation using Unity's default tools.

    I have just uploaded a fully featured trial version. So if you are curious you can give it a try for free:
    https://www.visualdesigncafe.com/nature-renderer/#trial
     
    Acissathar likes this.
  23. Acissathar

    Acissathar

    Joined:
    Jun 24, 2011
    Posts:
    503
    Awesome, I do have VS Pro so I'd love to give it a go and compare the two. I'm mainly interested in performance aspect, so having an easier workflow in exchange for placement is okay by me :)
     
    Visual-Design-Cafe likes this.
  24. Fobri

    Fobri

    Joined:
    Jan 28, 2014
    Posts:
    17
    Hey
    We are having a problem with Nature Renderer. Whenever we add it to terrain Unity memory usage jumps up to 10 gigs from 4 gigs. Then it slows down but is still gradually rising until the system runs out of memory, causing the PC to freeze for a while and crash multiple programs alongside with Unity. Removing Nature Renderer from the terrain does not fix it, Unity needs to be restarted.

    Using HDRP version 7.1.7 with Unity 2019.3.0f3. Looking forward to a fix for this. Already bought two seats for the plugin.

    - Fobri
     
  25. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    381
    Thanks for reporting this issue. Just saw this post after replying to your email and I have a few more questions. Can you let me know if you did any specific actions after adding Nature Renderer to the terrain and/or if you have any other scripts that edit the terrain? It looks like the terrain is marked as dirty and a rebuild is requested every frame (or at least many times), causing Nature Renderer to hog up all memory and CPU to rebuild the terrain data.
     
  26. Fobri

    Fobri

    Joined:
    Jan 28, 2014
    Posts:
    17
    Hey
    Thank you for the fast reply

    The issues appear right after adding Nature Renderer to the terrain. The terrain is fully procedurally generated, but not in realtime. There is nothing actively modifying the terrain. We have added bushes and other terrain decals to the "Trees" section for now as well if that matters at all. Trees section has 23 variants of bushes. As for terrain details, we have 10 variants of grass, all procedurally placed along the terrain.The terrain is almost fully covered with grass.

    We also have 4 terrains next to each other. On Terrain neighboring settings we have enabled "Fill heightmap using neighbors" and "Fill heightmap address mode" is set to "Mirror".

    Terrain width and length are both 2048
    Detail resolution per patch is 8
    Detail resolution is 2048

    Detail patches currently allocated: 65536
    Detail instance density: 67108864

    - Fobri
     
    Visual-Design-Cafe likes this.
  27. Fobri

    Fobri

    Joined:
    Jan 28, 2014
    Posts:
    17
    Update:

    The problem persists even when there is no grass. However memory usage jumps from 3.5Gb to 9Gb and it keeps rising slowly. Even after removing Nature Renderer.

    Update 2:
    Made a new project with the same settings and it works perfectly. So it has something to do with our assets intervening with the plugin I'm guessing? Trying to figure out which assets they are.
     
    Last edited: Jan 1, 2020
  28. Wolfos

    Wolfos

    Joined:
    Mar 17, 2011
    Posts:
    744
    This asset doesn't work for top-down games. It culls grass patches that are completely visible in the viewport, as it only renders cells that are in front of the camera.
    Had the asset been open source (like every other asset), I would have simply disabled the culling. Now the whole asset is useless because you didn't provide the source code.

    I hope Unity will start to do something about closed source assets like this. Like a big fat warning on the store page. I see it more and more often and you always run into one problem or another.
     
    Last edited: Jan 1, 2020
  29. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    1,688
    "Nature Renderer" is under active development. You could've messaged the devs, asking them to fix this. It's called 'bug reporting'.
     
    Visual-Design-Cafe likes this.
  30. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    381
    Can you try attaching the following script to your terrain? It will print a message to the console when the terrain changed. It should help you determine if any of your scripts are modifying the terrain.
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. [ExecuteInEditMode]
    4. public class TerrainChangedDebugger : MonoBehaviour
    5. {
    6.     public void OnTerrainChanged( TerrainChangedFlags flags )
    7.     {
    8.         Debug.Log( "Terrain Changed: " + flags );
    9.     }
    10. }
    11.  
     
  31. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    381
    Thanks for the feedback. I just replied to your review and then saw your message here.
    I have replaced the culling algorithm and created a preview build with the changes for you. I am running a few more tests to make sure that everything is working correctly and then I'll send you the build later today.

    As for the source code: Keeping the code in plugins helps us maintain a consistent code-base for all users and helps us update the asset frequently. Feel free to contact me if you have any requests or feedback regarding any features.

    Edit: I just sent you the latest build with a fix by PM. Please give it a try.
     
    Last edited: Jan 2, 2020
    Wolfos likes this.
  32. Fobri

    Fobri

    Joined:
    Jan 28, 2014
    Posts:
    17
    Hey
    Terrain doesn't get updated excessively. However I noticed that whenever I try to add a terrain detail to the terrain I get a a warning saying "Detail rendering shaders not found for the active render pipeline, falling back to default shader".

    Edit:
    I used the memory profiler to see what is going on. When I add Nature Renderer to the terrain the following happens:
    GC allocated spikes up to 3Gb and goes back down.
    Unity itself doesn't allocate more memory, but Mono does.

    Edit 2:
    I managed to get the grass working in edit mode after I removed all other grass variants. However it still doesn't work in play mode. The grass gets procedurally placed. Do I need to add the nature renderer component after the script has added the grasses?
     
    Last edited: Jan 2, 2020
  33. Wolfos

    Wolfos

    Joined:
    Mar 17, 2011
    Posts:
    744
    Thanks for the quick fix. I still disagree with the lack of source access and believe it should be mentioned on the store page. I tend to heavily customize any asset I download and obviously don't expect any support for that.

    Anyway, I'm having another issue. I'm using it on a fairly big terrain (1x1km) with a 2048px detail map texture and it will lag heavily for about 20 seconds every time the game starts. The profiler says Camera.Render() is taking about 80ms per frame to execute.
     
  34. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    2,426
    +1 on source acces
    I have many assets that are still working fine even when depricated because they have source acces.
     
  35. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    381
    The warning is from Unity's default detail shader, you can ignore that one.

    The memory usage sounds correct, although 3GB is definitely very high. I'll move detail streaming to the top of the priority list for now so that you don't have to load the entire terrain at once. That should fix this issue. Right now, all details for the entire terrain are loaded and cached at once, so for large terrains with a lot of details the memory usage can go up quite a lot. I'll keep you updated on the progress for streaming. It shouldn't take too long to add since it is already mostly working in edit mode.

    Yes, you have to add Nature Renderer after generating the grass (if it is at runtime). Nature Renderer does not check for changes at runtime and only builds the terrain once on start.
     
    Lars-Steenhoff likes this.
  36. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    381
    Could you share a screenshot of the terrain so that I can get an estimate of the detail density? Also, if you open the 'debug' section in the Nature Renderer component then it should print some debug statistics for the Main Camera in your game. Could you include those as well?

    I am getting similar results when rendering around 500K instances in view in a single frame, but generally the number of details shouldn't be that high. These are the numbers of details I get with a 1x1km terrain with 2048px detail map at 100% density.
     
  37. Fobri

    Fobri

    Joined:
    Jan 28, 2014
    Posts:
    17
    Hey
    I thought that one of the reasons to use GPU instancing is that the instances don't take up memory, but rather live on the GPU? Also do you have any eta for when this update will be live?
     
  38. Wolfos

    Wolfos

    Joined:
    Mar 17, 2011
    Posts:
    744
    My instance count isn't nearly that high.
     
  39. Fobri

    Fobri

    Joined:
    Jan 28, 2014
    Posts:
    17
    Hey
    How do I change the detail distance from a script?
     
  40. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    381
    We still have a render buffer on the CPU that gets send to the GPU. It is not much (just a position and rotation), but with a lot of instances it can take up quite a lot of memory. I have a working preview version at the moment. It needs some more testing but I am sure that I can send you a custom build sometime this week.

    Just noticed that the rendering distance is a private field. I'll make it public so that it can be changed. As a temporary fix you can set the value of the private '_detailDistance' field in the VisualDesignCafe.Rendering.Nature.NatureRenderer component with reflection. I'll change the read-only 'DetailDistance' so that you can set the value there in the next update.
     
    Last edited: Jan 5, 2020
  41. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    381
    The instance count is indeed not that high. And the stats in the screenshot show that Nature Renderer only takes 0.3 ms. So I am not sure where the rest of that 80 ms is coming from. Could you check the profiler which part of the Camera.Render() takes up that much time? The streaming update for Fobri should also fix that loading time for you. I'll send you a custom build this week as well.
     
  42. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    381
    @Fobri I have sent you a preview build by email with the streaming feature enabled. Please give it a try :)
     
  43. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    381
    @Wolfos I have also sent you a preview build by PM.
     
  44. Wolfos

    Wolfos

    Joined:
    Mar 17, 2011
    Posts:
    744
    It depends on the spike what takes up the most time. Sometimes it's Culling.WaitForJobGroupID, sometimes it's shadow maps. Sometimes it spends 50ms waiting for the GPU.

    The issue is entirely gone with the new preview build. I'm not seeing any of the pop-in you mentioned, possibly because my game is top-down and I'm only rendering a very small patch of grass.
     
  45. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    381
    It might have been running into a limit somewhere because there were too many instances loaded, resulting in random spikes. Good to hear that everything is running smoothly now!
    And it is indeed very likely that you won't notice much loading for a top down game. It should only take about 20 ms at startup to stream all the details on the screen with such a small patch of grass in view.
     
  46. Fobri

    Fobri

    Joined:
    Jan 28, 2014
    Posts:
    17
    Thank you, I'll give it a try now.
     
  47. Fobri

    Fobri

    Joined:
    Jan 28, 2014
    Posts:
    17
    Hey
    It seems to be working in editor. However when I build the project the grass simply doesn't appear.

    This error also appears, I don't know if it's connected:
    NullReferenceException: Object reference not set to an instance of an object
    VisualDesignCafe.Rendering.Nature.NatureRenderer.RebuildBuffers (UnityEngine.TerrainChangedFlags flags) (at C:/Compiler/NatureRenderer.cs:176)
    VisualDesignCafe.Rendering.Nature.NatureRenderer.OnEnable () (at C:/Compiler/NatureRenderer.cs:229)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
     
    Last edited: Jan 6, 2020
  48. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    381
    Can you check if you have a camera in the scene with tag MainCamera? At the moment the streaming requires a Main Camera to be set before loading because the camera's position is used as a reference point to check which details are in range. If you are spawning the camera after loading then please let me know and I'll see if I can change the loading behavior for you.
     
  49. Fobri

    Fobri

    Joined:
    Jan 28, 2014
    Posts:
    17
    Hey

    We do have a main camera in the scene during loading, however it's only used to render a canvas to display world generation progress.

    I used this code:
    Code (CSharp):
    1. if (useNatureRenderer)
    2.                 {
    3.                     var nr = terrains[j].gameObject.AddComponent<NatureRenderer>();
    4.                     nr.DetailDistance = grassRenderDistance;
    5.                     //nr.RebuildBuffers(TerrainChangedFlags.FlushEverythingImmediately);
    6.                 }
    I tried without rebuildbuffers and with. If I tried to add the component to the terrain beforehand, it would not even compile, because of the error I mentioned.

    I also tried this same code with a hotkey, so I would load the world with Unity's default grass, go look at the grass, or more like white squares, and press the button to run the code. The application would hang a bit and then the grass would just disappear.
     
    Last edited: Jan 8, 2020
  50. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    381
    I just sent you a new build by email that should fix this issue. Please give it a try.
     
unityunity