The problem is that the outline is drawn per mesh (actually, per submesh). I guess that like for the dude, your mesh is made of several meshes / sub-meshes, that’s why you don’t get the result you want.
A solution would be to merge all the meshes into a single one by calling Mesh.MergeMeshes, then draw the outline for this mesh.
For this to work you need to make sure this mesh will be displayed before your regular meshes so that the outline is drawn under the meshes and not over. To do so, you can assign a material to this mesh that has a uniqueId lower to the lowest ids of your other mesh materials: since 5.0, the (non transparent) meshes are sorted by ascending material.uniqueId (or mesh.uniqueId if the meshes don’t have materials).
You should also disable depth/color writing for the merged mesh, to save some performances as this mesh won’t be seen anyway, as it will be overwritten by your regular meshes.
Here’s a PG that demonstrates that:
Maybe there’s a simpler way. Using the highlight layer would definitely be simpler. See:
Yes, but in this case you cannot animate dude anymore with its edge rendering. What about the toon shader? I haven’t used it so far but it seems to be a perfect match for this kind of thing, or isn’t it?
I don’t know the toon shader but it may suffer the same problem because in the end each sub-mesh is drawn separately, so each sub-mesh will have its own outline.
Thank you for your reply
First, I’ve tried a lot of things.
One of them was mesh merging.
I have to keep changing the character’s clothes, so I can’t change clothes if I merge them. (+As Mawa mentioned below, there are animations)
So now I’m researching to apply to the toon shading, and I’m frustrated, so I posted a question.
I learned a lot from the answers and codes. Thank you!
Kenshin Toon Shading, which is shared on the forum, doesn’t have an outline.
So, I used “Highlight Layer” for the outline.
If it overlaps, the overlapping parts disappear and only the outline of the whole is visible.
so I use the high light layer for each character’s outline, but there’s a bit of a load
I know. HL will add to the draw calls. There has been (a number) of other posts recently in the forum about how we could possibly make edge rendering apply more specifically to an object group (or exclude objects or object groups). But the subject is complex and then, far beyond my reach. Let’s just hope the ‘big brains’ will eventually find one of their own automagical solution for this. Meanwhile, we’ll do what we can.