Search Unity

Question Shader generated grass or model it myself

Discussion in 'Shaders' started by rambii, Aug 15, 2022.

  1. rambii

    rambii

    Joined:
    Jan 7, 2017
    Posts:
    40
    I’m not sure if anyone can answer but, are there any performance differences between generating grass using compute shaders and modeling grass in Blender or any modeling software to paint all over the terrain?
     
  2. burningmime

    burningmime

    Joined:
    Jan 25, 2014
    Posts:
    845
    Most grass do not use mesh model. Grass is tricky and depends a lot on how you want your game to look, how tall grass will be, how close camera will be to it, if it moves, if it gets wet, etc, etc. Many different approaches.

    Most common is to use crossing quads and draw them alpha tested (ideally with AtoC if using MSAA). This can look pretty good especially in first person or close up third person camera. This is used by Unity default terrain mesh. However there are some problems with the technique with lot of grass:
    https://forum.unity.com/threads/the-great-grass-dilemma.797874/

    This asset fixes the generation of grass (so close to compute shader but I think it does it all on CPU):
    https://assetstore.unity.com/packages/tools/terrain/advanced-terrain-grass-100014

    This can look bad if using orthographic camera zoomed out (eg diablo or bauldur's gate). Easiest way is just to use a texture maybe with parallax map, which is fine if grass is short. Other technique uses precomputed raycast, looks really good but a lot of work to implement:
    https://gamedev-ru.translate.goog/c...l=auto&_x_tr_tl=fy&_x_tr_hl=en&_x_tr_pto=wapp

    Another way is to use shells like for fur. This can be good in specific circumstance:
    https://assetstore.unity.com/packages/vfx/shaders/brute-force-grass-shader-192388

    Model in blender would be slow unless grass is big:
    proxy-image.jpg
     
    Last edited: Aug 16, 2022
  3. rambii

    rambii

    Joined:
    Jan 7, 2017
    Posts:
    40
    Currently, I am generating my grass using compute shaders. However, my knowledge of shaders is still kinda limited so I run into some things I don't like about it, especially with how it behaves with the day and night cycle in my game. I learned recently that MiHoyo used grass models they created to be used in Genshin Impact