Hey. So I know how to do an outline shader but I would then want to remove everything except the outline. (so you can see through it). I guess you could use Clip but how. The way I do outline is that I first render a solid color that is bigger than the object in one pass. And then the object above that in the 2nd pass. Im confused how I would use Clip in this context.
That last pass is an old fixed function shader. Unity no longer supports fixed function shaders, so they actually treat those as vertex fragment generators, the generated code for which you can see if you select the shader in Unity and click on “Show Generated Code” in the inspector.
However for what you want, that’s not going to be useful. The above shade works by rendering the mesh once slightly expanded on the vertex normals, but with ZWrite Off. This means it doesn’t write to the depth buffer, and means the second pass just renders on top of it.
To do what you want you’d still need a two pass shader, but you’d need to render your mesh with a stencil only pass, then have the expanded outline pass exclude itself wherever the stencil has been written to.
See the depth only pass from this page, but use ZWrite Off and stencils.
Hey Thank you so much! I read some tutorials about stencils and such things you talked about.
But currently my stencils dont seem to do anything no matter how i change them. Should i do stencil 2 times? How can the 2nd stencil use the expanded model and check against the regular model? The code is a mess right now. I have just tried a lot of different things.
Also another questinon. Is it possible to draw pixels end then erase them in the same shader? I know about clip but I mean in a secound pass erase something from the first so you can see through it to the stuff behind the object. Trying to get a grasp on whats possible.
Now the next step is that i would like it to only have the outline like that when the object is behind the character and when its in front to show itself without outline. So I need one more stencil of the character as well. Hope it will work. (But help is much appreciated as i will most likely fuck up).