Six Grass Rendering Techniques in Unity

Поделиться
HTML-код
  • Опубликовано: 17 янв 2025

Комментарии • 66

  • @LowLevelLemmy
    @LowLevelLemmy 2 года назад +9

    The king returns. You and Ben Cloward are Shader geniuses

    • @danielilett
      @danielilett  2 года назад +2

      Ben Cloward is amazing, right? Lots of in-depth videos!

  • @FrankGennari
    @FrankGennari Год назад +7

    This is a great overview of grass rendering methods. It's important to note that you can combine multiple solutions for near vs. far grass, but you have to get the colors/lighting to match and make the transition incremental. I like to use a pixel dissolve effect when transitioning from geometry to billboards, or when switching between imposter images at different angles.
    The approach I used that works well is to generate some number of square grass patches (I use 32) and randomly select from one of these for each terrain tile/chunk. Then these are drawn across the terrain using hardware instancing. I also generated several lower LODs by recursively finding the nearest pair of grass blades and merging them into a new blade with the sum of the surface area, the average of the color, and the average of the height. Each LOD is half the size, and they're all stored in the same buffer. Then for 4 different LODs you have up to 32*4 draw calls for each mesh of each LOD.
    In addition, I use hardware tessellation shaders to curve the grass blades when close to the player and apply a wind effect that scales with distance from the base to the tip so that the ends move more in the wind. This system can support a field of grass that stretches to the horizon at about 300 FPS on a GTX 1070.

    • @danielilett
      @danielilett  Год назад +1

      Your approach sounds super interesting! And of course, mixing approaches at different distances is crucial if you want great-looking grass with high performance. As it turns out I also have a GTX 1070 so 300FPS sounds pretty good to me!

  • @CodexHere
    @CodexHere Год назад +5

    EXCELLENT video! This is quality right here!
    It would have been cool to see the mixing of mesh, imposters, and billboard at different LODs implemented just to fully observe the effects - but what you DID show was also very helpful!
    Thanks for this, gonna look at your other videos now!

  • @samivanni3866
    @samivanni3866 10 месяцев назад +1

    This helped me a lot. Thank you for the video!

  • @ayayrawnnn9725
    @ayayrawnnn9725 Год назад +5

    Such an amazing tutorial. The procedural geometry way I can only get to render in one eye though for VR, trying to search how to fix this, seems ill need to add lines to the shader

  • @iDabbl
    @iDabbl Год назад +1

    thank you for your amazing grass assets, it was just what I was looking for. It's also really fun to play around with the settings

  • @shane3158
    @shane3158 Год назад +1

    Thanks Daniel, this is exactly what I needed, love the detail you go into, thank you for creating this content!

  • @Goeki_4
    @Goeki_4 Год назад

    OMG IM GLAD TO FOUND THIS CHANNEL

  • @Chris-jo1zr
    @Chris-jo1zr 2 года назад +2

    You are a God send. I have your book and was about to look at the computer shader grass section for a mobile VR project, but now here's a lovely video on multiple ways!

    • @danielilett
      @danielilett  2 года назад +1

      Glad I accidentally got the timing right for you :D I actually get a surprising number of comments asking about VR stuff, although I don't have a headset myself. Maybe it's worth me grabbing one, so I can at least see how well my shaders work in VR!

    • @Chris-jo1zr
      @Chris-jo1zr 2 года назад

      @@danielilett I think there's a lot of VR development in the UK and US running with Quest 2 and Pico Neo 3/4 but there's also not a lot of top tier people working on it, they understandably gravitate to the bigger games companies. So there's still a lot of professional work to be had in VR.
      What would you consider the best method for grass on a Quest 2 device?

    • @danielilett
      @danielilett  2 года назад

      Out of these six, I would assume the procedural rendering approach would work fairly well on a Quest 2, but I really don't know that for sure.

    • @Chris-jo1zr
      @Chris-jo1zr 2 года назад

      @@danielilett Thanks Dan, I've come to that Conclusion myself also, I was attempting to implement the Compute Shader method (just to be all fancy) but realised it's likely really pointless for the project at hand.
      I did notice that the RenderParams Class used in the C# script appears to only be available in the 2021 Unity version, so my 2020 VR testing project was doomed to fail regardless.

  • @samhblackmore
    @samhblackmore Год назад +1

    TIL you can enter functions into the transform position inspector!

  • @subhradipmajumder4204
    @subhradipmajumder4204 2 года назад +1

    Thank You brother again for teaching me something new :) , Keep posting

  • @AlexandreCoulonOldChannel
    @AlexandreCoulonOldChannel Год назад +1

    Very clear and informative, I took some notes ! thanks :)

  • @sangchad9161
    @sangchad9161 2 года назад +2

    Great tutorial

  • @UnityDevJOY
    @UnityDevJOY Год назад +1

    Great video. Keep it up!

  • @SincerestSawa
    @SincerestSawa Год назад +1

    this was a great video, instructional enough for me to be able to choose what style would work for a world im making, spent days making multiple different meshes but painting the terrain with a grass texture worked great

    • @danielilett
      @danielilett  Год назад +2

      Glad it helped - best of luck with your game!

  • @Memeieli
    @Memeieli Год назад +1

    Great tutorial. is there a chance you could cover Mesh Shaders sometime? (Mesh shaders/meshlets?)

  • @TheMrPawolo
    @TheMrPawolo 2 года назад +2

    WOW! Where I can read more about "math functions" that you typed in the transform component in 3:50? I never heard about it! :O

    • @danielilett
      @danielilett  2 года назад +2

      Yeah I learned about them pretty recently too! Here's the documentation page that goes over them: docs.unity3d.com/Manual/EditingValueProperties.html

  • @atomictraveller
    @atomictraveller 8 месяцев назад

    i love grass, man. i work in win32 so not the same, i was figuring on using shells next time i want grass, and an abstraction (several layers of squares like uninterpolated wind positions). i don't know if i missed it, a good tip i herd was to mix the terrain normal for specular at a distance to reduce aliasing. anyway, here's hoping some folks out there get the good word about the abstract.

  • @hulponot29
    @hulponot29 2 года назад +2

    Cool video, I have known something new!
    What about others Terrain grass methods? (Instanced mesh,Grass mesh). I think they are somehow related to batching approach?
    Thanks for your work!

  • @Massive-3D
    @Massive-3D Год назад +2

    Hey awesome video. The audio is quiet though, sound far away

    • @danielilett
      @danielilett  Год назад +1

      The acoustics in my room are pretty terrible which makes it difficult to get the audio balance right. I think I've worked out a solution for future videos, but it's a shame that I can't go back and fix the audio for past videos!

  • @mikwns3722
    @mikwns3722 5 месяцев назад

    do you use terrain or plane

  • @Berndr
    @Berndr 7 месяцев назад

    this was so informative thanks, just curious what grass do they use in top-down games, I noticed that recent top-down city builder games such as Manor Lords or Farthest Frontier are literally littered in the grass , how is that not slowing the performance? in the past top-down games never had any actual grass just texture ...

    • @danielilett
      @danielilett  7 месяцев назад +1

      I don't know for sure which techniques they used, but I would strongly assume it involves a lot of GPU instancing. After all, I'm just some guy on the internet and I could easily get a couple million grass blades all on screen at once, so a dev team with a lot more resources (and a few optimisations to thin out the grass when further away) should be able to litter the ground with grass without destroying performance.

    • @Berndr
      @Berndr 7 месяцев назад

      @@danielilett Thank yuo for the reply, I was only wondering because in top-down games you see a very large area of the terrain and yet they had foliage all over it whilst in first-person view it is easy to cool down the grass far away ... apparently, Manor lord is made by one guy ...

  • @soleia9461
    @soleia9461 2 года назад +1

    Can you please do fur shader? thank you

  • @iDabbl
    @iDabbl Год назад

    when changing the max tesselation distance, it works for the most part but still leaves singular grass blades outside of this max distance. How can i fix it so that no grass whatsoever appears outside of this max tesselation distance?

  • @Gandalf642
    @Gandalf642 Год назад

    Many thanks for this video. I tried to use the procedural instancing (with compute shader). That works perfectly on pc but the grass is not displayed in a PS5 build, an idea ?

  • @slurpiks
    @slurpiks Год назад

    how did you put everything from the winrar file? like grass ground and others
    ?

  • @mallugamedev4951
    @mallugamedev4951 2 года назад +1

    which one is the best for a mobile game with dense grass ( which aproch is the most optimized ) ?

    • @danielilett
      @danielilett  2 года назад

      I wouldn't recommend geometry shaders for this, because they are not well-supported on mobile.
      If you don't mind the visuals being slightly rougher, terrains with grass are most likely the most efficient. If you want something that looks a bit better, the procedural rendering approach is still very optimised. That's probably my favourite technique.

  • @day_that_i_die9854
    @day_that_i_die9854 Год назад

    Amazing content! Unfortunately procedural+compute grass crashes Unity 2021 and 2022 without console errors

  • @plainshades
    @plainshades Год назад

    Can I get your book even if I wish to specifically learn the Shader Graph only? I've always found shader code intimidating.

    • @danielilett
      @danielilett  Год назад

      Most of the effects in the book include Shader Graph versions. There are a few things that Shader Graph still can't do, but I made sure to cover it where possible!

  • @bistek2769
    @bistek2769 Год назад

    I tried to run the procedural rendering with compute shaders one but I can't make it work. Console is throwing "out of range" error constantly. Maybe someone knows what's happening?

  • @aliengarden
    @aliengarden Год назад

    What about Graphics.DrawMeshInstanced ?

  • @frankyonng1710
    @frankyonng1710 Год назад

    Dose Billboard increase the overdraw?

    • @danielilett
      @danielilett  Год назад

      If you're using an opaque material (even if it uses alpha clipping), then it shouldn't do. If you're using a transparent material, then it will - so it's definitely something to be careful of!

  • @GiMiat
    @GiMiat Год назад

    How about DrawMeshInstanced vs the DrawProcedural, they seem similar, is there any performance difference?

    • @danielilett
      @danielilett  Год назад

      While making this video I did see tons of similar looking methods like those which seemed to do very similar things and just differ by what paramaters they accept. Not sure about the performance difference, but I'm assuming it's small.

  • @vrictor
    @vrictor Год назад +1

    HELP pls, when using the geometry grass method and upgrading it to unity 2022.2.18 for some reason the grass displaces to a diferent location than the objects one. for example if the object with the material is at X=0 and Y=0 the grass is at X=0 Y=0 but if I move the object to X=2 Y=0 the grass moves to X=4 Y=0 and so on and on. this makes the grass unusable because when the objects get a little bit away from the center of the scene (lets say 12 meters) the grass moves super away (24 meters) because for some reason it multiplies the distance by two in all axis. if someone can tell my why it does this ill be veryu thankfull :D
    ps: sorry for writing a full byble paragraph xd

    • @alpergiray1783
      @alpergiray1783 Год назад

      Hey! Did you manage to solve the problem?

    • @vrictor
      @vrictor Год назад

      @@alpergiray1783 i dont use Unity anymore bc of the polemic that happened and also nevera found the soultion. Apparently its a bug that the versión hada or smthn because no one was able to solve It 🫠

  • @mochou_p
    @mochou_p Год назад +1

    19:39 XD

  • @armyofchickens6062
    @armyofchickens6062 Год назад

    how can you render grass in a 2D game using a single blade of grass and populating the world with it?

  • @majortom2405
    @majortom2405 Год назад

    It apears the Link to your Book doesn't work anymore

  • @omelette2718
    @omelette2718 10 месяцев назад

    You should really lower the sound of music in your video. Great video though!

  • @derrelecte
    @derrelecte 10 месяцев назад +5

    The music is very annoying and hard to understand you over it.

  • @matrixdev
    @matrixdev Год назад

    nice video but music is way to loud...

  • @rasmuspedersen4891
    @rasmuspedersen4891 2 года назад +2

    when you misinterpret "Go touch grass":

  • @stevphiericardo2790
    @stevphiericardo2790 2 года назад +4

    You forgot the most important grass method, called Grass blending.. It's very common in UE and easy to do that there, whil;e in Unity, good god it's so little resources regarding this matter in Unity due to these reasons "
    1. Normal blendings are expensive
    2. It's very hard to implement in Unity

    • @danielilett
      @danielilett  2 года назад +3

      I'm interested in this, where do you suggest to find out more details about it in UE? Would be interesting to have a go at implementing it in Unity!

    • @stevphiericardo2790
      @stevphiericardo2790 2 года назад

      @@danielilett Almost every UE stylized tutorials out there you can find, usually they don't even mention it due to how it's a built-in feature there and it can be done on the shader level pretty easily. Most likely can find this in a stylized ue videos.
      in Unity, either baking the maskmap or using secondary ortho camera, yeah, it sucks.
      And for the love of god! PLEASE MAKE A TUTORIAL FOR THIS for Unity!...

  • @carriesummers4244
    @carriesummers4244 2 года назад

    lets
    GOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO

  • @matiastemesio893
    @matiastemesio893 2 года назад +2

    unreal engine is a way better than unity in all this grass and foliage thing as far i can see

  • @Arelias95
    @Arelias95 Год назад

    Using geometry shaders is a pretty poor idea

  • @smokinjoeee
    @smokinjoeee Месяц назад

    You gotta turn this music down man

    • @smokinjoeee
      @smokinjoeee Месяц назад

      can barely hear your voice in the intro