My entire game consists only of materials that are white, so in order for people to tell when one object ends and another begins I need a black outline around the object. The unity toon shader is inconsistent when it comes to showing lines and generally looks poor. I have zero knowledge of shaders, so any help appreciated. Not unlike this (antichamber):
I think what you need is not outline, but edge detection. Unity has an edge-detection scripts in ImageEffects package, which I think would help you out.
I guess I need an alternative then. I know shaders can do what I need, I just don't where to find them.
Actually, Unity has four Toon Shading shaders (two are with Outline) and they're also working with Free. You'll find them in the Standard Assets or get them via Assets > Import Package > Toon Shading. Edit: I saw that you're already aware of the toon shaders. Didn't read your posting properly. My fault.
What part of the toon shaders don't you like? I know you can adjust them so line width is consistent. Since you don't have pro, your only other option is to manually make outlines by duplicating the geometry, pushing the verts out in the direction of their normal, and flipping the normals.
The toon shaders seem to sometimes miss certain edges of models unless you look at it from a specific angle. In my game than can be confusing because all you have to go off are those lines.
Toon shaders works fine when normals of rendered objects are consistent, so if you use toon shader to render a cube whose normals at the edge of two adjacent sides are not consistent with normals of the two sides, then toon shader could not get a right consistent outline for these edges. Sorry but I don't know how to handle with this . Edit: There is a way to improve normals consistent of an objects, in fbx import settings, set "Normals" to "Calculate" and "Smoothing Angle" value as large as possible. And there is also a expensive way to achieve more accurate result. when building models, every model is comprised of two sub-models, a larger one and s small one. the small one is wrapped by the larger one, and when rendering the model, render the larger one with Cull Front, render the small one with normal method. This could get a fine appearance while your vertex numbers could be doubled. Here is a simple version of toon shader, you can see vertices in view-space are pushed into normal direction to get a larger version of rendered object in the first pass, and the second pass is used to draw the object self. Code (csharp): Shader "Custom/TestShader" { Properties { _OutlineColor ("Outline Color", Color) = (0,0,0,1) _Outline ("Outline width", Range (0, 0.1)) = .005 _MainTex ("Base (RGB)", 2D) = "white" { } } SubShader { Tags { "RenderType"="Opaque" } Pass { // Pass drawing outline Cull Front Blend SrcAlpha OneMinusSrcAlpha CGPROGRAM #include "UnityCG.cginc" #pragma vertex vert #pragma fragment frag uniform float _Outline; uniform float4 _OutlineColor; uniform float4 _MainTex_ST; uniform sampler2D _MainTex; struct v2f { float4 pos : POSITION; float4 color : COLOR; }; v2f vert(appdata_base v) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); float3 norm = mul ((float3x3)UNITY_MATRIX_IT_MV, v.normal); float2 offset = TransformViewToProjection(norm.xy); o.pos.xy += offset * _Outline; o.color = _OutlineColor; return o; } half4 frag(v2f i) :COLOR { return i.color; } ENDCG } Pass { // pass drawing object CGPROGRAM #include "UnityCG.cginc" #pragma vertex vert #pragma fragment frag uniform float4 _MainTex_ST; uniform sampler2D _MainTex; struct v2f { float4 pos : POSITION; float2 uv : TEXCOORD0; }; v2f vert(appdata_base v) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv = v.texcoord; return o; } half4 frag(v2f i) :COLOR { return tex2D (_MainTex, _MainTex_ST.xy * i.uv.xy + _MainTex_ST.zw); } ENDCG } } Fallback Off }
old thread but still id like to chip in my 2 cents. of course it depends on what exactly trying to achive, but you can visualize the white objects with black outline via simple black/white textures. works well with cube like shapes. round objects probably need a tex that looks like a simple mesh.