I would like to use a shader to get the edges with a specific color (http://wiki.unity3d.com/index.php/OutlinedDiffuse). (The code only works with “vert”, there is no “frag” function, but since it is on the wiki, I guess it is also working like that).
EDIT #2:
Thanks whydoitdoit for the link. Would you know how to avoid the outline effect inside an intersection between 2 rectangles? The 2 rectangles are perfectly perpendicular in Blender…
Also how could I change the color of the front “frag”, I tried with return float4(70, 70, 30, 1); but it triggers a warning : “Shader warning in ‘Toon2’: Program ‘vert’, implicit truncation of vector type (compiling for d3d11_9x)”
I have got this result without the lightcolor with :
So you can do that by not writing to the depth buffer on the first pass, or by offsetting the depth buffer backwards during that pass (or forwards in the other pass) - however, it ends up looking odd when you put two characters next to each other, because their outlines will merge and they won't be outlined against each other very well.
Something like this?
– whydoidoitSo you can do that by not writing to the depth buffer on the first pass, or by offsetting the depth buffer backwards during that pass (or forwards in the other pass) - however, it ends up looking odd when you put two characters next to each other, because their outlines will merge and they won't be outlined against each other very well.
– whydoidoitConverted the toon shader to an answer (because it's too unwieldy as a comment :)
– whydoidoit