Search Unity

Bug Wrong grass shader when creating TerrainData at runtime in a build

Discussion in 'World Building' started by Alex-Vertax, Oct 14, 2022.

  1. Alex-Vertax

    Alex-Vertax

    Joined:
    Sep 16, 2013
    Posts:
    205
    Hi.

    When creating TerrainData and grass at runtime in the editor (Built-in Render Pipeline, Unity 2022.1.15f1), Hidden/TerrainEngine/Details/WavingDoublePass shader is used and the grass is displayed correctly.



    In the build on PC and Android (I haven't tested other platforms, but most likely it will be the same), Legacy Shaders/Diffuse shader is used, and the grass is displayed incorrectly.


    If TerrainData is not dynamic, the grass is displayed correctly.
    But for the technology I'm working on, TerrainData should be dynamic and shouldn't be included in the build.

    I tried adding WavingDoublePass shader to Always Included Shaders but it didn't help.
    Although it is present and I can get it using Shader.Find.

    For more context, I've attached an example of the behavior.

    Is this some kind of bug in Unity, or am I doing something wrong?
    Is there a way to force Terrain Engine to use the correct grass shader?
     

    Attached Files:

    Last edited: Oct 14, 2022
  2. mattb-unity

    mattb-unity

    Unity Technologies

    Joined:
    Feb 7, 2020
    Posts:
    55
    This does seem like a bug -- will do some investigation and follow up this week.
     
    Alex-Vertax likes this.
  3. mattb-unity

    mattb-unity

    Unity Technologies

    Joined:
    Feb 7, 2020
    Posts:
    55
    I've spent some time looking at this today but have not figured out a solution yet. I can see from memory capture of a build that the shader _is_ there, but the waving grass material is not. So now looking for the code path that creates the material to understand why it would not be created.
     
  4. mattb-unity

    mattb-unity

    Unity Technologies

    Joined:
    Feb 7, 2020
    Posts:
    55
    Ok this is definitely a regression -- I tested in 2019.4.35f1 and your code is working as expected.

    Would you mind filing a bug report?

    upload_2022-10-21_17-17-28.png
     
  5. Alex-Vertax

    Alex-Vertax

    Joined:
    Sep 16, 2013
    Posts:
    205
    I have already submitted a bug report (IN-19821).
     
    mattb-unity likes this.