Тёмный

Stylized Geometry Grass Shader for Universal Render Pipeline Unity [Pt. 2] 

AJTech
Подписаться 8 тыс.
Просмотров 9 тыс.
50% 1

A fully functional grass shader that's made for the Universal Render Pipeline, it works without Unity's terrain system and comes with a bunch of features such as lighting, shadows, tesselation! This is the system I will be using in my open world game which I am developing on this channel as well, we will be coding everything ourselves so that you can understand from the base up how everything works.
PROJECT FILES (TEXTURES & MODELS) + COMPLETED PROJECT :
☢ github.com/AJTech2002/Grass-S...
☁ In this video we begin our journey by creating the second of the three shader sections, the Geometry Shader. It will contain the creation of the planes that our grass texture will sit on, we will also be able to randomly rotate these non-existent planes through rotation matrices.
* NEWS : Welcome to the community!! I want to congratulate everyone on reaching 3,800 subscribers, this is a collective accomplishment and I thank you all for your support. *
Firstly I would like to apologise for the late upload times I know I announced this video a while ago, I really wanted to polish up the system before I shared with everyone :)
❤ 2020 calls for more social media & interaction with you guys so check me out on, also I hope everyone is safe during this time ❤ :
====================================================
✄ / codewithajay ✄ [TWITTER]
- Daily Game Development Content, tips, motivation, updates on the game & just about my very 'interesting' life.
====================================================
----- LETS TRY AND HIT : 50 LIKES ✌ ---------
★ Upcoming Videos :
- Grass Shader Part 2 ❤
- Open World Series Part 6 ❤
◕‿◕ The next part is even better and in order for you to see it you have to subscribe and tap that bell icon to be notified :
►► / subscription_. . ◄◄
☾ Stay tuned for the next episode, I will be releasing new videos once every 5 to 6 weeks discussing what I have done over the course of the weeks, always giving you some good entertainment with some knowledge on how you can tackle complex challenges in your own games! (◕‿-)
I'll see you next time ✌
✄ IMPORTANT LINKS YOU SHOULD CHECK OUT ✄ :
1. roystan.net/articles/grass-sh... (Grass Shader Blog)
2. gist.github.com/phi-lira/225c... (URP Sample Shader)
3. kenney.nl/assets/foliage-sprites (Grass and Leaf Textures)
OTHER VIDEOS
DEV LOG PART 1
☢ • Video
DEV LOG PART 2
☢ • Video
DEV LOG PART 3
☢ • Video
CUSTOM CHARACTER CONTROLLER TUTORIAL
☢ • (01) Stealth Game - Cu...
INVERSE KINEMATICS SERIES
☢ • (05) Stealth Game - In...
♬ MUSIC ♬ :
☮ Wayr - Follow the light
If any of these videos or music belong to you and you wish for them to be taken down, please email me at : ajays.workemail@gmail.com
Thank you, for watching guys :)
Intro: (0:00)
Vertex Visualisation: (0:55)
Quad Setup: (2:55)
Tangent Rotation: (9:18)
UV and Normal Setup: (16:24)
Outro: (22:30)
#unity #shaders #openworld #stylized

Наука

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

 

25 июл 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 37   
@batchprogrammer108
@batchprogrammer108 3 года назад
Thanks for tuning in again guys! Sorry if I sound a bit tired, I wanted to record this as soon as I woke up. Next part coming soon :)
@rajinhossain9522
@rajinhossain9522 3 года назад
You never went to bed :(
@batchprogrammer108
@batchprogrammer108 3 года назад
@@rajinhossain9522 Sorry, I couldn't sleep :'(
@pureay2700
@pureay2700 3 года назад
im curious as to why you use geometrry shaders instead of just placing them(i know would take time tho), just premaking them in blender and merging them as one mesh, or just placing them procedural
@batchprogrammer108
@batchprogrammer108 3 года назад
@@pureay2700 There are a few reasons, one of the main ones would be the lack of control you would have over a grass mesh, for example how would you approach LODs for one large combined grass mesh, in the geometry shader you can simply stop drawing grass vertices if it is too far away. Placing them procedurally would require individual meshes and while GPU instancing helps, objects like grass don't need to exist in the game world as they don't really add value to the gameplay; so it's best kept as a simple shader in my opinion. There are a few other reasons, I'll try explain them on my next episode concluding this series :)
@KDSBestGameDev
@KDSBestGameDev 3 года назад
Frac gives the decimal part e.g. 1.23 frac of that is 0.23. Dot calculates the dot product and you pick this as a sinus value. So you basicly do some math operations, which returns a value between 0 and 1. Feels random but isn't, which is good else each frame the grass would rotate differently.
@daylightnebula5830
@daylightnebula5830 3 года назад
Game looks amazing!
@ultraxdzn
@ultraxdzn 3 года назад
YOU ARE BACK ONCE AGAIN!!!!!!!!!!!!!!
@VictorPitchPlays
@VictorPitchPlays 3 года назад
I thank you my liege.
@DavidReinhold666
@DavidReinhold666 2 года назад
Instead of rotating for the normal you could also take the cross of the up (normalWS) and the rotatedTangent. Saves you the matrix multiplication.
@ZachAbueg
@ZachAbueg 2 года назад
how would this look like in code?
@srengleie4812
@srengleie4812 3 года назад
Thank you for this nice tutorial. Im playing around with it and it seems like performance decreases dramatically just with using a tiny bit of tesselation. Are you experiencing the same, or am I doing something wrong?
@batchprogrammer108
@batchprogrammer108 3 года назад
No it's completely normal to experience the performance drop, tesellation is a very heavy process and I would recommend simply having a higher poly mesh; not only is it actively segmenting the meshes but we are also drawing many more multiples of vertices so it is expected behaviour :)
@francoisneko
@francoisneko 3 года назад
Hi, this is looking insanely good! Just what I was looking for. Do you think this could work well on mobile? Or it is too heavy for that? Thanks
@batchprogrammer108
@batchprogrammer108 3 года назад
Thank you! I had to do a bit of research and it turns out it may be hit or miss for phones and as far as I can see iOS doesn't support geometry shaders. Sorry :(
@francoisneko
@francoisneko 3 года назад
AJTech oh that is too bad.. Thank you for responding through and for your really interesting videos!
@u.n.igaming5456
@u.n.igaming5456 3 года назад
When are u going to finished ur game bro?
@lesarch
@lesarch 3 года назад
Thanks for the tutorial! Quick question regarding shadows... I downloaded the file on github and tested out the grass. It works really great except for the grass not receiving shadows from other objects in the scene. Is there a way to fix this? Looking forward for part 3!
@batchprogrammer108
@batchprogrammer108 3 года назад
Hey! Sorry about that, the few things I can think of would be to ensure that the RecieveShadows property of the shader is set to 1 in the inspector, ensure that the main light or the directional light is actually casting shadows. This is all the shadow code: Light mainLight = GetMainLight(); if (_ReceiveShadows == 1) { #if SHADOWS_SCREEN float4 clipPos = TransformWorldToHClip(input.positionWS); float4 shadowCoord = ComputeScreenPos(clipPos); #else float4 shadowCoord = TransformWorldToShadowCoords(positionWS); #endif mainLight = GetMainLight(shadowCoord); } else { #ifdef _MAIN_LIGHT_SHADOWS mainLight = GetMainLight(input.shadowCoord); #else mainLight = GetMainLight(); #endif } Make sure everything is setup so that this works, I hope this fixes the issue if not please let me know. Good luck :)
@lesarch
@lesarch 3 года назад
@@batchprogrammer108 Thank you very much for the quick reply! There was actually nothing wrong with your code -- only something wrong with me. Turns out I had the Shadow Affectance turned up to 1 instead of .1 :( thanks for lending your time for a newbie like me! Really love your tutorial!
@batchprogrammer108
@batchprogrammer108 3 года назад
@@lesarch Glad it worked! 😁
@AmgedAlfakih
@AmgedAlfakih 3 года назад
now how to use it with unity Terrain System
@SockitWrench627
@SockitWrench627 3 года назад
Are you still working on that game
@defonotme2476
@defonotme2476 2 года назад
the created rectangles on the plane go pass the ground boundaries? they arent staying on the plane and going beyond it...
@brunch.
@brunch. 3 года назад
Hi, i downloaded the entire completed project folder and imported it as its own game to unity, but when i open the project i just have 3 flat, colored surfaces. Is there something i need to do once ive installed it? I didnt touch the folder at all besides to drag it into unity but it still seems to not work And by unity i mean a folder that has all of my other projects in it and then i selected it from the unity hub project menu
@batchprogrammer108
@batchprogrammer108 3 года назад
I'm going to be honest, I have no clue what's happening. I'll see if there are any errors in the project. What version of Unity are you using? I am utilising 2019.4, maybe there are some issues with prior or even later versions. I have updated the GitHub repository to remove the Library, Logs and obj Folders so try downloading it again and using it and maybe Unity will correct some of the issues itself. Sorry about the hassle.
@brunch.
@brunch. 3 года назад
AJTech awesome ty. Chances are i have messed something up somewhere, i am still quite new to unity. Thanks for your time
@brunch.
@brunch. 3 года назад
AJTech as for what version, i am using 2019.4.0f1 which it prompted me to download when i first tried to open the project since i didnt have it installed
@batchprogrammer108
@batchprogrammer108 3 года назад
@@brunch. happy to help, just a bit dissapointed that the project didn't work. If you get it to work, please let me know the solution so I can inform viewers in the next video :)
@brunch.
@brunch. 3 года назад
AJTech was it a problem on my end then i assume? I will look into it more tomorrow maybe i will find something I will say the only other thing that came up is i had to change the target platform from windows to mac or something like that. I will try tomorrow on my windows computer to see if that changes things as well
@pirvanlaurentiu7755
@pirvanlaurentiu7755 3 года назад
I've got the full code from your github, and it's not working (it does literally nothing, not even a pink texture)
@batchprogrammer108
@batchprogrammer108 3 года назад
That's interesting, are you using URP? And did you download the Completed Project?
@pirvanlaurentiu7755
@pirvanlaurentiu7755 3 года назад
@@batchprogrammer108 I'm using URP, i've copied the scripts needed ( CustomTessellation, the shader itself, GrassPass, textures.. etc), still now working. I've noticed that when I select the shader for my material, it has the path as: "URPPlanedDepth (FailedToCompile/Unlit/URPPlanedDepth )" maybe this is the problem? the failure to compile? but I don't get any error. Thanks for helping :)
@batchprogrammer108
@batchprogrammer108 3 года назад
@@pirvanlaurentiu7755 It could be a problem with the location of the files, the GrassPass and Tesselation scripts have to be in the same directory as the URPPlanedDepth script. Maybe try and download the Unity Project itself from the GitHub repo and see what differs.
@pirvanlaurentiu7755
@pirvanlaurentiu7755 3 года назад
@@batchprogrammer108 thanks, now it's solved, could i have something like a brush for it? or some placement on a specific place on the map? or it is stuck only for vertices?
@batchprogrammer108
@batchprogrammer108 3 года назад
@@pirvanlaurentiu7755 Yes absolutely you can have a brush, I will be going over that in the following episodes however the way to do it is to ensure that the geometry shader only works where the vertex color exceeds a certain value. So you can check if the vertex color is green and if it is then put a grass element there, then you can paint on vertex colors in unity using PolyBrush or something.
@samuelrose5934
@samuelrose5934 3 года назад
face reveal pls
Далее
Выпускаем трек? #iribaby
00:14
Просмотров 494 тыс.
How Do Games Render So Much Grass?
15:52
Просмотров 323 тыс.
Creating a Scalable Saving System in Unity
9:00
Просмотров 5 тыс.
Unity | I made an Interactive Grass Shader + Tool
8:26
7 Ways to Optimize your Unity Project with URP
11:18
Просмотров 204 тыс.
Creating procedural walk movement | Prototype Series
5:50
CREATE YOUR OWN RENDERER WITHOUT CODE in Unity!
10:32
Просмотров 274 тыс.
Making a First Person Shooter with Thomas Brush!
4:50
АЙФОН Г0ВН0
0:54
Просмотров 1,3 млн