Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

HDRP Terrain 8 layers maximum

Discussion in 'Graphics Experimental Previews' started by AustinRichards, Feb 16, 2019.

  1. AustinRichards

    AustinRichards

    Joined:
    Apr 4, 2013
    Posts:
    321
    Currently the HDRP TerrainLit shader only supports a single pass and 8 terrain layers maximum. Is there any plans to make it possible to have a higher maximum, with additional passes?

    Is there any current way around the 8 layer limit too?
     
    Waterlane likes this.
  2. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    Couldn't you just split your terrain into smaller chunks and have individual terrains use 8 layers max? You can still use same few materials on the terrain borders so you would get smooth transition from one chunk to another. Adding passes sounds pretty expensive.
     
    Ryiah, Danua and hippocoder like this.
  3. Waterlane

    Waterlane

    Joined:
    Mar 13, 2015
    Posts:
    188
    This would be useful for scenes rendered to video...
     
    newguy123 and AustinRichards like this.
  4. Danua

    Danua

    Joined:
    Feb 20, 2015
    Posts:
    197
    Maybe texture array can do this like megasplat in legacy rp?
     
  5. BlasterDm

    BlasterDm

    Joined:
    Aug 28, 2018
    Posts:
    6
    Hey, are there any updates on this topic? Decided to upgrade my project to HDRP. My terrain is already done and has about 20 layers. So part of them became black after update. Got stuck with this problem (unity version 2019.2.11f1). Would appretiate any advise.
     
    Waterlane likes this.
  6. Flow-Fire-Games

    Flow-Fire-Games

    Joined:
    Jun 11, 2015
    Posts:
    305
    Any update on this?

    Please let us create terrain shaders with shader graph, this fixed forced standard shader approach is ancient and crippled unity for so long. We dont need a one size fits all terrain shader that never fits any professional requirements, neither with standard shader nor standard terrain shader. This approach just dosnt work.

    UDK terrain could do that 15 years ago.
    Im in HDRP and I have 8 terrain layers like Im in a Roblox mod editor. Not even thinking about parallax occlusion, tessellation, displacement mapping and not even dreaming about any cutting edge tricks from 2015 like mesh blending.

    Im sorry I have to be angry about this but this needs to be said, some people need a reality check.
    Stop forcing these standard shaders no professional ever uses or wants and which are outdated the day they come out. Embrace shader graph and stop spending resources on total dead end standard shaders, people said it for a decade now.

    Add support for shader graph, One closed system that works throughout the Engine. make a working preset and let people do their thing. Im waiting since Unity 3 for an update and coming back after 10 years full of anticipation and seeing this is maddening. And its 1 year since that guy here asked for his terrain to not go black when above just 8 texture layers, it feels like nobody ever tries to build anything with these tools some times.

    (Edit: Previously also complained about lack of splat map and slope support but that seems to be there in a way to paint it with 2019.2, which I definitely appreciate)
     
    Last edited: Jan 27, 2020
  7. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    789
    We are all waiting to make custom terrain shaders with shader graph but some of the features you mention are already there. Download the Terrain Tools package and you will be able to apply splat maps and advanced terrain creation features. Still nothing on the shader side yet, tessellation, POM, etc.

    Docs
    https://docs.unity3d.com/Packages/com.unity.terrain-tools@2.0/manual/index.html

    Two blog posts about the tools it contains
    https://blogs.unity3d.com/2019/05/28/speed-up-your-work-with-the-new-terrain-tools-package/
    https://blogs.unity3d.com/2019/08/1...ainting-with-the-2019-2-terrain-tools-update/
     
  8. Flow-Fire-Games

    Flow-Fire-Games

    Joined:
    Jun 11, 2015
    Posts:
    305
    Is there an update to this?

    I had to embarrassingly explain my environment artist that Unity only supports 8 texture layers simultaneously and this is likely not a bug..
     
  9. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    883
    Microsplat has HDRP support. This is the only solution I see right now.
     
  10. Flow-Fire-Games

    Flow-Fire-Games

    Joined:
    Jun 11, 2015
    Posts:
    305
    The microsplat creator recently explained how its near impossible for him to make anything for HDRP due to Unity handling of packages and updates
     
  11. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    883
  12. Zicore

    Zicore

    Joined:
    Jul 2, 2018
    Posts:
    10
    I'm also looking for a solution, microsplat with the HDRP support doesn't work either. It renders either pink or blacks out completely after adding the ninths texture layer.

    EDIT: It works! Just go to the MicroSplat Material -> Core -> Max Texture Count
     
    Last edited: Jun 7, 2020
    KeybladeViking likes this.
  13. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Damn right it works..
     
  14. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Oh it's possible to make, it's just the maintenance that's killer. No documentation on shaders, no abstraction layer, breaking changes not being in the change list, overly abstracted shader code with no comments, releases not tied to unity versions, 4 different renderers to port changes between and abstract, basically if you asked me how to make shaders worse for Unity I wouldn't have come up with something this bad.
     
  15. JJRivers

    JJRivers

    Joined:
    Oct 16, 2018
    Posts:
    137
    I managed to make a shader that could support more layers on the terrain but have no idea how to get the painting tools to actually make a 3rd alpha splat
     
  16. yangmirus

    yangmirus

    Joined:
    Aug 3, 2022
    Posts:
    1
    I'm also looking for this. can you share your shader? I would be greatly appreciated.
     
  17. JJRivers

    JJRivers

    Joined:
    Oct 16, 2018
    Posts:
    137
    The full feature shader is owned by my employer and i can't share that one, but i'll look into sharing the basic one that shows the implementation i created on my own time first for URP that i do own.
     
  18. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    They will automatically and it will be sent to the shader as _Control2 (3,4,5,6, etc). Basically Unity's terrain tools don't have any limit to how many splat maps can be used, only the shader they ship does.
     
    hippocoder and JJRivers like this.
  19. JJRivers

    JJRivers

    Joined:
    Oct 16, 2018
    Posts:
    137
    I had some other funky stuff happen and abandoned the effort when doing that and didn't actually notice that fact, thanks for correcting me!
     
  20. REDACT3D_

    REDACT3D_

    Joined:
    Nov 8, 2020
    Posts:
    222
    my work around is to have more then one Terrain going
    or turn off layers
     
    Last edited: Sep 13, 2022
    JJRivers likes this.
  21. JJRivers

    JJRivers

    Joined:
    Oct 16, 2018
    Posts:
    137
    What we chose was retain the 8 layers limit per terrain (it's a sensible limit in terms of shading considering once you start using enough texture types in the shader you're quickly hitting DX11_0 limits anyways).
    Our scene would consist of up to a few dozen different terrains, which we would also cull manually with a Burst compiled Job to retain additional performance, final tally was negligible performance cost despite having pretty detailed and extremely complex final shader.
     
    Waterlane and REDACT3D_ like this.
  22. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    The dx11 texture limit is 128 textures, but 16 samplers. And texture arrays blow way past that by allowing a single texture to contain up to 1024 textures in it. The real cost is that Unity's system for storing splat maps uses 1 texture for every 4 textures on the terrain, and leaves them uncompressed as well, so burns memory on high texture counts like crazy. I get around this in microsplat's 256 texture module by using my own format that does this as a single texture.
     
    hippocoder and JJRivers like this.
  23. JJRivers

    JJRivers

    Joined:
    Oct 16, 2018
    Posts:
    137
    I'll rephrase since that isn't the entire point i had in mind and i worded my response rather poorly so sorry for that, the issue one will usually run into is the memory bandwidth on your average gaming GPU when using too many textures for a single shader.

    You can try to make it as flat as possible but eventually you'll either burn too much memory or too much bandwidth when you try to stay inside the DX11_0 texture limits so the texture limits aren't the actual issue really but final performance goals for a releasable game. Arrays can alleviate and allow you to blow past the limits that but it won't get around eventual soft performance limits of trying to sample textures with 16 samplers with 128 textures for example when you have a ton of other things occurring in the same shader to boot.

    My view is probably colored by the fact that the last major project i personally had far greater challenges of optimizing for GPU memory than i did for optimizing my algorithms and effects for computational performance.
     
  24. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    That's not actually true - any given pixel on a terrain rarely has more than a few textures showing at a time, so that kind of brute force sampling approach (that so many people do) is terrible. MicroSplat only samples 4 texture sets per pixel regardless of how many textures are on the terrain. It can further cull that down at runtime. When you combine that with triplanar, stochastic, and distance resampling, doing it the brute force way can be hundreds of samples per pixel, where in MicroSplat it will often be 30-40. If you check out my Youtube channel I have two videos on the optimization techniques I use, and some info on my blog about it.

    Plus, once you remove the limits on texture counts, you can use a bunch of smaller textures blended together to create infinite non-repeating surfaces with lots of variation instead of using giant 2k textures everywhere.
     
    hippocoder likes this.
  25. JJRivers

    JJRivers

    Joined:
    Oct 16, 2018
    Posts:
    137
    Using MicroSplat was not an option at the time this was implemented and we weren't looking for just Any terrain shader that does better than Unitys stock shader but highly customized shader with custom effects that didn't require writing an entire terrain system ourselves or modifying yours to fit our needs. I packed the control splats with reduced accuracy which was compensated for with customized height blending which allowed us to mix up to 5-6 layers in an exact same spot of the terrain.

    For anyone looking for better terrain shading, i've always referred them to use yours instead of making their own but it isn't an automagic solution for every need respectfully :)
     
  26. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I'm. not trying to sell you MicroSplat, just pointing out that what your stating is incorrect - you don't have a 16 texture limit, you don't have to sample every texture on the terrain, etc. These are common misconceptions that don't need to be propagated.
     
    hippocoder likes this.
  27. JJRivers

    JJRivers

    Joined:
    Oct 16, 2018
    Posts:
    137
    Mind you i don't mind being sold something good :D

    But i think we were talking at cross purposes there, would you mind elucidating exactly where/how you believe/know i'm wrong about this subject i would certainly like to know.

    My use case was a situation where i am Actually rendering 3-7 terrain layers simultaneously on the same terrain in close proximity to each other, say if i have 4 layers all competing for top spot in a given spot on a pixel, i'll presumably have to actually evaluate the weights of those layers which are in the splat map no?

    I'm the first to admit my knowledge of shaders isn't perfect and would love if you could elaborate more clearly what you particularly mean in this context because it wasn't clear to me or was at cross purposes to what my usecase was.
    edit:formatting
     
  28. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Each pixel can evaluate which textures it needs to sample and only sample those textures.

    So if that particular pixel only uses grass and dirt, that is all it needs to sample. You could have hundreds of textures in close proximity on one terrain, but each pixel can do its own evaluation of what it needs to sample. I have two videos on this on youtube, explaining exactly how I do this in MicroSplat, which has both a rough cull down to the 4 highest weights per pixel, and then a dynamic cull per pixel using dynamic branching.

    In practice, it's extremely rare to find more than 4 textures on any given terrain pixel, and the weight of the last one is so low that omitting it and rebalancing the weights is not visible. When you add a feature like height based blending, it's basically non existent to find such cases. On a typical terrain, you average about 1.7 textures per pixel being visible (with other factors like triplanar, stochastic, etc multiplying the number of samples needed higher- but these can be culled as well - for instance, a lot of the map points up and only needs the top projection for triplanar).

    The only case where I can practically see needing a large of samples is using large linear blend with essentially flat colors, where the output is simply a blend of color. And even in that case, if the weights are varying over the space, I would expect there would be an upper limit on what would be visibly possible to discern.

    And as for the splat maps, rather than storing one texture for every 4 texture sets used on the terrain, you can use an index/weight mapping instead. Storing some number of texture indexes and weights for each of them. This allows you to have hundreds of textures using a single splat map because your only storing which textures are actually used on each pixel (you still have to interpolate these values, so technically any given pixel in the world could have 12 weight values, but again, you can remap this down to your desired maximum since most of these will end up the same indexes).
     
    hippocoder likes this.
  29. Jonny010

    Jonny010

    Joined:
    Feb 16, 2019
    Posts:
    7
    So is there a solution to increase the terrain layer count using Unity's Terrain in HDRP? I don't really see a way to change the terrain-shader nor the amount of passes on the newest version of HDRP. I heard of custom shader passes but I never worked with those and don't know if that's an option.

    I'd like to keep all the gadgets from Terrain Tools so I'm not really keen of writing my own Terrain class and shaders, but I don't really see any solution besides using chunks and hoping no chunk needs more then 8 layers.

    I'm using biomes for generating the terrrain via code and 8 layers max is kind of a tough limit for me.
     
  30. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    There is no 8 layer limit to HDRP- Unity's shader only handles 8 layers, you can have as many as you want.
     
  31. Jonny010

    Jonny010

    Joined:
    Feb 16, 2019
    Posts:
    7
    Thanks for the heads up!

    Yeah I figured there's no limit to it, but as I understood it won't render more then 8 layers using Unity's shader. So I'm trying to figure out how I'm supposed to make things work without losing compatibility to Terrain Tools and the likes.

    Only thing that comes to mind is to create chunks and fracture them until it can be rendered with 8 layers. Otherwise I don't know how to get more layers to work using Unity's terrain, but I'm not that good with shaders so I might be missing something obvious or not so obvious.
     
  32. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Just use a better terrain shader which supports more than 8 layers - terrain tools have nothing to do with it, they support any number of layers as well.
     
  33. Jonny010

    Jonny010

    Joined:
    Feb 16, 2019
    Posts:
    7
    Oh yeah duh. I thought that wasn't possible haha.

    I might end up using microsplat for the standard RP then I guess. Do you have any recommendations for a free HDRP Terrain Shader I might use?
    Will those also support the wind features for grass and trees or will I have to implement those separately then?
     
  34. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I don't know of any, but who knows what's out there. Grass/wind have nothing to do with the terrain shader.
     
  35. Jonny010

    Jonny010

    Joined:
    Feb 16, 2019
    Posts:
    7
    Thanks for the help, I'll go take a look at better terrain shaders then, might need to write my own maybe (hopefully not). I thought of looking up the documentation, but there's like nothing sensible there to read haha.
     
  36. mgeorgedeveloper

    mgeorgedeveloper

    Joined:
    Jul 10, 2012
    Posts:
    324
    Just came across this - I copied the built-in HDRP terrain shader with its ridiculous hard-coded 8 layer limit. I then managed to upgrade it to 12 layers through some painstaking hackery.

    This works well so far, except for the fact that today I ran into an issue where a custom pass attempting to render terrain, results in an error "DX12: texture index out of range" when I use my custom terrain shader. So it's not great.

    I do wish they would simply give us a dropdown box to select how many layers we want on our HDRP terrain. 8 is just far, far too low for our purposes.
     
  37. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    MicroSplat - 32 (using Unity's format) or 256 (using a custom one) max..