Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

2019.2: Overriding shaders of Terrain-Grass

Discussion in 'Shaders' started by Selupsis, Aug 9, 2019.

  1. Selupsis

    Selupsis

    Joined:
    Mar 17, 2019
    Posts:
    5
    Hi!

    For my project I'd like to modify the shader that is used to render the grass-meshes that I paint on the terrain with the Unit tools. However, following the instructions I have found I still cannot modify the shader...

    Here's what I tried:
    • Downloaded the built-in shaders for the correct version
    • copied the shaders into the Assets-folder
    • Tried to modify the shader "Hidden/TerrainEngine/Details/WavingDoublePass"
    However, the grass always renders the same, even if I e.g. change the color in the shader

    I tried tips that I found, like hitting the "Refresh"-Button for the according Detail-Stencil in the according details setting, reloading the project, creating a new terrain... Neither the grass-shader, nor the VertexUnlit-shader that I can choose when creating a mesh-detail brush are affected...

    I remember it working in a 2018.x-Version of Unity, did something change in the meantime?

    I'm currently working in a LWRP-project, but I also created a quick "normal" 3D-test-project, and it also did not work there...
     
  2. Aerial_Knight

    Aerial_Knight

    Joined:
    Aug 9, 2012
    Posts:
    85
    Did it ever find a solution? I have been trying to get grass to render in LWRP for about a week now with no luck
     
    astracat111 likes this.
  3. tmcthee

    tmcthee

    Joined:
    Mar 8, 2013
    Posts:
    119
    Not sure about the details of the grass shader but the name "WavingDoublePass" is a clue for me.
    LWRP only allows single pass shaders.
     
  4. Selupsis

    Selupsis

    Joined:
    Mar 17, 2019
    Posts:
    5
    No luck so far, I'm thinking about implementing something on my own, since I don't know if/when this will be fixed...

    It would make sense - only the Vertex shader you can pick is a singlepass shader as far as I remember, and it too doesn't work... Might be wrong though!
     
  5. Selupsis

    Selupsis

    Joined:
    Mar 17, 2019
    Posts:
    5
    I'll try a simple project with a 2018.x later to see if it works there - it's not an option for me to jump back to an older version, but it might be a useful information for others
     
  6. Selupsis

    Selupsis

    Joined:
    Mar 17, 2019
    Posts:
    5
    Sorry, I missed a part there - the grass doesn't render at all for you with the standard shaders in LWRP? Because for me it renders at least with the default shaders
     
    astracat111 likes this.
  7. Selupsis

    Selupsis

    Joined:
    Mar 17, 2019
    Posts:
    5
    Ok, I did a quick test with 2018.4.6f1, and there overwriting of shaders definitley works - the overwritten shader is definitley loaded as soon as I drag it into the project.

    However, I'm now at the same stage as Aerial_Knight, as the shader does not work (grass is only rendered in pink and does not move), so perhaps there is really a problem with using multipass-shaders... I'll try out a few things I have found
     
    astracat111 likes this.
  8. xdegtyarev

    xdegtyarev

    Joined:
    Jul 2, 2012
    Posts:
    9
    Having same issue with Nature/Terrain/Standard
     
    astracat111 likes this.
  9. astracat111

    astracat111

    Joined:
    Sep 21, 2016
    Posts:
    709
    Having this issue in 2019, the latest version, I think that overriding must have stopped working for some reason? Really need this feature!
     
  10. Arycama

    Arycama

    Joined:
    May 25, 2014
    Posts:
    181
    Same in 2019.2, not using LWRP either. (And LWRP isn't an option due to how many missing features it has compared to the built in pipeline)
     
  11. Arycama

    Arycama

    Joined:
    May 25, 2014
    Posts:
    181
    Slight update, the issue appears to be linked to specific TerrainData assets. I exported the heightmap and splatmap from the terrain, and created a new terrain and imported the heightmap. Newly painted grass now uses the custom shader.

    However if I duplicate the existing TerrainData, the issue still persists with the copy. So the TerrainData must internally cache it's Detail shaders or something, and there appears to be no way to modify it from C#.
     
  12. xdegtyarev

    xdegtyarev

    Joined:
    Jul 2, 2012
    Posts:
    9
  13. astracat111

    astracat111

    Joined:
    Sep 21, 2016
    Posts:
    709
  14. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,010
    Looks like the bug report was closed, and a fix was added in the latest beta version (2019.3.b12). Though I haven't had any luck getting it to work.
     
  15. xdegtyarev

    xdegtyarev

    Joined:
    Jul 2, 2012
    Posts:
    9
    it's still listed in Known Issues as Graphics - General: Custom shader doesn't override built-in terrain shader (1193781)
     
  16. Vita-

    Vita-

    Unity Technologies

    Joined:
    Jul 2, 2019
    Posts:
    120
    Hello, the issue is not reproducible on our side anymore and it seems everything works fine. If the issue still persists, could you please define the exact steps needed to reproduce the issue?

    Cheers,
    Vita
     
  17. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,010
    You're right, I completely misread :p

    @vitaskruibyte I'll see if I can file a bug report and track down the last working Unity version (and if a SRP affects it). But I feel this more comes down to a feature request (being able to assign a custom grass shader/material to a terrain). It seems this only used to work by accident, since it was never an official feature but more of a hack.
     
  18. xdegtyarev

    xdegtyarev

    Joined:
    Jul 2, 2012
    Posts:
    9
    @vitaskruibyte i've sent an email today with updated sample and more details
     
  19. xdegtyarev

    xdegtyarev

    Joined:
    Jul 2, 2012
    Posts:
    9
  20. Gufetto

    Gufetto

    Joined:
    Oct 19, 2015
    Posts:
    29
    Really annoying... In case it can help, this is how I solved this issue in my asset store plugin, which required that grass replacement hack to work:

    Code (CSharp):
    1. using System.Text.RegularExpressions;
    2. using UnityEditor;
    3. using UnityEngine;
    4.  
    5.  
    6. // Kinda hardcoded, but works rather well
    7. public class TerrainDataHelperWindow : EditorWindow
    8. {
    9.     [MenuItem("Window/BendinGrass/Terrain Helper")]
    10.     public static void Init()
    11.     {
    12.         var window = (TerrainDataHelperWindow)GetWindow(typeof(TerrainDataHelperWindow));
    13.         window.titleContent = new GUIContent("TerrainData tool (Unity 2019.2.0+)");
    14.         window.Show();
    15.     }
    16.  
    17.     void OnGUI()
    18.     {
    19.         DrawTerrainConversion();
    20.     }
    21.  
    22.  
    23.     private void OnInspectorUpdate()
    24.     {
    25.         TerrainConversionTarget = Selection.activeGameObject?.GetComponent<Terrain>();
    26.     }
    27.  
    28.     bool _showTerrainConversion;
    29.  
    30.     Terrain _conversionTarget;
    31.  
    32.  
    33.     TerrainData _dataTarget;
    34.  
    35.     public TerrainData DataTarget
    36.     {
    37.         get
    38.         {
    39.             return _dataTarget;
    40.         }
    41.  
    42.         set
    43.         {
    44.             if (_dataTarget != value)
    45.             {
    46.                 _dataTarget = value;
    47.             }
    48.         }
    49.     }
    50.  
    51.     public Terrain TerrainConversionTarget
    52.     {
    53.         get
    54.         {
    55.             return _conversionTarget;
    56.         }
    57.  
    58.         set
    59.         {
    60.             _conversionTarget = value;
    61.  
    62.             if (_conversionTarget != null)
    63.                 DataTarget = _conversionTarget.terrainData;
    64.             else
    65.                 DataTarget = null;
    66.         }
    67.     }
    68.  
    69.  
    70.     public Object Grass, Billboard, VertexLit;
    71.  
    72.     public void ExtractShaderAssets(TerrainData data)
    73.     {
    74.         string json = EditorJsonUtility.ToJson(data);
    75.  
    76.         string grassProp = GetJsonProperty(json, "m_DetailMeshGrassShader");
    77.         string billboardProp = GetJsonProperty(json, "m_DetailBillboardShader");
    78.         string vertexLitProp = GetJsonProperty(json, "m_DetailMeshLitShader");
    79.  
    80.         Grass = GetAsset(grassProp);
    81.         Billboard = GetAsset(billboardProp);
    82.         VertexLit = GetAsset(vertexLitProp);
    83.     }
    84.  
    85.     public Object GetAsset(string prop)
    86.     {
    87.         Regex fileReg = new Regex("\"fileID\":\\s*\\d+");
    88.         Regex guidReg = new Regex("\"guid\":\\s*\"\\w+\"");
    89.  
    90.         var f = fileReg.Match(prop);
    91.         var g = guidReg.Match(prop);
    92.  
    93.         long fileID = long.Parse(f.Value.Split(':')[1]);
    94.         string guid = g.Value.Split(':')[1].Trim('"');
    95.  
    96.         return AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guid), typeof(Object));
    97.     }
    98.  
    99.     public void InjectAsset(ref string prop, string guid, long localID)
    100.     {
    101.         Regex fileReg = new Regex("\"fileID\":\\s*\\d+");
    102.         Regex guidReg = new Regex("\"guid\":\\s*\"\\w+\"");
    103.  
    104.         var f = fileReg.Match(prop);
    105.         string idString = f.Value;
    106.         idString = idString.Split(':')[0] + ": " + localID.ToString();
    107.  
    108.         prop = prop.Remove(f.Index, f.Length).Insert(f.Index, idString);
    109.  
    110.         var g = guidReg.Match(prop);
    111.         string guidString = g.Value;
    112.         guidString = guidString.Split(':')[0] + ": \"" + guid + "\"";
    113.  
    114.         prop = prop.Remove(g.Index, g.Length).Insert(g.Index, guidString);
    115.     }
    116.  
    117.     public string GetJsonProperty(string json, string property)
    118.     {
    119.         Regex reg = new Regex("\"" + property + "\"\\s*:\\s*\\{(.|\\n)*?\\}");
    120.         var m = reg.Match(json);
    121.  
    122.         if (m.Success)
    123.             return m.Value;
    124.         return null;
    125.     }
    126.  
    127.     public bool ConversionReplace = true;
    128.     public bool OverwriteAsset = false;
    129.  
    130.     public Shader ReplacementShader;
    131.  
    132.     void DrawTerrainConversion()
    133.     {
    134.         EditorGUILayout.HelpBox("Due to changes made in Unity 2019.2.x, you will most likely run into issues using BendinGrass on already existing terrains. To avoid repainting, you can use this conversion tool to generate a new TerrainData asset." +
    135.             "\nSelect your terrain in the inspector and click the Convert button. If you turn off Auto-assign, you will have to assign the new Terrain Data manually, either using the field below, or inspector debug mode.", MessageType.Warning);
    136.  
    137.         EditorGUILayout.HelpBox("Your original TerrainData assets will not be overwritten, but it will generate new ones.\nIt will overwrite the assets only if they are already in the conversion folder.\n\nConversion target folder: \n" + MAIN_FOLDER + CONVERT_FOLDER, MessageType.Info);
    138.  
    139.         //TerrainConversionTarget = (Terrain)EditorGUILayout.ObjectField("Convert Terrain", TerrainConversionTarget, typeof(Terrain), true);
    140.      
    141.         if (TerrainConversionTarget != null)
    142.         {
    143.             EditorGUILayout.HelpBox($"Currently selected: {TerrainConversionTarget.name} ({TerrainConversionTarget.terrainData.name})", MessageType.None);
    144.  
    145.  
    146.             TerrainConversionTarget.terrainData = (TerrainData)EditorGUILayout.ObjectField("Assigned TerrainData", TerrainConversionTarget.terrainData, typeof(TerrainData), false);
    147.  
    148.             EditorGUILayout.LabelField($"Shaders from {DataTarget.name}", EditorStyles.boldLabel);
    149.  
    150.             EditorGUI.indentLevel++;
    151.             EditorGUILayout.HelpBox("You can see or change what the current shaders for this TerrainData are.\nSet to null if you want to use defaults.\nYou have to convert to actually change them.", MessageType.None);
    152.             Grass = EditorGUILayout.ObjectField("Grass Shader", Grass, typeof(Shader), false);
    153.             Billboard = EditorGUILayout.ObjectField("Billboard Shader", Billboard, typeof(Shader), false);
    154.             VertexLit = EditorGUILayout.ObjectField("VertexLit Shader", VertexLit, typeof(Shader), false);
    155.  
    156.             if (GUILayout.Button("Extract from TerrainData"))
    157.                 ExtractShaderAssets(DataTarget);
    158.  
    159.             if (GUILayout.Button("Set null (default)"))
    160.             {
    161.                 Grass = null;
    162.                 Billboard = null;
    163.                 VertexLit = null;
    164.             }
    165.  
    166.  
    167.             EditorGUI.indentLevel--;
    168.  
    169.             ConversionReplace = EditorGUILayout.Toggle("Auto-assign new data", ConversionReplace);
    170.             if (GUILayout.Button(ConversionReplace?"Update and assign": "Update"))
    171.                 RecreateTerrainData(TerrainConversionTarget);
    172.         }
    173.  
    174.  
    175.     }
    176.  
    177.     const string MAIN_FOLDER = "Assets/BendinGrass/";
    178.     const string CONVERT_FOLDER = "ConversionTool";
    179.     string output = null;
    180.  
    181.     public void RecreateTerrainData(Terrain target)
    182.     {
    183.         TerrainData source = target.terrainData;
    184.  
    185.         TerrainData newData = new TerrainData();
    186.      
    187.         CopyTerrainData(source, ref newData);
    188.         string fullPath = MAIN_FOLDER + CONVERT_FOLDER;
    189.      
    190.         if (!AssetDatabase.IsValidFolder(fullPath))
    191.             AssetDatabase.CreateFolder(MAIN_FOLDER.TrimEnd('/'), CONVERT_FOLDER);
    192.  
    193.         string sourcePath = AssetDatabase.GetAssetPath(source.GetInstanceID());
    194.         bool overwrite = false;
    195.         if (sourcePath.StartsWith(fullPath))
    196.             overwrite = true;
    197.  
    198.         string asset = fullPath + "/" + source.name + (overwrite ? ".asset" : "_converted.asset");
    199.  
    200.         AssetDatabase.CreateAsset(newData, asset);
    201.  
    202.         if (ConversionReplace)
    203.         {
    204.             target.terrainData = newData;
    205.             var coll = target.GetComponent<TerrainCollider>();
    206.             if (coll)
    207.                 coll.terrainData = newData;
    208.         }
    209.  
    210.         AssetDatabase.SaveAssets();
    211.     }
    212.  
    213.     void CopyTerrainData(TerrainData source, ref TerrainData target)
    214.     {
    215.         // Quick way to create a deep copy of the source terrain data, with the updated shaders
    216.         string toJson = EditorJsonUtility.ToJson(source, true);
    217.         string fromJson = EditorJsonUtility.ToJson(target, true);
    218.  
    219.         CopyJsonProperty("m_DetailMeshGrassShader", ref fromJson, ref toJson, Grass);
    220.         CopyJsonProperty("m_DetailMeshLitShader", ref fromJson, ref toJson, VertexLit);
    221.         CopyJsonProperty("m_DetailBillboardShader", ref fromJson, ref toJson, Billboard);
    222.         EditorJsonUtility.FromJsonOverwrite(toJson, target);
    223.     }
    224.  
    225.     // "\w+"\s*:\s*\{(.|\n)*?\}
    226.     void CopyJsonProperty(string property, ref string from, ref string to, Object injectObject = null)
    227.     {
    228.         Regex reg = new Regex("\"" + property + "\"\\s*:\\s*\\{(.|\\n)*?\\}");
    229.         var fromMatch = reg.Match(from);
    230.         var toMatch = reg.Match(to);
    231.  
    232.         if (fromMatch.Success)
    233.         {
    234.             if (toMatch.Success)
    235.             {
    236.                 to = to.Remove(toMatch.Index, toMatch.Length);
    237.                 string fr = fromMatch.Value;
    238.                 if (injectObject!=null)
    239.                 {
    240.                     string guid;
    241.                     long id;
    242.                     if (AssetDatabase.TryGetGUIDAndLocalFileIdentifier(injectObject, out guid, out id))
    243.                         InjectAsset(ref fr, guid, id);
    244.                 }
    245.                 to = to.Insert(toMatch.Index, fr);
    246.             }
    247.         }
    248.     }
    249. }
    250.  
    It opens a window that lets you change the shaders saved inside the TerrainData asset. Probably not the most efficient way to do it, but does the job.

    Left the instructions inside the code.
     
    Last edited: Jan 15, 2020
  21. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,069
    Great idea! Unfortunately, at least in 2019.2.5f1 it appears Unity still overrides the Grass shader even with this change! When the asset gets loaded it's stomping on the shader overrides and setting them back to null. >.<
     
    MadeFromPolygons likes this.
  22. Gufetto

    Gufetto

    Joined:
    Oct 19, 2015
    Posts:
    29
    Then I guess it works starting from 2019.2.6, because is the one I currently use. I also tried it on 2019.3.0 and seems to work the same. Don't know how to fix it for older versions tho :S
     
  23. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,069
    Also, one thing about that bug report that @xdegtyarev filed. As worded, Unity was indeed correct to close it as "by design" as the bug report is on automatic replacement of the terrain shader. With 2019 you can assign a material directly on the Terrain component rather than needing to override it via shader name. The note on the issue is it now uses "standard asset referencing", which is accurate. The problem is (as @Gufetto's workaround seems to show) they also changed the grass shaders to use "standard asset referencing", but didn't expose those properties anywhere for users to assign.

    So the real issue isn't really that automatic overriding doesn't work, it's that there is no exposed way to override it!
     
  24. xdegtyarev

    xdegtyarev

    Joined:
    Jul 2, 2012
    Posts:
    9
    @bgolus for me it was critical to do it in an older way, as we added additional render types to built-in shaders to be able to draw them with specific replacement shaders for thermal/segmentation during dataset generation. We have tons of terrains in asset bundles that could not be modified now.
     
    MadeFromPolygons likes this.
  25. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,069
    @xdegtyarev Yeah, I can understand that, as it's something that's breaking backwards compatibility, and I don't think it was explicitly called out in any patch notes (or I missed it). But it is a subtly different case than the one this thread is about, which is something I (and I think other people) missed.

    Basically, the specific issue of "there's no obvious way to override the grass shaders" wasn't what Unity called "by design". Someone needs to issue a bug report specifically on overriding the grass shader as it's a different problem.
     
  26. xdegtyarev

    xdegtyarev

    Joined:
    Jul 2, 2012
    Posts:
    9
    @bgolus I've found the closest match of an issue on forums and submitted reports of exactly my problem. So I agree with you, it makes sense to create another issue on tracker for grass.
     
  27. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,069
    @xdegtyarev Yep. It is technically the same issue in terms of the cause; Unity no longer does name matches to search for shaders internally. I reported the grass issue separately and it got closed as a duplicate and "by design" pointing at the issue you reported. >.<

    Not your fault. Just frustrating. I already responded to the e-mail they sent me explaining why the closed it arguing my case for why it's different, but it can be hard to get things past the "first defenders" when there's similar but subtly different issues that have already been marked closed, especially when they're "as designed" since it's not even an issue of regression testing.

    @vitaskruibyte I don't know if you're paying attention to this topic any more either, but it's Case 1214113 if you want to reproduce the issue. Not sure if I should resubmit the bug with different wording to make the issue more clear.
     
  28. Vita-

    Vita-

    Unity Technologies

    Joined:
    Jul 2, 2019
    Posts:
    120
    @bgolus Accept my apologies for the delayed reply. I will take a look at this issue and will update you as soon as possible. Also, if you have any other details about the issue, let me know.

    Cheers,
    Vita
     
  29. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,069
    Thank you for the reply.

    Concisely: Unity 2019 removed overriding of terrain shaders via shader name and replaced it with direct asset referencing. For the terrain’s main passes this can be modified by using a material with a custom terrain shader. However the terrain’s Grass, Grass Billboard, and Vertex Lit detail shaders, those references are not exposed so they can not by user set when using the built in rendering paths.

    The Terrain shader used to reference those detail shaders through the terrain shader itself and its “dependencies” during the Unity 4.0 days. This was broken sometime during Unity 5.0, which was fine because almost everyone was using shader name implicit overriding instead. Now neither work and there’s no official way to set those shaders outside of the SRPs which do have those shader asset references exposed as part of the renderer asset class. There needs to be some equivalent for the built in rendering paths, preferably per terrain like the terrain material setting.
     
    xdegtyarev likes this.
  30. Tristan-Moore

    Tristan-Moore

    Joined:
    Aug 22, 2014
    Posts:
    18
    Took me a while to figure this out, but it's actually intended behavior and works properly as expected. The settings for the terrain shaders are now included in the HDRenderPipelineEditorResources asset. You'll have to create your own asset so you can edit the shaders in the fields, but it works properly and actually is a pretty straightforward system. Hope this helps!


     
    bgolus likes this.
  31. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,069
    This does fix the specific issue described in the original post. For the LWRP / URP there's a similar RenderPipelineEditorResources asset.

    However:
    It's broken for the built in rendering paths.
     
    Last edited: Jan 27, 2020
  32. Tristan-Moore

    Tristan-Moore

    Joined:
    Aug 22, 2014
    Posts:
    18
    Definitely, I have been using this thread as a reference for the HDRP so I wanted to point this out if it was relevant to HDRP folks.
     
    bgolus likes this.
  33. SomeGuy22

    SomeGuy22

    Joined:
    Jun 3, 2011
    Posts:
    717
    I've run into this same issue, using the builtin rendering path. Totally agree that there should be a grass material parameter on the Terrain settings just like there is for the Terrain material if it's not already on the roadmap. Without it, I am unable to override the Waving Grass shader on Unity 2019.2.6f1 using the path name method. As you discussed it appears they closed off this override function but never exposed the grass and vertex lit shaders to users, which is extremely problematic because it's removing functionality that used to work.

    I tried out the script from Gufetto but I couldn't get it to work. I only made a few tweaks to where the converted Terrain is output, and the asset was created successfully. But I got the error "Assertion failed on expression: m_Shape == NULL". Not sure what that means, but it's probably one of the terrain parameters in the asset because it seems to match the other JSON properties you edit in the script. The terrain data was set correctly, but when I made changes to the Shader I set it to it didn't update, and I didn't see any differences in the grass, even after setting the color to solid red. Maybe I'm missing something but if not it might be the error which is giving me trouble.

    Then I ran into a problem because I could not for the life of me find a way to set the Terrain Component's data outside of code. So I wasn't able to revert my terrain back to the un-converted original state. I made this little script which is an Editor window to do just that:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEditor;
    5.  
    6. #if UNITY_EDITOR
    7. public class MSetTerrainData : ScriptableWizard
    8. {
    9.     [Header("Data")]
    10.     public Terrain terrainToSet;
    11.     public TerrainData terrainData;
    12.  
    13.     void OnWizardUpdate()
    14.     {
    15.        
    16.     }
    17.  
    18.     void OnWizardCreate()
    19.     {
    20.         //function to execute on submit
    21.  
    22.         if(terrainToSet != null && terrainData != null)
    23.         {
    24.             terrainToSet.terrainData = terrainData;
    25.         }
    26.     }
    27.  
    28.     [MenuItem("Window/Terrain/Set Terrain Data")]
    29.     static void MakeBillboard()
    30.     {
    31.         ScriptableWizard.DisplayWizard<MSetTerrainData>(
    32.             "Set Terrain Data", "Set");
    33.     }
    34. }
    35. #endif
    Hopefully that helps anyone that needs to set terrain data manually.

    I just seem to keep hitting roadblock after roadblock with my project and what I've learned is apparently never start your project on the latest version of Unity since it's possible to be missing dozens of crucial features which can completely halt progress. I'm sure there is some workaround, if I could figure out the error and get the script working perhaps, but I'd much rather just set the material through a parameter. I've already wasted over an hour just trying to override the shader using different methods but no luck. I'm probably going to move to 2019.3 eventually for Cloth fixes, so I really hope that the grass shader will be exposed for the builtin pipeline by that point.
     
  34. Gufetto

    Gufetto

    Joined:
    Oct 19, 2015
    Posts:
    29
    To change TerrainData in the inspector, you have to enable Debug mode (by clicking on the top right button), then select the terrain and it will be exposed there.

     
    edwiz7 likes this.
  35. SomeGuy22

    SomeGuy22

    Joined:
    Jun 3, 2011
    Posts:
    717
    Huh... I've been using Unity for 8+ years and I never knew that existed. Thanks!

    Any idea what the "m_shape == NULL" is or if that could be related to the shader not being set on the duplicate data? I didn't think my few changes could really impact the individual properties but I could be mistaken.
     
  36. Gufetto

    Gufetto

    Joined:
    Oct 19, 2015
    Posts:
    29
    I have no idea about the m_shape thing, I'm sorry. It would be so easy for unity to just expose the grass shader property and avoid so many problems, but whatever...
     
    SomeGuy22 likes this.
  37. Vad3rInHale

    Vad3rInHale

    Joined:
    Apr 19, 2015
    Posts:
    96
    I'm trying to get this to work for URP. Using 2019.3.0f6, I can create a new RenderPipelineAsset, but it seems the default RenderPipelineEditorResources asset is stuck in "Packages" and uneditable. Was there a way you've seen this asset created? And if so, how can I assign it to my RenderPipelineAsset to use those editor resources?

    Thanks
     
  38. gml106_nc

    gml106_nc

    Joined:
    Apr 7, 2020
    Posts:
    1
    I am having the same problem in 2019.2 not using LWRP
    Is there an update plan?
     
  39. LIVENDA_LABS

    LIVENDA_LABS

    Joined:
    Sep 23, 2013
    Posts:
    377
    In Unity 2019.3.6f1 I still can't override the terrain billboard shaders! It only picks it up if you create a completely new terrain, but then the custom shader only works in Unity Editor not if you build it.

    What is going on? Is there no way to override billboard shader???
     
  40. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,069
    So I created a bug report for this with a test project and they were unable to reproduce the problem. Oddly, after reopening the test project I had created I to show the problem I could not reproduce the problem anymore and the terrain properly used the shader I had included though I did not try making a building in that project. Part of the problem is in trying to find a work around I'd partially broken the override shader so I don't know if it'd magically fixed itself while I was fiddling with it. :rolleyes:

    Those having problems, can you try restarting the editor and see if the grass starts magically using the new shader.
     
    Last edited: Apr 8, 2020
  41. LIVENDA_LABS

    LIVENDA_LABS

    Joined:
    Sep 23, 2013
    Posts:
    377
    I'm trying to override the BillBoard shader as I said it's working in the editor but not when I make a build. Tried restarting the Editor still not working when I build, why is the build not picking up the shader?
     
  42. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,069
    Because it's (probably) a bug!

    It's another point of data for how to reproduce the problem, though as stated I cannot reproduce the issue anymore even though I initially did in the project, and in other projects (it magically works there now too). I may try to follow up with Unity on the topic, especially if anyone else finds any more ways to reliably reproduce the problem. My test project (which again originally did not work) is using a billboard shader override and it shows up in a build fine. Just double checked.
     
  43. LIVENDA_LABS

    LIVENDA_LABS

    Joined:
    Sep 23, 2013
    Posts:
    377
    I still can't get it to work in builds, works fine in editor. Is there something else I have to do or assign something somewhere to get this working?

    So Is overriding the build-in billboard shader is broken in Unity 2019.3.6f1 ? Bug Or Not?

    Also, to get it to work in the editor in the first place! I had to make a new terrain then export the height map and splat map (After Putting In My BillBoard Shader, which is just a copy of unity build-in billboard shader). After this step it works inside unity editor , but no matter what I tried can't get it to work in builds.

    I can't believe Unity did this without providing a clear mechanism to override the build in shaders that works??
     
  44. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,255
    How is this not a bug? Extremely frustrating...
     
  45. zackblack

    zackblack

    Joined:
    May 17, 2015
    Posts:
    72
    Where is this located?
     
  46. Vita-

    Vita-

    Unity Technologies

    Joined:
    Jul 2, 2019
    Posts:
    120
    I've investigated @bgolus submitted issue, unfortunately, I could not reproduce it myself. Terrain detail shaders were overridden successfully. If you can still reproduce the issue, please submit a bug report with the project attached and reproduction steps.
     
    Last edited: Jul 20, 2020
  47. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,255
    I can change the billboard one, but not the non-billboard one, for some reason. I'll submit a bug later, thank you.
     
  48. zackblack

    zackblack

    Joined:
    May 17, 2015
    Posts:
    72
    @vitaskruibyte I think I speak for all developers when I say what we would really love is public inspector slots on the Terrain component to simply drag and drop any shaders we want to override. This seems like such a simple and straightforward solution to a problem that shouldn't exist.
     
  49. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,069
    Especially since the terrain data appears to already have those slots in the json data itself, just hidden to Unity.
     
    sirleto, Vincent13122 and SomeGuy22 like this.
  50. gdespaux2010

    gdespaux2010

    Joined:
    Feb 16, 2017
    Posts:
    34
    Tried setting my own Terrain Grass shader as described by @Tristan-Moore but I just get green squares everywhere.

    Does this still work? Where can I get a grass shader? I'm pretty sure Unity is never adding one at this point.