- Home /
How to render outline differently
Hi, I amtrying to achieve an outline effect similiar to what I found here http://blogs.aerys.in/jeanmarc-lerou...s-cel-shading/. I'm interested only in the first part, the one with drawing the outline. So far I've managed to write this
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata {
float4 vertex : POSITION;
float4 color : COLOR;
float3 normal : NORMAL;
};
struct v2f {
float4 pos : SV_POSITION;
float3 color : COLOR0;
float isEdge;
};
v2f vert (appdata v)
{
v2f o;
float eyeToVertex = normalize(v.vertex - _WorldSpaceCameraPos);
o.isEdge = dot(v.normal, eyeToVertex) < -0.05 ? 1 : 0;
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
return o;
}
half4 frag (v2f i) : COLOR
{
return half4 (lerp(float3(0,0,0), float3(1,1,1), i.isEdge), 1);
}
ENDCG
but It didn't get me where I wanted. I'm having a bit of trouble with this part , more specifically how can I replicate it in shaderlab Code:
multiply4x4(
add(vertexPosition, float4(delta, 0)),
localToScreenMatrix
);
I already have an outline effect inspired by the unity's toon shader, but now I need to change the way I draw the outline in order to meet some new requirements. Any ideeas? Thanks
Your answer
Follow this Question
Related Questions
Is there a shader to only add an outline? 7 Answers
Blueprint Shader 2 Answers
"double" outline shader? 0 Answers
How can I get soft edges on planes/quads? 1 Answer
Set Color not working on Outline 0 Answers