Poiyomi Toon Shader Tutorial *Stencils*

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
stencils are actually really easy to understand they're just never explained in a way that is easy to understand so basically the way they work is the first object renders and then it says hey I am the white circle and then the red circle says okay I'm not gonna render anywhere where that white circle is so if the red circle passes over the white circle you'll see that the white circle is in front of it the red circle is not rendered where the white circle is so it's wherever is not equal to the white circle the red circle can exist and it's the exact opposite on this side wherever the white circle is is where the red circle can exist so wherever is equal to the white circle the red circle renders and that's all stencils are so I'll give you an immunity example of that now all right now that we're back in unity you can see the exact same thing as possible here's the red circle again there's the white one and the red one can only render where the white one is not it works exactly the same we can go into a 3d view so you can see that these are just two spheres and as you can see the red one okay the backgrounds kind of messing with it but the red one only renders where the white one is not and you can change that really easily so if I go into the red thing and I say instead of rendering where it's not equal let's render where it is equal and now you can see that the red circle is only rendering where the white circle is and it's really just that easy so let's go over this a little more in depth we grab this red circle turn all of it's just reset it actually reset that one reset this one and let's cover the settings so for this case we want this left circle you'll make this one red again we want this left circle to tell the red circle where it is and then have the red circle react to that so going to the white circle going to the stencil settings we want the stencil reference value well the stencil reference value is basically the value that tells the red circle where the white circle is so it can be anything you want let's go with 167 and then we'll say for the stencil compare function this basically this function says if it should run or not and we say yeah always run and then the stencil pass operation is what it does when it runs so we want to replace whatever value is in this pixel with 167 and then when the red one renders we want it to look for that 167 so we're going to type back here and we're gonna say to only render if it is not equal to that 167 and you can see it does it so the white one is writing 167 it's always replacing its pixels with 167 so the whole screen is basically just a big like list of pixels and then you can fill in your stencil value add up at any pixel where you render so this is filling the pixels in this within the sphere to 167 and then this one comes by and checks those pixels but you may have an issue where it looks like this where you have all your settings correct okay it's gonna work in this case obviously but it may not always work because what's happening here is that the render queue for both the red and the white one are the same meaning they're rendering at the same time and one may not be rendered before the other one renders you can't control which order they render in so if say if the white one rendered second and the red one rendered first the red one wouldn't be able to look for the white one because it hasn't rendered yet so you need to make sure that the thing that is being stenciled by the other thing renders after it so you would just go down here to your render queue and increase it by one so it's two or two thousand four hundred fifty one and the white one is two thousand four hundred and fifty so now it'll always render correctly and you can change this to equal if you wanted to so now it only renders where the white one is and that's basically what you need to know for stencils I'm not gonna go through all of the stencil stuff because it is just basic unity if you want to know how stencil stuff works like more than this just go to the documentation for stencils and unity I'll actually leave a link in the description below if you want to check that out and if you have any other questions about this or anything else I do feel free to join the discord there's a link in the description below thank you for watching
Info
Channel: poiyomi
Views: 12,144
Rating: undefined out of 5
Keywords:
Id: uniOEpw88jk
Channel Id: undefined
Length: 5min 29sec (329 seconds)
Published: Fri Aug 30 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.