- Home /
Question by
Plukers · Jun 12, 2015 at 01:00 AM ·
colorscaleissuepropertiessurface shader
Surface Shader issue: property color gets changed
Hey guys,
i'm currently writing a surface toon shader, which has among others an outlineColor property. This is by default black. However, if the shader is used on scaled objects, this color changes also.
Properties {
//...
_OutColor ("Outline Color", Color) = (-1,-1,-1,1)
//..
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Toon
fixed4 _OutColor;
half4 LightingToon (SurfaceOutput s, half3 lightDir, half3 viewDir, half atten) {
// other shader code
fixed4 c = _OutColor; // only access in the whole shader
// c = fixed4(-1,-1,-1,1) -> if i would do this, every outline would be black
// other shader code, where c is modified, if we are at no border at the moment
return c;
}
struct Input {
float2 uv_MainTex;
float4 customColor;
};
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb * _Color.rgb;
}
ENDCG
}
I can hardly post more code, I'm sry.
Here is a picture of an object where this shader is used. The spheres are scaled (1, 1, 1), whereas the connections inbetween them are scaled (2, 0.25, 2). You can see that these connections don't have black borders.
EDIT: I just testet what happens if I change the scale of a sphere. Result nothing. However, if I reset the shader during runtime in the Unity Editor then its working like it should.
example.png
(219.1 kB)
Comment