Wrong grass shader when creating TerrainData at runtime in a build

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?

8512868–1134725–DynamicGrass.unitypackage (235 KB)

This does seem like a bug – will do some investigation and follow up this week.

1 Like

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.

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?

I have already submitted a bug report (IN-19821).

1 Like