Search Unity

Detailed Grass Meshes have stopped working

Discussion in 'World Building' started by FFWorldsCollide, Jul 6, 2021.

  1. FFWorldsCollide

    FFWorldsCollide

    Joined:
    Jul 11, 2020
    Posts:
    1
    So after a while of using flat detail textures for grass on my terrain, I decided to switch over to detailed meshes instead for visual improvement purposes. As you can see it works perfectly fine in this image from the same day that it decided to stop working.

    After having to restart my PC for other reasons and booting back up my project to get back to work, I realized all the grass I had placed had disappeared and wasn't anywhere to be seen. I found out that all my grass is there, but it's not rendering at all, either in scene view or game view. After some tweaking, I found out that I can make the grass appear (albeit weirdly) by switching the render mode from grass to vertex lit.

    ezgif.com-gif-maker.gif
    There's also an error I'm getting when I'm painting my grass but after attempting to follow everything the error asks me to do, there are still no results of my grass reappearing.
    Unity_rQMUR4jrKR.png
    I've tried making new terrain and seeing if it works on that, but no luck. I've attempted to go see if it was just a problem with the mesh and the material not appearing properly, but the prefab works perfectly fine placed down in the world. Messing with every possible terrain setting just doesn't work and results in nothing. Is there any way I can get my grass to work or am I better off finding a third-party solution that can help me out here?
     
  2. warthos3399

    warthos3399

    Joined:
    May 11, 2019
    Posts:
    1,758
    "lower the terrain detail" is your hint... Currently used mesh has too many vertices...
     
  3. paulan_unity

    paulan_unity

    Unity Technologies

    Joined:
    May 17, 2018
    Posts:
    3
    The detail renderer generates a texture atlas by grabbing all textures used by the details on the terrain. This is more straightforward when you were just using detail textures, since it directly points to the texture. I suspect that originally, terrain was able to use the original texture atlas even after you had converted to detail meshes.

    Now that you've reopened your project, it probably tried to recreate that texture atlas. With detail meshes, terrain attempts to find the right texture on the material by checking for a texture property named _MainTex. Can you make sure your prefab material has a texture named _MainTex?
     
  4. SteveTheodore

    SteveTheodore

    Unity Technologies

    Joined:
    Oct 7, 2020
    Posts:
    12
    Another variable to investigate is the relationship between the Detail Resolution and Detail Resolution Per Patch settings in the Terrain inspector. A smaller Detail Resolution Per Patch provides more fine-grained culling and generally gives you a more efficient use of your limited budget of instances, at the expense of more CPU time spent deciding which instances to show. You may find that lowering Detail Resolution Per Patch helps you keep the screen better filled. If this is the driver of your cause, you may also find that your "disappearing" grass is visible in part of your map -- it's using up all the available instances over there and so has nothing left to show near your camera.

    Here's a test map with Detail Resolution Per Patch at 128

    upload_2021-7-8_12-52-3.png

    Same map, but Detail Resolution Per Patch at 16. Here the culling is much finer, so instead of dropping the whole two big block of intances at top left we get something that's more or less correctly centered on the camera (you can see the groupings along the arc if you look carefully)

    upload_2021-7-8_12-52-52.png

    Unfortunately there is a a tradeoff here: a lower Detail Resolution Per Patch is less performant (although on my pretty beefy machine the difference between the two above images was around 0.1 ms per frame)
     
    Last edited: Jul 9, 2021