Тёмный

Six Grass Rendering Techniques in Unity 

Daniel Ilett
Подписаться 19 тыс.
Просмотров 47 тыс.
50% 1

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

Игры

Опубликовано:

 

11 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 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!
@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 Год назад
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
@samivanni3866
@samivanni3866 3 месяца назад
This helped me a lot. Thank you for the video!
@AlexandreCoulonOldChannel
@AlexandreCoulonOldChannel Год назад
Very clear and informative, I took some notes ! thanks :)
@subhradipmajumder4204
@subhradipmajumder4204 Год назад
Thank You brother again for teaching me something new :) , Keep posting
@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!
@StefanRIZEA_
@StefanRIZEA_ Год назад
Great video. Keep it up!
@sangchad9161
@sangchad9161 Год назад
Great tutorial
@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
@Goeki_4
@Goeki_4 Год назад
OMG IM GLAD TO FOUND THIS CHANNEL
@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.
@hulponot29
@hulponot29 Год назад
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!
@Memeieli
@Memeieli Год назад
Great tutorial. is there a chance you could cover Mesh Shaders sometime? (Mesh shaders/meshlets?)
@samhblackmore
@samhblackmore 5 месяцев назад
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.
@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!
@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
@slurpiks
@slurpiks 10 месяцев назад
how did you put everything from the winrar file? like grass ground and others ?
@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
@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!
@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?
@soleia9461
@soleia9461 Год назад
Can you please do fur shader? thank you
@Berndr
@Berndr Месяц назад
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 Месяц назад
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 Месяц назад
@@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 ...
@bistek2769
@bistek2769 11 месяцев назад
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.
@aliengarden
@aliengarden Год назад
What about Graphics.DrawMeshInstanced ?
@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!
@omelette2718
@omelette2718 4 месяца назад
You should really lower the sound of music in your video. Great video though!
@mochou-p
@mochou-p Год назад
19:39 XD
@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 5 месяцев назад
Hey! Did you manage to solve the problem?
@vrictor
@vrictor 5 месяцев назад
@@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 🫠
@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 9 месяцев назад
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 4 месяца назад
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
Далее
How Do Games Render So Much Grass?
15:52
Просмотров 321 тыс.
Moebius-style 3D Rendering | Useless Game Dev
8:12
Просмотров 812 тыс.
Дарю Самокат Скейтеру !
00:42
Просмотров 2,1 млн
How Are Games Rendering Fur?
28:51
Просмотров 436 тыс.
Modern Foliage Rendering
11:02
Просмотров 136 тыс.
Adding This One Thing Made my Game Look 327% Better
6:11
The Game That Hacks Your Brain
24:43
Просмотров 567 тыс.
What I Did To Optimize My Game's Grass
8:13
Просмотров 126 тыс.