Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Terrain Grass Detail hack for HDRP (Shader inside)

Discussion in 'World Building' started by Flamacore, Mar 5, 2019.

  1. Flamacore

    Flamacore

    Joined:
    Dec 17, 2013
    Posts:
    81
    Hey there all. Since I've seen a few different posts and threads on this, thought I'd share what I have in my hand. Many people (like me) have a need for detail textures on the newest terrain engine for hdrp. The original one drew all the details in pink as they had no shader support.

    So I've come up with a rather hack than a great shader. Using the ShaderGraph, one can actually make a supporting lit shader for painting detail on terrain. Just use a main texture with reference name _MainText and put your shader under path Hidden/TerrainEngine/Details and name it WavingDoublePass.

    Please bear in mind that this is a very basic shader hack. No idea on performance. Please try/use with caution and definitely back your scene/project up before using this.

    Here's the link:
    https://github.com/flamacore/UnityHDRPTerrainDetailGrass
     
  2. Flamacore

    Flamacore

    Joined:
    Dec 17, 2013
    Posts:
    81
    Updated with experimental wind :)
     
  3. GameDevCouple

    GameDevCouple

    Joined:
    Oct 5, 2013
    Posts:
    2,518
    If anyone knows how to get billboarding working on this that would be great. Its the only feature thats missing to make it a drop in replacement for the current broken in built
     
  4. Flamacore

    Flamacore

    Joined:
    Dec 17, 2013
    Posts:
    81
    Well I've tried my best to replace BillboardWavingDoublePass with a billboard I designed in shadergraph as well but somehow it simply refuses to render anything when set to billboard. Not sure why at this point... The shader works fine when I try it on a simple mesh and really makes it a perfect billboard but when I rename it to BillboardWavingDoublePass in the same folder as the normal one, it simply just does not want to draw...
     
  5. GameDevCouple

    GameDevCouple

    Joined:
    Oct 5, 2013
    Posts:
    2,518
    @wyatttt would you be able to advise how to hook this up? The shader is working so thats the harder bit done I feel :)
     
  6. Flamacore

    Flamacore

    Joined:
    Dec 17, 2013
    Posts:
    81
    This is the bit that generates billboard view but as I said, somehow the billboard renderer on terrain does not render this. Simply shows blank :)
     

    Attached Files:

  7. Flamacore

    Flamacore

    Joined:
    Dec 17, 2013
    Posts:
    81
    Also I've updated github once more to provide better alpha shading.
     
    GameDevCouple likes this.
  8. GameDevCouple

    GameDevCouple

    Joined:
    Oct 5, 2013
    Posts:
    2,518
    Im going to look into this over weekend as Ill be back to doing dev on my personal project which I needed the grass for, if I make a breakthrough I will submit a pull request to the repo :)
     
  9. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    314
    @Flamacore if you go to one of the wireframe debug views for the scene view, does it show the geometry for the grass?
     
    GameDevCouple likes this.
  10. Flamacore

    Flamacore

    Joined:
    Dec 17, 2013
    Posts:
    81
    @wyatttt Interesting question and the answer is no. The wireframe disappears. Any leads I can follow from here?
     
  11. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    314
    What about modifying the Shader Category for the graph? Did you do that for both?
     
    GameDevCouple likes this.
  12. Flamacore

    Flamacore

    Joined:
    Dec 17, 2013
    Posts:
    81
    Umm okay not exactly sure what you mean by that. I gotta say I'm not an expert at shaders or grapsh :) I2m just a mere tinkerer... So care to elaborate a bit? :)
     
  13. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    314
    Of course. Sorry about that. So for the shader that works, you have set the shader category/path to "Hidden/TerrainEngine/Details". Did you also do that for the Billboard ShaderGraph?
     
    GameDevCouple likes this.
  14. Flamacore

    Flamacore

    Joined:
    Dec 17, 2013
    Posts:
    81
    Ah ok got it, Definitely did so. Both shaders are under that category. Maybe we're talking about a naming issue or something else? Also as another note, this might be of interest; When I take a look at the original BillboardWavingDoublePass shader, I see the render mode is set to "GrassBillboard" but as far as I know there's nothing like that I can set to in Shader Graph. So, could this be a lead?

    Thanks for all the help btw. Really appreciate your time :) @wyatttt
     
    GameDevCouple likes this.
  15. GameDevCouple

    GameDevCouple

    Joined:
    Oct 5, 2013
    Posts:
    2,518
    Guys just wanted to chime in and say that the work you guys are putting into this issue is not going un-noticed! I myself have been wanting a solution to this for a while and I know a few other people such as @hippocoder will directly benefit from the time you are putting in so a very warm thank you!
     
    Sonorpearl likes this.
  16. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,727
    I will use Unity's own or Vegetation Studio Pro. This is not a criticism, just the original plan :D but very grateful to community for stepping up.

    Also I think maybe Unity's graphics depts could use a few more hands!
     
  17. GameDevCouple

    GameDevCouple

    Joined:
    Oct 5, 2013
    Posts:
    2,518
    Is vegetation studio worthit? I have been teetering on the edge for a while now, still not sure if its worth the purchase?
     
  18. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,727
    Best talk to the author. It doesn't work until custom nodes return to SRP though (soon ish). It's by far the best vegetation rendering in Unity though, by miles. But that's partly due to Unity entirely lacking in this department too.

    I think it's performance and tools are very valid and useful additions to anyone's terrain-based toolbox. Weirdly I don't want to use it but probably will have to. The reason I don't want to use it is nothing to do with the asset, simply I like to use built in stuff where possible in case of depreciation.
     
    GameDevCouple likes this.
  19. GameDevCouple

    GameDevCouple

    Joined:
    Oct 5, 2013
    Posts:
    2,518
    Thats mostly my concern, I have had too many assets get unsupported or removed entirely from asset store that I try my best to stay clear of them entirely. But as you say it seems to be the best solution for vegetation currently so I guess I may have to bite the bullet. Anyway I will contact the author for more information and watch some videos regarding it, thanks!
     
    hippocoder likes this.
  20. abstractfragment

    abstractfragment

    Joined:
    Jan 16, 2014
    Posts:
    15
    For some reason, I'm not getting this workaround to take in 2019.2 HDRP alpha? I drop it into the assets folder and nothing happens. Am I missing something?
     
  21. mr-Fox

    mr-Fox

    Joined:
    Jun 10, 2015
    Posts:
    2
    This no more working since 2019 version, because way to engine find shaders by name is broken. You can copy HDRenderPipelineEditorResources from default package folder, paste it to any place, set it to use by HDRenderPipelineAsset and assign shaders there. But grass appears only in scene view.
     
  22. abstractfragment

    abstractfragment

    Joined:
    Jan 16, 2014
    Posts:
    15
    Dang it but thanks anyways.
     
  23. Psychoram

    Psychoram

    Joined:
    Jun 1, 2014
    Posts:
    4
    In unity 2019.1 Hdrp 5.13 is not working. how to solve?
     
  24. FNGamesAlex

    FNGamesAlex

    Joined:
    Sep 22, 2013
    Posts:
    4
    Any news on how to make grass show in unity 2019.1?
     
  25. Troast

    Troast

    Joined:
    Mar 5, 2017
    Posts:
    11
    Yeah I also need grass to work in HDRP and Unity 2019!
     
    ROBYER1 likes this.
  26. crysicle

    crysicle

    Joined:
    Oct 24, 2018
    Posts:
    89
    Can a dev comment on the expected date when the terrain component with all of it's features would be synced with the rendering pipelines? With the constant changes to the HDRP and LWRP and some features that were expected in 2019.1, but were pushed back to 2019.3 it doesn't look like it would be any time soon. This makes me think that creating your own painting tools when it comes to details and wind effects would be more appropriate rather than looking to find a new hack on a new released unity or pipeline version.
     
    ROBYER1 likes this.
  27. wondermanstudio

    wondermanstudio

    Joined:
    Dec 14, 2018
    Posts:
    1
    Is that ok to use any prefab placement tools instead? How to get a good performance?
     
    Phoenix116 likes this.
  28. Phoenix116

    Phoenix116

    Joined:
    Jun 30, 2016
    Posts:
    39
    Good question, I have the same doubt, if we place grass manually and set them to static, we should get the same performance than the default grass, right?
     
  29. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,727
    You'll get awful performance. Possibly the worst.

    Static batching: this will consume much more memory and go via CPU, it's just bad for lots of little things. Static batching is for fewer big infrequent and different objects that would not normally batch.

    However, some developers choose to actually make clusters of grass as single meshes. This is *not* the same as static batching. It's just combining grass meshes ahead of time into bigger groups. This will hurt you if you don't lod/manage them though.

    For grass it's best to use a proper instancing asset from asset store, something that can handle general cases like asteroid belts, rocks, grasses etc.

    Technically you'd want to use a compute shader to decide what to draw and draw mesh instanced indirect, but that's not for the faint hearted (experienced devs only) and that's what asset store solves in that respect.

    Otherwise the best option would be to use a regular object with camera culling layers set up so they are culled past a certain distance, and ensure the material has gpu instancing enabled.
     
    wyattt_ likes this.
  30. Sonorpearl

    Sonorpearl

    Joined:
    Sep 8, 2017
    Posts:
    32
    @Flamacore How do you use the Shader, or can you even use the Shader in Unity 2019.2 with HDRP? When we paint Terrain Details, even with the Shader inside the project, the Textures are still pink.
     
  31. jonathan_unity900

    jonathan_unity900

    Joined:
    Jul 4, 2019
    Posts:
    1
    Same Question!
     
  32. Flamacore

    Flamacore

    Joined:
    Dec 17, 2013
    Posts:
    81
    Hey, sorry for the late responses but this is not tested for any other version than 2018.3 so I'm not sure how it would perform on 2019 :) As I stated on the github page, it's experimental and may not work as expected depending on many things. For example they may have changed the default name or location for the default unity shaders so they may not get replaced anymore.

    It could be any number of things and unfortunately I don't have the time to test every possibility around that.
     
unityunity