- Home /
Toon shader for a cube - outline problem
Hi everyone,
I want to have a cube with a toon shader. I created the cube and added the standard "Toony-BasicOutline" to the cube.
My problem is that the outline is missing at the top edge and the outlines go to far away from the edges when I increase the width of the outline.
How can I fix this problem? I want outlines at all edges and the should touch the edges (no matter what width I choose).
Tim
Answer by Aestial · Sep 23, 2013 at 12:34 AM
Hello, I found a better solution with this approach (Pro only, uses Image Effects):
http://www.isotx.com/selection-outlines/
However, the scale approach works only if the origin of the geometry is in the same point as its centroid. Perfect for a cube, and you only have to take out from the common toon/outline shader this line:
o.pos.xy += offset * o.pos.z * _Outline;
And add the following:
v.vertex.xyz *= (1 + _Outline);
just before this multiplication in the code nearby:
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
<\br>Hope it helps! :)
Answer by Chronos-L · May 31, 2013 at 02:29 PM
If I remember it correctly, the outline is created by moving each faces of the mesh away from the original position aligned to the face-normal, before it is rendered behind of your original mesh, so thicker outline means further away from the original face-position.
Orignal + DiOutline -> Outlined Object
To get the real cartoonish full outline, a working way is to perform a dilation of the image and do some simple compositing:
Orignal + Tinted Dilation -> Outlined Object
However, I did this in a photo editing software, and unfortunately I do not know how to do the dilation (2D image manipulation) in a 3D environment. This will be very useful if an efficient shader that can do the same is implemented, so far I do not manage to find to it. You can work on it if you want to, or else you will have to stay put with what is offered by the standard shader.
Answer by legion_44 · May 31, 2013 at 03:36 PM
You can make other cube, scale this to be bigger than original, attach SkyBox shader to it, then change it color to ex. black and you have good looking outline. You can make it by script also.
This should work, but I prefer to use the toon shader. Is it a good idea to add the shader without outline to the original cube and place another cube with the outlines around the original?
But this wouldnt solve the problem that the top edge is not visible...
Your answer
Follow this Question
Related Questions
Silhouette Toon Shader 0 Answers
Questions about the Toon/Basic Outline Shader 0 Answers
Toon shader shows outlines in editor, but not in game views 1 Answer
Toon Lit Outline Outline Transparent on Air 0 Answers
Reflective toon (outline+ramp) shader 3 Answers