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. PROTOFACTOR_Inc

    PROTOFACTOR_Inc

    Joined:
    Nov 15, 2009
    Posts:
    4,054
    Tried in a totally new scene with your own grass and it worked. However not totally in real time in the editor. Meaning when tweaking the prefab I could see that the mesh was deformed but not playing the wind. in play mode in as working normally.
     
  2. PROTOFACTOR_Inc

    PROTOFACTOR_Inc

    Joined:
    Nov 15, 2009
    Posts:
    4,054
    Oh my god, sorry for the spamming... finally got it to work.. nothing wrong with your stuff (obviously). I forgot to add the global wind component to the terrain thinking that there was already some wind settings on it... Again, Big thanks for trying to help and apologies for troubling you for some dumb reason... :O
     
    Visual-Design-Cafe likes this.
  3. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Glad to hear that everything is working now :)

    Make sure that animated materials is enabled in your scene view, otherwise the scene view is not refreshed every frame:
    SceneViewAnimatedMaterials.jpg
     
    PROTOFACTOR_Inc likes this.
  4. PROTOFACTOR_Inc

    PROTOFACTOR_Inc

    Joined:
    Nov 15, 2009
    Posts:
    4,054
    hi again!

    Hope you were not reading that message that I edited a few times... I gotta be tired... Your system is absolutely amazing! Creating atlases of vegetation with it is simply a performance saver!

    Being able to create a cross grass with 2 triangles is a great gain in performance as well as allowing us to have a denser vegetation. considering unity is using on plane (2 tris). I got your plugin very early on and never got a chance to giving it an actual try and now that I'm in the middle of a project that requires optimization and visual enhancement, I have to say that your tool rocks! :)

    I'm really pleased with the way the terrain details look now.

    One last thing which would be a request: any way you'd be willing to add an emissive texture variable to the shaders? not everyone is using standard looking grass in their project, there are alien planets out there! :)
     
    Last edited: Aug 23, 2020
  5. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    649
    Hello,

    Any chance you can supply a demo for realistic grass? That would be _really_ helpful. I wanted to replace your grass with my own texture from megascans, but it doesnt fit your clipped mesh (which I get is to prevent overdraw) and I just dont have the time right now to figure out what you did with the baked in bending stuff.

    I would _really_ appreciate a ready-to-go realistic grass example I could just drop in to use. I know its simple, but I'm one person trying to cobble together a bunch of different systems to prototype the actual gameplay into something that can show the proper feel, and that would go a long way!

    PS: It would be great if you could find some way to integrate nicely with the Gaia Pro stuff ... right now Im nuking all the pre-generated terrain details and replacing with this. However, would be nice to be able to just use their biomes and have that work with all the different flowers, etc.

    Finally ... thank you so much for your work on this. Its the _only_ solution I found that gave both the visual quality AND the performance I needed. You guys are awesome.

    [Edit -- If you can't tell, I am _not_ an artist (I'm a programmer). So I dont actually know a lot of the basic stuff that most people using this can probably do easily and quickly. A tutorial / demo of how to get megascans stuff looking good using this would be _AMAZING_, since right now its beyond my reach priority wise.]

    [Edit 2 -- Oh, while I'm here. I'm using CTAA in built in, and any substantial sway from wind on the grass gives lots of nasty TAA artifacts. So I'm basically stuck with low-wind grass. Is there anything specific you recommend to make moving grass look better using deferred? If not, no worries, still thrilled with this, and accepting my limitations of what I can figure out :)]
     
  6. PROTOFACTOR_Inc

    PROTOFACTOR_Inc

    Joined:
    Nov 15, 2009
    Posts:
    4,054
    I have to replace and update every single assets of vegetation on my end. for the grass it isn't that hard you just need to get the UV layout of the example grass and set your textures to fit in there (10 mn of work max). For sopme other vegetation it might be trickier since you would have to set up at leas the vertices alpha for the foliage of each models and make sure to do that for their LODs as well. You'll notice that he also sell his own vegetation online, so maybe that's something to think about. But then you'd have to replace the Gaia biomes by your own...
     
    DGordon likes this.
  7. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    649
    Yeah makes sense. I was figuring Id take his grass texture, and just make my own grass fitting his UVs. Just saw his book of the dead example on the first page and was hoping something like that could make its way in for real, since it was mentioned back there he was thinking about a realistic grass demo :).

    Will check out his grass, I didnt realize that. Thanks.

    I'm not at the "final products" stage. Im in early prototyping and just want to get an idea of whats possible, quickly. Thanks!
     
  8. PROTOFACTOR_Inc

    PROTOFACTOR_Inc

    Joined:
    Nov 15, 2009
    Posts:
    4,054
    His tool is really great! it's a performance enhancer for , in some areas I was getting some slower fps like 60 barely and now it's back to 115 / 120 fps steady. I still need to update a couple trees to get some more performance gain. It's a little bit of work for sure, if you have to update some assets that were not initially designed for it but it's worth it at the end. once you know your biome you can create your own atlas of grass and just have that one draw call for a ton of vegetation. really powerful.
     
  9. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    649
    Hah, just realized who I'm talking to. Recognize this model I'm using right now to get combat up and running? :p It was also my first substance painter learning model, hence the repaint.

    [Edit -- thats the grass in the background. Even sharp, pointy, and stylized, it looks nice when running the game!]
     

    Attached Files:

    PROTOFACTOR_Inc likes this.
  10. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Sure, no problem. I'll add it to the list for the next shader update.
     
    PROTOFACTOR_Inc likes this.
  11. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    @DGordon @rosor
    You can usually use your own vegetation without having to set up anything, using the following method:
    1. If you only have textures then you can add them as 2D grass to the terrain. Nature Renderer will automatically generate quad meshes for them. (The downside is that you can't use normal maps, occlusion maps, etc. for these)
    2. If you already have meshes then you can assign a material that uses one of our Nature Shaders in the model's import settings and reimport the model. Any models that use Nature Shaders will be processed on import and the correct vertex colors will be calculated (alpha-channel only). All the other vertex channels are optional. This should work with any third-party models as well.
    3. The above only works for simple shapes. If you have complex shapes such as trees, or strangely-shaped vegetation then you'll need to manually add the vertex colors.
    Megascans should work as well with step 2 above (it is how I set them up myself).

    I am still looking into providing a demo with realistic assets. It is quite a busy period right now, so I haven't had time yet to create these assets.
     
    DGordon likes this.
  12. PROTOFACTOR_Inc

    PROTOFACTOR_Inc

    Joined:
    Nov 15, 2009
    Posts:
    4,054
    That'd be amazing! And a real visual enhancement in my project. if this can be added to all SRPs it'd be even better! :) I'm still on built-in but I4m sure a lot could benefit from this update on all SRPs
     
  13. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    649
    Okay, well I managed to get something looking better by basically copying the shape of how you laid out your grass texture, and putting my blades of grass like that. Still no idea how Im supposed to use photoshop to lay out normals / mask textures properly when doing that, but thats my own issue.

    Once I played with the textures, dropping stuff in and getting it to look right is easy. I just tried some default grass and it looked horrible, thought there was something special I needed to do.

    Thanks so much!
     
  14. PROTOFACTOR_Inc

    PROTOFACTOR_Inc

    Joined:
    Nov 15, 2009
    Posts:
    4,054
    Hey there! i think I need some technical explanations about the tree leaves material / shader... I set up my tree pretty much like I would do the grass with vertex alpha and for some reason the entire part of the mesh that is using the material is reacting not just the part that aren't black...
    Is there anything I'm missing? here is a picture of the tree set up :
    upload_2020-8-26_8-2-25.png Thanks in advance for any help you can provide
     
  15. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Trees use a different format for the data because they require a lot more information. They use the same data as Unity's tree creator and require a combination of vertex colors and texture coordinates. If the results are decent, then I recommend to just use the "Vertex" wind method for these, as hand-painting the correct data can be very difficult. Here are the values that our shaders use from Unity's tree creator data:
    Second UV Channel
    • X: not used. Normally stores the distance from the branch to the trunk.
    • Y: height of the tree. 0 at the bottom of the trunk, 1 at the end of the branches.
    Vertex Color
    • Red: phase offset for each branch group. A random value that is consistent for a branch and all the leaves connected to that branch. Is used to randomize the wind.
    • Green: distance from the branch to the end of the leaves. 0 at the branch, 1 at the end of the leave(s). This makes sure that leaves receive correct wind turbulence and that they do not float from the branches.
    • Blue: not used.
    • Alpha: baked ambient occlusion. (I believe this is ignored at the moment, because Unity's baking results were not that great)
     
    PROTOFACTOR_Inc likes this.
  16. PROTOFACTOR_Inc

    PROTOFACTOR_Inc

    Joined:
    Nov 15, 2009
    Posts:
    4,054
    ok but here I'm asking specifically about the "tree leaves" shader not the trunk or branches. I used that shader on another model which I set up the exact same and it's working as expected (meaning black vertices on alpha are not affected). For some reason the entire geometry is waving on the tree posted above (please note that it's has 2 materials on for the tree trunk and one for the leaves. Leaves are using your 3tree Leaves" shader

    Thanks
     
  17. Dark-1-Games

    Dark-1-Games

    Joined:
    Mar 26, 2014
    Posts:
    101
    Hi! Thanks for making this great plugin. We're having some trouble with building on OpenGL for windows though, with the following warnings + error:

    Any ideas on how to make this at least not crash our build?
    Thanks!
     
  18. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    The Tree Leaves shader and Tree Bark shader use the same data. This is because the leaves need to move along with the branches and the trunk. It may have been a lucky coincidence that the other tree worked. Can you double check that the Wind Control in the material is set to Baked?
     
    PROTOFACTOR_Inc likes this.
  19. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Thank you for reporting this. The error happens because our compute shaders use multiple threads to copy over data and it looks like the maximum number of threads is reached on that platform. Nature Renderer automatically reduces the number of threads based on the hardware specifications, but it seems that Unity just refuses the compile the shader at all.

    Can you open the following file:
    Assets/Visual Design Cafe/Plugins/com.VisualDesignCafe.NatureRenderer/Resources/Nature Renderer.compute

    And change line 6 from
    Code (CSharp):
    1. #pragma kernel AddInstances32 THREADS=128
    to
    Code (CSharp):
    1. #pragma kernel AddInstances32 THREADS=64
    That should force the number of threads to be limited to 64, which should be supported.
     
  20. Dark-1-Games

    Dark-1-Games

    Joined:
    Mar 26, 2014
    Posts:
    101
    Thanks for the suggestion. I gave it a try, but it still fails with the same error:

    Seems like it's having some issues linking AddInstances16 as well.
     
    Last edited: Aug 28, 2020
  21. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Can you try changing all lines from line 1 to 6 to THREADS=1 instead of THREADS=64? Setting the value to 1 should definitely work. Performance will be a bit worse, but it should rule out any other possible causes. If that works, then you can try increasing the value to THREADS=16 or THREADS=32.
     
  22. Dark-1-Games

    Dark-1-Games

    Joined:
    Mar 26, 2014
    Posts:
    101
    Still getting the exact same error with THREADS=1 on all of them. Perhaps the usage of the Instances0, Instances1... is just too many buffers used in AddInstances16 and just breaks AddInstances32?
     
    Last edited: Aug 28, 2020
  23. PROTOFACTOR_Inc

    PROTOFACTOR_Inc

    Joined:
    Nov 15, 2009
    Posts:
    4,054
    A you said, it looks like it was a very lucky coincidence. I double checked the wind on the other tree. Tried all 3 options with no changes at all. Tried to add the tree trunk material to the trunk to have the exact same set up as for the other tree (with all trunk options set to zero) and same here... no lucky coincidence....
    Do you have a workaround / trick to handle custom trees like these? right now I'm using either grass or vegetation shader for their foliage and don't use the option for fading distance. (it's not that great but still better than nothing moving at all)

    If I were to create my on trees, do you think the old Tree Creator would work nicely with all your shaders? What about the "Mr Tree" plugin?

    Thanks
     
    Last edited: Aug 28, 2020
  24. Wolfos

    Wolfos

    Joined:
    Mar 17, 2011
    Posts:
    951
    I'm getting "Material doesn't have a texture property '_MainTex'" errors on the grass shader. I mean, it doesn't have a property called _MainTex so I suppose that's correct, but it's failing the build because of this.
     
  25. amynox

    amynox

    Joined:
    Oct 23, 2016
    Posts:
    178
    Hi,
    Nature renderer is generating a lot of GC/every frame for no apparente reason:



    Any idea of what can cause this ?

    I'm on Unity 2020.1.3f1, using 4 terrain chunks (50x50), and here is my nature renderer config :



    Thanks for your help
     
  26. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    I'll take a look at it for you and get back to you. It is not an error that I have seen before, so I don't have an immediate answer for you. I thought that it was just the number of threads, but it must be something else.
     
    Dark-1-Games likes this.
  27. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Unity's tree creator should work fine, I use it as well to create my trees. All the shaders should work with them immediately without any additional setup.

    For other custom trees I recommend to first try the Vertex wind method, and set the tree height and radius. It should provide a good enough result for most trees.

    If that is not enough then the best option is to manually paint the vertex colors and second UV channel according to the data I described in the previous post. You can also look at the vertex data of the sample tree for an example.
     
    PROTOFACTOR_Inc likes this.
  28. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Nature Renderer occasionally allocates new memory while moving around the terrain. This memory is stored in an internal memory pool and is reused while Nature Renderer is enabled. It shows up in the profiler as allocated memory, but it should not affect your garbage collection or performance. It should be safe to ignore unless this happens every single frame, in that case there might be a bug in the memory management.
     
  29. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    I can confirm that this error occasionally pops up. It is not caused by any of our code though. It seems to be an internal error in Unity and, in our experience, has been completely harmless. However, if this error is failing your builds then you could try to add a dummy _MainTex property to the shader to work around this.

    Just add the following line anywhere in the Properties block at the top of the shader:
    Code (CSharp):
    1. _MainTex("Dummy Main Texture", 2D) = "white" {}
    Our material editor should be able to work correctly with this additional _MainTex property.
     
  30. Wolfos

    Wolfos

    Joined:
    Mar 17, 2011
    Posts:
    951
    If you build for UWP you can't have any errors in the log, so it fails on the material. I'll try the workaround.
     
  31. amynox

    amynox

    Joined:
    Oct 23, 2016
    Posts:
    178
    This is happen even 25 frame and even when i'm NOT moving arround the terrain !
    Is this is the excpected behaviour ?
    Thanks a lot
     
  32. Wolfos

    Wolfos

    Joined:
    Mar 17, 2011
    Posts:
    951
    It builds now but it the grass isn't visible. Either with or without that shader. This is on the Universal Windows Platform with Il2CPP. The issue occurs both on a PC and an Xbox One X.
     
  33. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Sounds like expected behavior. Details are being streamed-in in the background over the course of multiple frames. so you'll have a few memory allocations in multiple frames.
     
    amynox likes this.
  34. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    I'll look into it and get back to you.
     
    Wolfos likes this.
  35. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Can you share your Unity version, Render Pipeline, and exact build settings and project settings? I am trying to reproduce the issue, but all UWP builds seem to work fine here.
     
  36. Wolfos

    Wolfos

    Joined:
    Mar 17, 2011
    Posts:
    951
    Unity 2019.3.7f1. Standard render pipeline, deferred rendering with HDR and DirectX12 (issue also occurs with DX11). Build configuration is release, development build is checked.
    I'm also using the assets World Streamer and Microsplat.

    I can't reproduce it in a new project with the sample assets.
     
  37. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    It is most likely an issue when combining with World Streamer. Can you try to add the Nature Shaders to the list of "Always Included Shaders" in the project's graphics settings, and set Shader Stripping for Instancing Variants to Keep All. It is possible that the shaders are not included, or some variants are stripped from the project because the terrains are loaded dynamically by World Streamer.

    Also, can you check the logs of the standalone player to see if there are any errors in there?

    Graphics Settings.jpg
     
  38. Wolfos

    Wolfos

    Joined:
    Mar 17, 2011
    Posts:
    951
    I've tried that, and tried running without World Streamer but the issue persists.

    I get some errors in the log the first time I load the scene, but not if I go back to the main menu and reload:
    Long running job detected: Thread "Job.Worker 5" in frame 106 must have been in sync with the Main Thread, but it did not flush data for 50 frames and might be frozen.
     
  39. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Thank you for the additional details. The error is most likely from one of Unity's internal systems, as we don't use the job system.
    Is it possible for you to share the project, or a subset of the project? Because the issue can't be reproduced in a new project it is most likely a compatibility issue with the loading code in your project or one of the other plugins. It will be very difficult to find the exact cause without access to the project to debug it.
     
  40. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    I have just sent you a PM with a patch :)
     
    Dark-1-Games likes this.
  41. Wolfos

    Wolfos

    Joined:
    Mar 17, 2011
    Posts:
    951
    Sent you a DM.
     
  42. amynox

    amynox

    Joined:
    Oct 23, 2016
    Posts:
    178
    I'm experiencing the same issue here ... Using World Streamer + Microsplat + Jobs too on Unity 2020.1.3f1.
     
  43. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    I have sent you the patch as well.
     
  44. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    Nature Renderer version 1.3.7 is now available through the built-in updater and will be available on the Asset Store within the next few days. Go to Help > Nature Renderer > Check for Updates to download it.

    Fixed:
    • Fixed build/compile error in compute shader when targeting OpenGL.
    • Fixed culling issue where groups of details would pop-in when using a short culling distance.
    • Fixed disconnected normal node in HDRP Grass shader graph.
    Changed:
    • Improved placement algorithm to prevent noticeable lines and patterns from forming.
     
    Dark-1-Games and Lars-Steenhoff like this.
  45. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    721
    A notice for everyone:

    I will be out of the office on vacation from September 7 until September 14. If you have any questions then I'll get to them again starting from the 14th. There are no major known issues at the moment, so you should all be able to continue working on your projects without any problem :)

    If you do run into something, then make sure to check the knowledge base. Most common problems and solutions are described there.

    After I am back I'll have a major announcement as well!
     
    Dark-1-Games likes this.
  46. hepphep

    hepphep

    Joined:
    Feb 1, 2013
    Posts:
    24
    Hi!

    Is there currently any way to exclude the HDRP decals (Decal Projector) from rendering to foliage? At least I could not find such option, but it would be really useful to be able to do it for selected foliage (especially the trees). Default HDRP materials have Receive Decals checkbox, so something like that would be very useful addition.
     
  47. Jairusx

    Jairusx

    Joined:
    Jun 25, 2020
    Posts:
    62
    Hi.I need more than 250 detail distance, because i have big open world map and i need to see the grass meshes further away.Is there any option the increase that detail distance? Thanks!
     
  48. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    If you set the inspector to debug mode you can put any value you want, not sure if this is saved in the build.
     
  49. Jairusx

    Jairusx

    Joined:
    Jun 25, 2020
    Posts:
    62
    Hello and thanks for the advice! :) Unfortunately everything about 250 in debug mode too doesn't impact on the scene and play mode :(
     
  50. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,561
    I figured out how to get Nature Renderer working with MapMagic. I put a Nature Renderer component on the MapMagic object itself, and made sure the Copy Components to Terrain box is checked. This places a copy of the Nature Renderer component on each newly generated terrain.

    1. How can I change the detail distance and other settings on all my terrains at the same time? Normally I get an array of all existing terrains, then I change the values on all of them in one step. Im guessing I need a way to get every instance of the nature renderer component that is active in my scene and change the detail distance that way?

    2. How can we change the grass density?

    3. Is there a performance penalty having multiple nature renderer components in the scene? For example there are about 9 in the scene at any time because I have 9 terrains active at a time.

    EDIT: I built the terrain to IOS and the terrain grass doesn't show up on my iPad (it shows up in the editor fine). Could this be because I'm using the trial version of NR? EDIT2: for anyone with the same issue with missing grass its because I didn't include the grass shader in my build. I solved this by adding an empty game object with the shader attached, you could probably do this by manually including the shader in the project settings for the build too.

    IMG_2759.jpg
     
    Last edited: Sep 10, 2020
    boysenberry likes this.