I im trying to draw the contour of an object with a given color and a given size.
I have created a shader based on toon shading that modify the vertex adding the normal (modeled to achieve the effect)
The problem is that with object with little size is shows correct but with object with a bigger size the contour get a weird offset and i can’t figure out why ?
This is the CGPROGRAM
Pass
{
ZWrite Off
ZTest LEqual
Cull Off
CGPROGRAM
// profiles arbfp1
// vertex vert
// fragment frag
#include "UnityCG.cginc"
uniform float4 _Color;
uniform float _Size;
void vert (float4 Vertex
,float4 Normal
,out float4 oVertex : POSITION
,uniform float4 _Color
,uniform float _Size)
{
oVertex = mul (glstate.matrix.mvp, Vertex);
float4 normal = mul (glstate.matrix.mvp, Normal);
oVertex += normalize (normal) * _Size;
}
void frag (out float4 oColor : COLOR
,uniform float4 _Color)
{
oColor = _Color;
}
ENDCG
}
I can give troubleshooting a shot if you post the current version you are using with the object space transformation in a .unityPackage with a test scene – this seems similar to the Fur shader. Making it easier for people to help generally helps you get your answer.
if it’s just one object then that looks correct to me. i’m guessing that it’s scaling along the normal but relative to the center of the combined bounds. you can see how it’s more exaggerated on the edge objects compared to the middle objects. try them as 3 separate objects and see what happens.