Shader "Custom/NewSurfaceShader" { Properties { _Color ("Color", Color) = (1,1,1,1) _MainTex ("Albedo (RGB)", 2D) = "white" {} _Glossiness ("Smoothness", Range(0,1)) = 0.5 _Metallic ("Metallic", Range(0,1)) = 0.0 } SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM // Physically based Standard lighting model, and enable shadows on all light types #pragma surface surf Standard fullforwardshadows // Use shader model 3.0 target, to get nicer looking lighting #pragma target 3.0 sampler2D _MainTex; struct Input { float2 uv_MainTex; }; half _Glossiness; half _Metallic; fixed4 _Color; // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader. // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing. // #pragma instancing_options assumeuniformscaling UNITY_INSTANCING_BUFFER_START(Props) // put more per-instance properties here UNITY_INSTANCING_BUFFER_END(Props) void surf (Input IN, inout SurfaceOutputStandard o) { // Albedo comes from a texture tinted by color fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; o.Albedo = c.rgb; // Metallic and smoothness come from slider variables o.Metallic = _Metallic; o.Smoothness = _Glossiness; o.Alpha = c.a; } ENDCG Pass{ Cull Front CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" #include "AutoLight.cginc" struct appdata { float4 vertex : POSITION; float2 texcoord0 : TEXCOORD0; float3 normal : NORMAL; float4 color : COLOR; }; struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 vertex_color : TEXCOORD3; }; float _OutlineWidth; float _OutlineZbias; float4 _OutlineColor; v2f vert(appdata v) { v2f o; float3 pos_view = UnityObjectToViewPos(v.vertex); float3 normal_world = UnityObjectToWorldNormal(v.normal); float3 outline_dir = normalize(mul((float3x3)UNITY_MATRIX_V, normal_world)); outline_dir.z = _OutlineZbias * (1.0 - v.color.b); pos_view += outline_dir * _OutlineWidth * 0.001 * v.color.a; o.pos = mul(UNITY_MATRIX_P, float4(pos_view, 1.0)); o.uv = v.texcoord0; o.vertex_color = v.color; return o; } half4 frag(v2f i) : SV_Target { half3 outlineColor = _OutlineColor.xyz; return float4(outlineColor, 1.0); } ENDCG } } FallBack "Diffuse" }