Six Grass Rendering Techniques in Unity

  Рет қаралды 45,805

Daniel Ilett

Daniel Ilett

Күн бұрын

Ever wanted to add grass to your game? There are many ways of implementing grass in Unity, and while one technique could be great at one thing, it might suck at another. In this video, I'll go over six grass rendering methods and explore what makes each one great in certain situations.
Made with Unity 2021.3.0f1 and URP 12.1.6.
------------
👇 Download the project on GitHub: github.com/daniel-ilett/shade...
📰 Read this tutorial in article format instead: danielilett.com/2022-12-05-tu...
------------
📚 Get a copy of my shader book here: www.dpbolvw.net/click-10074214...
✨ Grab Snapshot Shaders Pro here: assetstore.unity.com/packages...
------------
🎨 Grass Variations by RBG Illustrations: sketchfab.com/3d-models/grass...
🎨 Ground 048 on ambientCG: ambientcg.com/view?id=Ground048
🎨 Tree by randum: sketchfab.com/3d-models/tree-...
------------
💬 Join the Discord: / discord
💖 Support me on Patreon: www.patreon.com/danielilett?f...
☕ Or throw me a one-off coffee on Ko-fi: ko-fi.com/danielilett
------------
00:00 Introduction
01:22 Method 1: Mesh Grass
04:33 Method 2: Geometry & Tessellation Grass
07:32 Method 3: Procedural Rendering & Compute Shaders
15:30 Method 4: Billboarding
17:54 Method 5: Terrains
19:39 Method 6: Impostors
#gamedev #shaders #madewithunity

Пікірлер: 63
@LowLevelLemmy
@LowLevelLemmy Жыл бұрын
The king returns. You and Ben Cloward are Shader geniuses
@danielilett
@danielilett Жыл бұрын
Ben Cloward is amazing, right? Lots of in-depth videos!
@FrankGennari
@FrankGennari Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
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!
@shane3158
@shane3158 11 ай бұрын
Thanks Daniel, this is exactly what I needed, love the detail you go into, thank you for creating this content!
@colecancode
@colecancode Жыл бұрын
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
@ayayrawnnn9725
@ayayrawnnn9725 Жыл бұрын
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
@samivanni3866
@samivanni3866 2 ай бұрын
This helped me a lot. Thank you for the video!
@Chris-jo1zr
@Chris-jo1zr Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
@@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 Жыл бұрын
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 Жыл бұрын
@@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.
@AlexandreCoulonOldChannel
@AlexandreCoulonOldChannel Жыл бұрын
Very clear and informative, I took some notes ! thanks :)
@subhradipmajumder4204
@subhradipmajumder4204 Жыл бұрын
Thank You brother again for teaching me something new :) , Keep posting
@sangchad9161
@sangchad9161 Жыл бұрын
Great tutorial
@StefanRIZEA_
@StefanRIZEA_ Жыл бұрын
Great video. Keep it up!
@Goeki_4
@Goeki_4 Жыл бұрын
OMG IM GLAD TO FOUND THIS CHANNEL
@samhblackmore
@samhblackmore 4 ай бұрын
TIL you can enter functions into the transform position inspector!
@atomictraveller
@atomictraveller Ай бұрын
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.
@hulponot29rus
@hulponot29rus Жыл бұрын
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!
@SincerestSawa
@SincerestSawa Жыл бұрын
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 Жыл бұрын
Glad it helped - best of luck with your game!
@Memeieli
@Memeieli Жыл бұрын
Great tutorial. is there a chance you could cover Mesh Shaders sometime? (Mesh shaders/meshlets?)
@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 ?
@day_that_i_die9854
@day_that_i_die9854 Жыл бұрын
Amazing content! Unfortunately procedural+compute grass crashes Unity 2021 and 2022 without console errors
@TheMrPawolo
@TheMrPawolo Жыл бұрын
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 Жыл бұрын
Yeah I learned about them pretty recently too! Here's the documentation page that goes over them: docs.unity3d.com/Manual/EditingValueProperties.html
@slurpiks
@slurpiks 10 ай бұрын
how did you put everything from the winrar file? like grass ground and others ?
@colecancode
@colecancode Жыл бұрын
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?
@Massive-3D
@Massive-3D Жыл бұрын
Hey awesome video. The audio is quiet though, sound far away
@danielilett
@danielilett Жыл бұрын
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!
@bistek2769
@bistek2769 10 ай бұрын
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?
@mallugamedev4951
@mallugamedev4951 Жыл бұрын
which one is the best for a mobile game with dense grass ( which aproch is the most optimized ) ?
@danielilett
@danielilett Жыл бұрын
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.
@soleia9461
@soleia9461 Жыл бұрын
Can you please do fur shader? thank you
@Berndr
@Berndr 19 күн бұрын
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 18 күн бұрын
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 18 күн бұрын
@@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 ...
@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.
@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!
@aliengarden
@aliengarden Жыл бұрын
What about Graphics.DrawMeshInstanced ?
@vrictor
@vrictor Жыл бұрын
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 4 ай бұрын
Hey! Did you manage to solve the problem?
@vrictor
@vrictor 4 ай бұрын
@@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 🫠
@omelette2718
@omelette2718 3 ай бұрын
You should really lower the sound of music in your video. Great video though!
@mochou-p
@mochou-p Жыл бұрын
19:39 XD
@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!
@armyofchickens6062
@armyofchickens6062 8 ай бұрын
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
@matrixdev
@matrixdev Жыл бұрын
nice video but music is way to loud...
@stevphiericardo2790
@stevphiericardo2790 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
@@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!...
@rasmuspedersen4891
@rasmuspedersen4891 Жыл бұрын
when you misinterpret "Go touch grass":
@carriesummers4244
@carriesummers4244 Жыл бұрын
lets GOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
@derrelecte
@derrelecte 3 ай бұрын
The music is very annoying and hard to understand you over it.
@Arelias95
@Arelias95 Жыл бұрын
Using geometry shaders is a pretty poor idea
@matiastemesio893
@matiastemesio893 Жыл бұрын
unreal engine is a way better than unity in all this grass and foliage thing as far i can see
Energy Shield Hologram in Unity Shader Graph
15:32
Daniel Ilett
Рет қаралды 8 М.
How Do Games Render So Much Grass?
15:52
Acerola
Рет қаралды 316 М.
Как быстро замутить ЭлектроСамокат
00:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 13 МЛН
Adding This One Thing Made my Game Look 327% Better
6:11
OverPhil Dev
Рет қаралды 83 М.
How Big Budget AAA Games Render Clouds
10:45
SimonDev
Рет қаралды 257 М.
Halftone Effect in Unity Shader Graph and URP
11:14
Daniel Ilett
Рет қаралды 16 М.
An introduction to Shader Art Coding
22:40
kishimisu
Рет қаралды 914 М.
How do Major Video Games Render Grass?
9:33
SimonDev
Рет қаралды 375 М.
How Ray Tracing (Modern CGI) Works And How To Do It 600x Faster
32:06
Josh's Channel
Рет қаралды 558 М.
Can I Create Video Games Using SQL? (No Game Engine)
20:58
icitry
Рет қаралды 116 М.
What I Did To Optimize My Game's Grass
8:13
Acerola
Рет қаралды 123 М.
😱ЭТОГО ТЫ ТОЧНО НЕ ЗНАЛ О KinitoPET 2
11:26
DELETE TOXICITY = 5 LEGENDARY STARR DROPS!
2:20
Brawl Stars
Рет қаралды 14 МЛН
ЛУЧШАЯ ИГРА ПРО АНОМАЛИИ ► Platform 8
38:57
Kuplinov ► Play
Рет қаралды 1,4 МЛН