Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Terrain custom shader graph

Discussion in 'High Definition Render Pipeline' started by Ruchir, Sep 21, 2021.

  1. Ruchir

    Ruchir

    Joined:
    May 26, 2015
    Posts:
    934
    So I recently came across this video:


    Is there a way to create custom shaders for terrain in HDRP currently? I wasn't able to get Lit materials to work with Terrain in HDRP either :( (It does seem to work but I can't use terrain layer)
    If I do use Lit material I can't access the splat map or terrain layer by default either, is there a way to get it working currently?
     
  2. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    695
    Technically, nothing prevents you to assign the HDRP/Lit to a material and assign it to the terrain, but indeed, it will totally ignore the terrain layers.
    HDRP comes with a terrain compatible shader, doesn't it fit your needs ?

    An alternative hack is to use the HDRP/LayeredLit shader for the terrain, and assign the terrain splat map to the layer map on the material. But it will ignore the terrain layer settings, you will have to set up everything on the material itself, and is limited to 4 layers.

    Finally, you can create a shadergraph that you assign to the terrain material, but once again, you'll have to assign the terrain splat maps and the different layer textures to it manually.
    I think it should be possible to automagically grab them in the shader using custom function nodes where you declare the proper shader variables in the code, but you'll have to try that out.
     
    FlightOfOne and Ruchir like this.
  3. Ruchir

    Ruchir

    Joined:
    May 26, 2015
    Posts:
    934
    Could you point to some resources related to this? :)
     
  4. Ruchir

    Ruchir

    Joined:
    May 26, 2015
    Posts:
    934
    Check the video I linked above, things like shader based random noise and other things for better terrain shading aren't available in HDRP terrain shader by default and it can't be achieved just using paint techniques or something like Gaia (asset store package).

    So, I really wanted to try and create custom terrain material for my needs :)
     
  5. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    695
    Ruchir likes this.
  6. sqallpl

    sqallpl

    Joined:
    Oct 22, 2013
    Posts:
    384
    @Remy_Unity

    Is it already possible to create a shader graph that would work with terrain normals?

    We have our shader graphs for terrain ready but we are still using them on meshes instead of terrain because of this limitation:

     
  7. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    695
    I don't think it's already possible.
     
  8. JJRivers

    JJRivers

    Joined:
    Oct 16, 2018
    Posts:
    137
    Incase you never found out the answer i'll go ahead and necro this post since it comes up pretty high on google rankings.

    You can simply ignore that warning about terrain tangents, they do exist in HDRP atleast, but the Unity shader doesn't use them and they presume you must be using a shader that functions identically to the unity terrain shader, so it's safe to completely disregard that warning as it's not true if your shader does use them.

    As to why Unity has decided to keep rolling with 10 a ten year old shader with more TODO, Hack, Bug comments than comments about how it does work or why they think that their shader is so good you'd never want to replace it is anybody's guess but you Can make your own and do it with Shader Graph to boot.

    Steps you'll need to do to achieve this:

    • Find all the relevant variables in the unity terrain shader, declare those as unexposed variables in your shader graph
    • Sample them for the most part as they do but instead of using the derivative functions for tiling you use 1/tiling + offset method for the UV sampling.
    • Create a component that grabs the relevant data from a given terrain compnent: splatmaps, terrainlayer properties etc
    • Apply that data to a material property block, then apply that MPB to each terrains material.
    • Limitations, i was not personally able to get instancing to work in SRP but i made the shader itself compatible with SRP Batcher and keep the terrain size small and handle culling for those terrains myself. (Which is ludicrously fast even on the CPU if you use Jobs&Burst which are a godsend example of good tech Unity has)
    Visual examples of a custom HDRP Terrain Shader Graph in a soon to release production:

    Without PP, custom heightmap sampling with identical layer weights demonstrating 4-6 layers in single spot:

    https://i.gyazo.com/d6b384031c1a8097ce49196bfa6a6020.jpg Ours left, unity terrainshader on right
    https://i.gyazo.com/5bebccb41e28e99feaad64d344909a4a.jpg Unity terrainshader on left, ours on right

    Early production shot:

    https://i.gyazo.com/06d989035ed8327698c64b5734f17416.jpg

    Obviously Unitys heightmapping isn't designed to be able to do this and ergo looks worse than it would in actual use since you wouldn't paint 6 equal weights of layers with the Unity shader. As such the shots were taken as demonstration of what you Can do when you have a custom terrain shader. In addition to that we now have the ability to have fully global effects since 100% of the environment shaders we have are now subgraph modularized shaders.
     
    Ne0mega, chadfranklin47 and MrBigly like this.
  9. Deleted User

    Deleted User

    Guest

    So can I use tesselation and pixel displacement on the terrain with the shader graph right away by using this technique??
     
  10. JJRivers

    JJRivers

    Joined:
    Oct 16, 2018
    Posts:
    137
    Since we're releasing this very month we're on 2020.3 LTS and not the newer tech branches where the Tessellation stage is an in-built feature of Shader Graph i cannot say for certain. I don't see an obvious blocker.

    If it's worth developing your own Terrain shader you should consider your priorities first and foremost, what version of Unity will you be releasing on and how important are the features you're looking to get out of it. If you already have a suitable in-place system for doing that it may or may not be worth the hassle.

    But if you don't want to dedicate the time to develop your own terrain shader graph only to find it potentially may not work with Tessellation and that is a feature you really want, i can do a test run with ours and see if it works but that'll have to wait until may since i'm rather busy until then. If you can wait for that and want to know for sure then fire up a PM at me here at the forums and i'll add it to my calendar.
     
    Deleted User likes this.
  11. nehvaleem

    nehvaleem

    Joined:
    Dec 13, 2012
    Posts:
    429
    Despite I wasn't the one being asked but I cannot withhold myself - 8 textures limit. Seriously it is a massive dealbreaker for me. We have to stick with solutions like Microsplat which are far superior in terms of performance and extensibility for that matter. Why do you guys try not to see what is the real problem with your approach?
     
    cmdexecutor likes this.
  12. nopesecretname

    nopesecretname

    Joined:
    Mar 5, 2023
    Posts:
    2


    The current Layer system for terrains is a joke.

    Who goes around and hand paints their entire landscape? Unity should come with a proper shader for landscapes that takes different materials and combines them based on presets.

    The fact that I can find numerous videos explaining how to do this in Unreal Engine using blueprints but not a single video on how to do this in Unity is annoying.

    It makes me think the terrain tool is essentially useless and I am better off just making a Terrain in Blender and importing it into unity as a mesh and then using a shader to apply materials.

    Even that I mean.. I might as well just use Unreal Engine at this point.
     
  13. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    695
    Nothing prevents you to create a Lit shadergraph, assign it to a material, and assign this material to the terrain.
    You can then in the shader do some procedural layering (similar to what the videos you've mentioned are doing) by blending textures based on : altitude, world position, slope .... without ever using the layer painting.
     
    MrBigly likes this.
  14. Ruchir

    Ruchir

    Joined:
    May 26, 2015
    Posts:
    934
    Is there a way to access the splatmaps, and other layer properties (like the textures)
     
  15. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    695
    Not directly, but you can assign the splatmap texture from the terrain (visible as sub asset of the terrain in the project window) as texture input for your material, as well as the different layers textures.
    You'll then be able to sample the splatmaps and layers textures from you shader and work with it.
     
    Ruchir likes this.
  16. JJRivers

    JJRivers

    Joined:
    Oct 16, 2018
    Posts:
    137
    This is how i did it, i simply have an additional component on every Terrain instance, it automatically samples the splats/textures and applies them to the Terrain material via a property block. In editor it also monitors for changes to the Terrains dirty state and whenever it's dirty it reapplies the splats/textures.

    It's a bit of a hassle to reverse engineer the shader + the terrain components way of doing things but it's not pure blind dev since both do have the relevant portions exposed in code for us.

    As a bonus since i now have a component on each Terrain i made my own culling solution on them which disables the entire terrain if it isn't in view or in the Main Directional Light cone. Which gives quite a few precious frames if you use high quality Terrain extensively.
     
    Ruchir likes this.
  17. mgeorgedeveloper

    mgeorgedeveloper

    Joined:
    Jul 10, 2012
    Posts:
    317
    Since this thread is alive again, here's my opinion on the matter of Shader Graph support for terrain.

    I'm quoting your reply/question to the OP from 2021 - "doesn't it fit your needs"? It's a totally fair question because on the surface the built-in shader and the generally upgraded terrain system is pretty good. But as is often the case in Unity, the given feature is quite close to what you need, but then there is just that one thing you want to do, and can't get (and I'm not picking on Unity, I'm sure the "other engine" has similar issues).

    In our case (with Farm Folks), we almost instantly needed 12 layers in the terrain - and guess what... HDRP for some reason is hard-coded to 8. So I had to copy and paste all the source textures, and hand modify the source so that 8 means 12, so I basically hacked 12 layers into it, and thank goodness the terrain component's UI was quite happy to live with this (and not also forced to 8).

    Now I imagine in my head this utopia, where I click Create -> Shader Graph -> Terrain. On the main settings in this shader graph, I select "Number of layer" -> 12. Or possibly a Terrain Layers node for sampling layer weights, with a dropdown selecting how many layers to expect. Then you have some nodes for sampling and blending the splats according to the layer weights. Etc. It would be so nice to have a dedicated Shader Graph for advanced terrain materials.

    So back to the original question - I actually think that in most cases, the built-in shader, material, terrain component settings, etc... it does not meet "the requirements" because people have very specific requirements. If custom Shader Graphs are often required in for general objects, foliage, characters, and everything else, then it stands to reason that such custom Shader Graphs would also be required for terrain... I mean.... why not?
     
  18. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    Unity planned for terrain shader graph integration, but the person working on it left unity I believe in 2021, someone else at unity picked up the work at that time, but it seems that nothing came out of it/the idea was abandoned. Not sure what happened. A proper integrated solution would be great for sure.
     
    AydinDeveloper likes this.
  19. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,247
    Does the terrain shader graph integration relied on a single person who left Unity 2 years ago? That doesn't make sense at all!
     
  20. jjejj87

    jjejj87

    Joined:
    Feb 2, 2013
    Posts:
    1,115
    This is just madness...why can't the shader graph support just be added...after all this time...
     
    Deleted User likes this.
  21. Marou1

    Marou1

    Joined:
    Dec 13, 2021
    Posts:
    161
    There is this video:

    It explains how to create a shader graph for terrain.
    There is a Control Texture that is needed as a property (_Control). Each channel (R G B A) represents a terrain layer.
    I am using it and it works great. However, you will be limited to 4 layers. The guy who made the video does not know how to get more layers.
    Maybe the Devs could explain how to control more layer?
     
  22. DEEnvironment

    DEEnvironment

    Joined:
    Dec 30, 2018
    Posts:
    437


    The _Control texture is also referred to as “Splat” a texture sample has 4 channels RGBA, each channel is the mask for one set of textures.

    Built-In and URP they use something called “AddPass” that is realy second shader assigned dependency of “Fistpass” shader. The AddPass also uses _Control texture.

    in HDRP it does not have AddPass, they use two control textures called _Control and _Control1 that will run all 8 layers in one pass.
     
    oleg_v and Ruchir like this.
  23. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,247
    @Marou1 Ok but what we are looking here is the official terrain integration in Shader Graph rather than the first search result online.

    Features that can't be reproduced are mainly terrain Instanced Drawing which greatly improve performance and reduce drawcalls and things like terrain specific internal data (tangents...).

    @DEEnvironment Having 8 or more terrain layers is also another important feature but as you said Shader Graph cannot have additional passes. However I've seen people could feed more than 4 layers in their terrain shader graph but I have no idea how they did it! Do you have a working reference for this or how to blend splatmaps?
     
  24. DEEnvironment

    DEEnvironment

    Joined:
    Dec 30, 2018
    Posts:
    437
    Code (CSharp):
    1. Features that can't be reproduced are mainly terrain Instanced Drawing
    the reason for this issue i think is in SG Lit templates use "pragma instancing_options renderinglayer"
    however, for terrain it should use "pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap


    i build all my shaders with amplify and make my own custom templates to compile with amplify.
    sorry i am not aware what SG can or cannot do about for adding dependencies and tags that are need in terrain system.
     
    TerraUnity likes this.
  25. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,247
    @DEEnvironment Thanks for the help, yes a lot of tags and dependencies are still not present in SG and adding them manually in hundreds of thousands of compiled codes is not ideal or doable at all. Another option is to add a custom sub-node to inject more options but they may fail due to SG limitations at the end!

    We are in the middle of developing a terrain shader in SG for HDRP & URP pipelines and will update you once we are getting close to the release.
     
  26. Marou1

    Marou1

    Joined:
    Dec 13, 2021
    Posts:
    161
    @TerraUnity I was asking a question related to what I, actually, was looking for, that is related to the first post of this thread and may help other people, rather than answering your specific needs.

    @DEEnvironment Thanks, _Control1 works!
     
  27. Crazy34

    Crazy34

    Joined:
    Jul 14, 2019
    Posts:
    65
    We wrote our own custom solution that supports 128 Terrain Textures with shader graph. In other words, since the SG system has been activated, we have already known from day one that we can throw an SG material into the Terrain Material section. So I'm asking; Since Terrain system is not supported internally in Unity Terrain SG, how do we manage to mark Terrain Draw Instanced? We are clever enough to put SG Material in the Terrain Material slot. We are waiting for more permanent and fast solutions now!
     
  28. Crazy34

    Crazy34

    Joined:
    Jul 14, 2019
    Posts:
    65
    Yes, we've been staring at that screen for over a year :D
     
    jjejj87 likes this.
  29. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,247
    It's always good to point other users in the right direction and help them but I was pinging someone at Unity to take this into consideration. And I don't have a specific need here on forums while I was writing exactly what OP needed here to have official terrain compatibility in SG.

    @Crazy34 Guess a lot of users here have no idea about Unity delays and failures in bringing multiple projects and features and no offense on them (Unity) since my small company is never on our roadmap too :D So can you share general info on how you could feed 128 terrain layers in SG? Are they connected to splatmaps? Because that's the main goal here!
     
  30. DEEnvironment

    DEEnvironment

    Joined:
    Dec 30, 2018
    Posts:
    437
    for info only if you come across this post reference this closed PR
    -- Terrain Shader Graph Integration #6056
     
  31. Marou1

    Marou1

    Joined:
    Dec 13, 2021
    Posts:
    161
    @TerraUnity Again: I was asking a question, not bringing to you "the first search result online" (a condescending comment does reflect badly on whoever is making it).
    While I agree it is an interesting feature, I don't think that you "pinging someone at Unity" has a lot of chance to change the roadmaps of the product managers. As you may know, they prioritize all the features depending on the value brought to their clients and define an operational strategy that must be in line with the business strategy as defined by the upper management of Unity.
    So, considering that, and the resulting delays, I was just trying to find a workaround to fix my own issue. So I am not even sure to understand why you started pinging me at first, especially since DEEnvironment was helpful and answered my question. So I don't think I will answer your next comment, if there is any.
     
    Last edited: Mar 15, 2023
  32. Crazy34

    Crazy34

    Joined:
    Jul 14, 2019
    Posts:
    65

    We started a high quality MMORPG game with the Unity game engine, our team's professionalism with this engine actually made it possible. But the development process of the engine is not satisfactory at all. Unfortunately, there is no possibility to switch to another engine for a project that has reached a certain level. In-game Terrains are loaded on the player screen in the form of hundreds of Tiles. Yes, all terrains automatically create their own splatmaps archive according to which textures are used in that tile. Basically, it uses the original Splatmaps of the Terrains, but in the build phase, it only creates the used layers as Splatmaps separately. So actually the shader never renders 128 textures, because it would take too long to calculate because it has tesselation, hight blended, seasonal factors and tons of dynamic effects. These shaders are divided into 2, one for editor and one for runtime and both are written through SG. The shader only tries to render 24 textures. 128 textures are stored as an Atlas. When it's in the form of an Array, unfortunately we lose memory control. Because Virtual Texture and mipmap systems work more effectively in Atlases. Our team wrote all this for a huge game. But here, unfortunately, Unity had difficulties at many points.

    As you know, the problem with Unity Terrain system is not only Shader, but also the incredible memory usage in Runtime. Even if they have solved the Shader system mentioned here, the memory to be spent when dozens of Terrains are in the scene in the Terrain working logic, especially for a large number of Texture, results in disaster. :D The solution we are using fixes this as well, we have 80 Terrains in the scene at the same time with 2048 resolution. And we were able to fix the memory usage to Ram(Approx 1gb), Vram(Approx 1gb) just for Terrain for Ultra settings.

    In short, it should not be underestimated that there will be a lot of problems when using the Unity Terrain system in a huge world. However, these problems should be minimized by starting somewhere. A little more burden should be lifted from the developers.
     
  33. DEEnvironment

    DEEnvironment

    Joined:
    Dec 30, 2018
    Posts:
    437


    For this issue I would suggest you take a close at the I mip stream in the sampler states getting overflow breaking the mip stream by crossing the fragment stages, I also had a similar issue and found if I carefully keep the mips from crossing was helpful.. Note be extra careful with the height blending an consider running it multiple times but with diffrent sampler state groupings

    as I see your storing all in a single atlas this could be more challenging
     
    Crazy34 likes this.
  34. Crazy34

    Crazy34

    Joined:
    Jul 14, 2019
    Posts:
    65
    Of course, the Atlas method can have mip seam problems. As you said, we solved this problem by calculating the mipmaps ourselves. Unfortunately, such details were a bit time consuming at first. But now our Terrain Shader works completely smoothly. Since it is only written by SG, there are some incompatibilities with Terrain. Such as inverse calculation of normals (Fixed by showing normal values as negative). Also the Terrain Draw instanced command unfortunately doesn't work because SG doesn't support it. This can be a bit of a problem on CPU usage. We solve this by reducing the pixel lod level. Since pixel lod makes remote landscape Terrains look very bad, we create Mesh Terrains using the same shader. The list goes on and on unfortunately :D
     
  35. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,247
    @Marou1 ?!

    @Crazy34 Wow, great process and implementations, seems like you tackled most of the limitations with the terrain system especially in large worlds which I'm aware is a nightmare. Do you have any media to share or it's under NDA or something?
     
    Crazy34 likes this.
  36. Crazy34

    Crazy34

    Joined:
    Jul 14, 2019
    Posts:
    65

    You can, of course, check out our massive online game where we have implemented all this. I hope it's not considered off-topic here.

    There was a really challenging process about the map. I can't deny that, we had to use our own tools at many points.

    The project we are working on as project developer leader and company partner is as follows:
     
  37. DEEnvironment

    DEEnvironment

    Joined:
    Dec 30, 2018
    Posts:
    437
    @Crazy34
    Code (CSharp):
    1. Also the Terrain Draw instanced command unfortunately doesn't work because SG doesn't support it.
    as discussed up in this thread the reason for this issue i think is in SG Lit templates use "pragma instancing_options renderinglayer" however, for terrain it should use "pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap

    additional note that just adding the new pragma is not enough as you must fully remove the other as it would conflict.
    that may be the harder part about working with SG ?

    pragma multi_compile_instancing
    pragma multi_compile _ DOTS_INSTANCING_ON
    goes in pass: Forward / GBuffer / ShadowCaster / DepthOnly / DepthNormals

    pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
    goes in pass: Forward / GBuffer

    cheers
     
    Talaei_Dev and Crazy34 like this.
  38. Crazy34

    Crazy34

    Joined:
    Jul 14, 2019
    Posts:
    65
    Yes, we had some experiments on this issue, but due to time constraints we could not work on it much. Thank you for your suggestion, we will take these issues into consideration when we review it again. :)
     
  39. Sunstrace

    Sunstrace

    Joined:
    Dec 15, 2019
    Posts:
    40
    AD: https://assetstore.unity.com/packages/tools/terrain/blank-first-dotsterraingrid-225217
    This plugin uses shadergraph entirely to make the shader of the terrain, and uses texture arrays to organize textures, so you can break the limits of HDRP 8 layers, and each base unit is sampled by the actual number of mixed layers. Welcome everyone to try it out and give me some feedback. More features and optimizations of this plug-in are still being improved.
     
  40. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,247
    In my 12 years of experience in terrain tools development and environment art and creation, I never felt needing to have more than 8 terrain layers even in a huge scene, it all comes down to choosing good textures and more importantly nice blending between them using an advanced shader, just my 2 cents on this.

    @DEEnvironment @Crazy34 Please update this thread if you could implement instanced drawing in Shader Graph for terrains, we tried and failed for the normals calculation part but we could get around the instancing and drawcallls decreased immensely!
     
    Ruchir likes this.
  41. jjejj87

    jjejj87

    Joined:
    Feb 2, 2013
    Posts:
    1,115
    I have to say that 8 layers is just not enough...and it forces the user to use the terrain in a specific way. I would agree with you if the limit was like 16 but 8 is a bit too much. Also, think of the next 12 years. It is time to work on the Terrain system.
     
    TerraUnity likes this.
  42. Sunstrace

    Sunstrace

    Joined:
    Dec 15, 2019
    Posts:
    40
    For normal calculation, my solution is to generate normal map through precalculation, so that they can be directly used in shadergraph, and there is no need to calculate the normal of each vertex in shadergraph.
     
    TerraUnity likes this.
  43. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,247
    While I agree with you on this, for larger worlds, the scene is split into chunks for streaming and each tile in chunk can have 8/16 textures for a smaller area and this way you can have different biomes and textures so the entire world can have as many as terrain layers as you wish.
     
  44. jjejj87

    jjejj87

    Joined:
    Feb 2, 2013
    Posts:
    1,115
    yes, exactly what i said - it forces you to work a certain way. To be exact, just one way.
     
  45. Crazy34

    Crazy34

    Joined:
    Jul 14, 2019
    Posts:
    65

    We haven't worked on the draw instanced command yet, but we have done more important work on the Terrain shader. We worked on the shader that will make our 2016 km2 map more detailed with 256 texture layers and a single splatmap in a single pass. We achieved very high performance and positive results. Again, we achieved this by branching on the shader graph. It is a very similar technique to the technique used by Megasplat/Microsplat. But we can call it a shader graph version. In the near future, we will look at what we can do about Draw instanced again.
     
    TerraUnity likes this.
  46. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,247
    @Sunstrace Thanks for the suggestion, I was thinking to bypass the heightmap normal calculations too since the main goal here is to have better performance which is already achieved and no need for these per-vertex normals for visuals.

    @Crazy34 Thanks for the info, looks like an advanced shader you have there, so I assume this is a new splatmap system which is not linked with Unity's terrain system to paint/erase layers in terrainData?
     
  47. Crazy34

    Crazy34

    Joined:
    Jul 14, 2019
    Posts:
    65
    Yes, unfortunately we had to write our own Layer Painter system. Due to the large variety of biomes and layers, both memory and performance decrease a lot as splatmaps multiply, even though we can use 24 different layers per chunk terrain, Splatmaps are insufficient for performance and detailed Level Designer operations.
     
    TerraUnity likes this.
  48. oen3

    oen3

    Joined:
    Aug 16, 2021
    Posts:
    20
    Just to bump on this, did anyone manage to get a custom Lit shader graph to work with Terrain's instancing option? I still have not been able to do this, tried a bit with the flags you suggested above. If this could work if would be a recognizable performance boost. I really hope Unity authors a TerrainLit shader graph that works with instancing by default...
     
  49. JasonB

    JasonB

    Joined:
    Dec 29, 2010
    Posts:
    102
    I've been fighting with getting a custom terrain shader working as well.

    I was able to create a sort of basic triplanar shader in shadergraph (HDRP), but have some very strange issues. The mesh "jitters" or something.

    Also, like you, I can't seem to get it working with instancing on. It just creates wild flailing polygons and emptiness.

    This is frustrating because the default terrain shader is hot garbage, and I refuse to use it. I'll export a mesh from another software instead of using the Unity terrain at all if I really have to, just so that I can use a custom shader on it without it going wonky.

    Half the time I try to do anything in Unity, there's always a hard needless roadblock waiting for me that I need to design my own workaround for. I'm used to it at this point, but it's exhausting.
     
    Last edited: Dec 6, 2023
    daxiongmao likes this.