Mastering Tessellation Shaders in Unity! Easy LoD, Curved Triangles, Height Maps | Game Dev Tutorial

preview_player
Показать описание
✔️ Tutorial tested in Unity URP 2020.3, 2021.3

Hi! Tessellation shaders are advanced shaders which can subdivide triangles in a mesh, creating new vertices. You can move these around for a variety of cool effects! This tutorial aims to give you a deep understanding of tessellation shaders in Unity by first explaining how to write your own and then showcasing several algorithms which use them. Some effects include advance culling, dynamic level of detail, curved triangles, smoothed silhouettes, height map rendering, and procedural meshes.

📚 If you prefer reading, check out the written version of this tutorial here:

👋 Subscribe for weekly game development videos!

👑 Join my Patreon to watch videos early, download all project files, vote on future topics, and more! Thank you so much!

🔗 Visit my website for a searchable list of tutorials!

💻 Script reference:

⏲️ Timestamps:
0:00 Intro
0:46 Tutorial scope
2:10 What is tessellation?
3:32 Anatomy of a tessellation shader
7:15 The hull function
9:03 The patch constant function
10:11 The domain function
11:05 Tessellation factors
12:57 Partitioning modes
13:59 Optimizing with culling
14:29 Frustum culling
15:37 Winding/backface culling
17:01 Culling tolerance
17:31 Dynamic tessellation factors
19:09 Screen space factors
19:56 Camera depth factors
20:45 Mesh data factors
21:39 Deformed patches factors
22:20 Curved triangles and smoothed silhouettes
23:10 Phong tessellation
24:52 Refining models for curved triangles
25:46 PN triangles
28:47 Quadratic normal interpolation
31:18 Height map displacement
32:45 Normals from height maps
34:24 Procedural height maps
36:08 Wrap up and credits

🎖️ Credits, references and further reading:

#GameDev #IndieDev #Unity
Рекомендации по теме
Комментарии
Автор


The script for this video was difficult to write since there was just so much to cover! It was fun experimenting with tessellation, so I hope you enjoy it too. What do you plan to do with it?

NedMakesGames
Автор

This is pure gold, Ned - the subject, the effort and the tutorial itself, you've come such a long way! Congratulations on understanding enough of tessellation shaders to make such a pro tutorial, and thank you so much for the time and work you've put into this to share it with the rest of us! Personally I only understand what it can do at this point, and will need to figure out how to use hybrid renderer with hlsl first, but I really hope to be open all these doors one day.

vildauget
Автор

This seems like the definitive guide to tesselation! Thank you so much! :3 - Regards a Unity Employee :P

DanielKierkegaardAndersen
Автор

this is the best age for making video games when someone like you researches & shares their findings online with so much care. making every technique feasable for indie devs. 1000 stars for you ned, i hope you can keep doing this forever.

GreenCream
Автор

"No shader graph in this tutorial" earned you a sub here and on patreon instantly

ParkingLotStudioGames
Автор

I'm not even gonna use this and I'm still gonna give this video a like. Lol. The quality of your tutorials went form 100 to 1000 real quick. Awesome demonstration.

TheUncutAngel
Автор

Amazing video. It was nice to watch your streams.

OdemGeek
Автор

Wow, totally subbed and queued some of your other videos, namely the compute shader ones.
Just half-ways in but it just finally dawned onto me that the hull/domain shaders are a fine way to be able to do operations on an vertex while having information about the others thanks to the ‘patch’ concept that groups 3 vertices! The last couple of years I have been avoiding tessellation shaders for now reason and working around that basic vertex shader constraint.

alejmc
Автор

im working on Unity Water Systems tessellation shaders. And NMG post a video at the right time! Thanks!

kolsuzgame
Автор

this is free! amazing, you are a blessing

hristoborisov
Автор

Thank you a thousand times for creating this video and the article that goes through everything more in-depth! It has helped a ton with understanding what to do for phong tessellation, as aside from your article and video, and the paper that introduced the technique, there's no info anywhere about how to implement it!
Though even with that help, I am in need of some serious help. Even if I use effectively the exact same code as you for the phong tessellation or PN Triangles (I'm working solely with direct3d, no help with stuff from the unity engine), I don't get any rounding of objects at all.
I'm trying to turn an icosphere (from blender) into a sphere using phong tessellation or PN Triangles, but at best I can get it to look like a popcorn, or an inverted popcorn, otherwise it just looks like a completely unmodified icosphere.
For the phong tessellation, I don't get any change at all, no matter what I set the shape factor to, and for the PN Triangles, the way I can change the way the object looks is by varying the multiplier for bezierpoints[6], because with a multiplier of 6 I only get the pure icosphere.

Edit: I ended up finding the issue, the model didn't have normals that allowed for curving, as they were orthogonal to the triangle faces.

ArtificialDjDAGX
Автор

Hey there is no Metallic/Smoothness/AO map in the shader. It was in the video when you show it in terrain.

shubhrojyotikabiraj
Автор

Great tutorial again!
From what I understand, tesselation hardware is not supported on Metal. We are now supposed to use compute shaders for that now. It would be great to have a tutorial that explains how to do that. I am especially interested in how it would be possible to split edges of arbitrary length so that they are roughly the same length. This would be really useful together with the grass shader. So that the grass density is more even and can be adjusted by the user interactively. I have been trying to wrap my head around doing this in compute shaders, but those are still a bit over my head.

elmareschlauer
Автор

Your stuff is unbelievably great!! Thank you so much. I'm thinking now, how could one tesselate and delete faces (I'm thinking a space ship having bullet/laser holes dynamically put into it) hmmmm also: subbed!! I can't wait to see what's next

chris.davidoff
Автор

Hey there! I don't know if you're still active on replies for this video, but I would still like to reach out and ask a question: Do you know of any plausible ways to retrieve the vector points generated on the GPU (with the tessellation) and give them to the CPU? I keep hearing about compute shaders, and how I could take the arrays of vertices and triangles and give those over, but I have no idea how to do so. The goal is to get the updated mesh and then apply it to a mesh-collider (since I didn't want to use raycasting for the movement in the demo i'm working on). Any help would be appreciated! Or links to where I can find the info.

therandom
Автор

Thank you for making this free. I had a quick look at the source code you provided, and as someone that knows nothing of shader scripting, it will take me a while to understand what's going on there. Anyway, i wanted to know how hard it would be to port this to Unity's shader graph? Are you aware of any nodes in the official Unity Shader nodes library that i could cobble together to achieve what you have done here? It's a lot to ask i know, so even just a point in the right direction would be of great help.

arthurgentz
Автор

Holy shit man Thank you so much for this you absolute Genius!

john-petercomitis
Автор

Works great but there is one issue Ambient occlusion from other objects is being seen through the object with TessellationSample material even when i enable After opaque (which usually fixes it) in the quality settings for ambient occlusion

styliejoker
Автор

Drink every time he says 'tessellesation'.
Also leave the man a like for this wonderful tutorial.

mrcresent
Автор

Hey, I learned a lot here, I would be very interested about how to use this technique with the grass compute shader of another video, so you would be able to select the grass density ( based on triangles sizes ), before we bake the mesh ... Tried to do that for long with other tutorials, but I can't figure out how to tessellate the mesh before computing the grass :(

Yukiixs