76 lines
1.4 KiB
Plaintext
76 lines
1.4 KiB
Plaintext
Shader "Tutorial/Outline" {
|
|
|
|
Properties {
|
|
|
|
_Texture ("Texture", 2D) = "White" {}
|
|
|
|
_OutlineColor ("Outline Color", Color) = (0, 0, 0, 1)
|
|
_OutlineWidth ("Outline Width", Range(0, 0.1)) = 0.03
|
|
|
|
}
|
|
|
|
Subshader {
|
|
|
|
Tags {
|
|
"RenderType" = "Opaque"
|
|
}
|
|
|
|
CGPROGRAM
|
|
|
|
#pragma surface surf NoLighting noambient
|
|
|
|
sampler2D _Texture;
|
|
|
|
fixed4 LightingNoLighting(SurfaceOutput s, fixed3 lightDir, fixed atten) {
|
|
return fixed4(s.Albedo, s.Alpha);
|
|
}
|
|
|
|
struct Input {
|
|
float2 uv_MainTex;
|
|
};
|
|
|
|
half4 _Color;
|
|
half _Glossiness;
|
|
half _Metallic;
|
|
|
|
void surf(Input IN, inout SurfaceOutput o) {
|
|
fixed4 c = tex2D (_Texture, IN.uv_MainTex);
|
|
o.Albedo = c.rgb;
|
|
}
|
|
|
|
ENDCG
|
|
|
|
Pass {
|
|
|
|
Cull Front
|
|
|
|
CGPROGRAM
|
|
|
|
#pragma vertex VertexProgram
|
|
#pragma fragment FragmentProgram
|
|
|
|
half _OutlineWidth;
|
|
|
|
float4 VertexProgram(
|
|
float4 position : POSITION,
|
|
float3 normal : NORMAL) : SV_POSITION {
|
|
|
|
position.xyz += normal * _OutlineWidth;
|
|
|
|
return UnityObjectToClipPos(position);
|
|
|
|
}
|
|
|
|
half4 _OutlineColor;
|
|
|
|
half4 FragmentProgram() : SV_TARGET {
|
|
return _OutlineColor;
|
|
}
|
|
|
|
ENDCG
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} |