I’m using this custom shader, but there seems to be a small problem with it.
This shader takes a ramp and creates an outline similar to the velvet shader, but I’m getting some weird lighting issues.
I put the shader on a sphere, put a texture on it, put a grayscale gradient on it, and when I rotate the sphere, it gives me this weird highlight in the middle of the sphere.
Any help is appreciated.
Shader "DiffuseOutline"
{
Properties{
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans. (Alpha)", 2D) = "white" { }
_RampTex ("Outline Ramp (RGB)", 2D) = "white" {}
_Shininess ("Shininess", Range (0.01, 1)) = 0.7
_OutlineColor ("Outline Color", Color) = (1,1,1,1)
_SpecColor ("Spec Color", Color) = (1,1,1,1)
}
Category{
ZWrite On
SubShader{
Pass {
Material {
Ambient (1,1,1,1)
Diffuse [_Color]
Shininess [_Shininess]
Specular [_SpecColor]
}
Lighting On
SetTexture [_MainTex] { constantColor [_Color] Combine texture * primary DOUBLE, texture * constant}
}
Pass{
Blend SrcAlpha One
CGPROGRAM
#pragma vertex vert
#include "UnityCG.cginc"
struct v2f {
V2F_POS_FOG;
float2 uv : TEXCOORD0;
};
v2f vert (appdata_base v)
{
v2f o;
PositionFog( v.vertex, o.pos, o.fog );
float3 viewDir = normalize(ObjSpaceViewDir(v.vertex));
o.uv.x = dot(viewDir,v.normal);
o.uv.y = 0.5;
return o;
}
ENDCG
SetTexture [_RampTex] {constantColor[_OutlineColor] }
}
}
}
}