- Home /
Question by
Mishnab · May 12, 2014 at 02:50 PM ·
shadernot workingoutline
Can't change the Outlinecolor of my silhouette shader.
Hello everyone I am relatively new to Shader coding and I needed a silhouette shader for a game I am actually working on. It is based on the silhouette shader found here Strangely enough, I can't change the color value of my _OutlineColor to blue(0,0,1,1), whatever I write in my color float4, it will always remain black (0,0,0,1). Here is my shader:
Shader "Outlined/Silhouetted Bumped Diffuse" {
Properties {
_Color ("Main Color", Color) = (1,.5,1,1)
_OutlineColor ("Outline Color", Color) = (0,0,1,1)
_Outline ("Outline width", Range (0.0, 0.03)) = .005
_MainTex ("Base (RGB)", 2D) = "red" { }
_BumpMap ("Bumpmap", 2D) = "bump" {}
}
CGINCLUDE
#include "UnityCG.cginc"
struct appdata {
float4 vertex : POSITION;
float3 normal : NORMAL;
};
struct v2f {
float4 pos : POSITION;
float4 color : COLOR;
};
uniform float _Outline;
uniform float4 _OutlineColor;
v2f vert(appdata 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 * o.pos.z * _Outline * 5;
o.color = _OutlineColor;
return o;
}
ENDCG
SubShader {
Tags { "Queue" = "Transparent" }
Pass {
Name "OUTLINE"
Tags { "LightMode" = "Always" }
Cull Off
ZWrite Off
ZTest Always
Blend SrcAlpha OneMinusSrcAlpha // Normal
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
half4 frag(v2f i) : COLOR {
return i.color;
}
ENDCG
}
CGPROGRAM
#pragma surface surf Lambert
struct Input {
float2 uv_MainTex;
float2 uv_BumpMap;
};
sampler2D _MainTex;
sampler2D _BumpMap;
uniform float3 _Color;
void surf(Input IN, inout SurfaceOutput o) {
o.Albedo = tex2D(_MainTex, IN.uv_MainTex).rgb * _Color;
o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
}
ENDCG
}
Fallback "Outlined/Silhouetted Diffuse"
}
and here is the result in my scene: http://imgur.com/ajpEBjX
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613144853im_/https://answers.unity.com/themes/thub/images/avi.jpg)