// Made with Amplify Shader Editor // Available at the Unity Asset Store - http://u3d.as/y3X Shader "My/OutLineAlways" { Properties { _LineWidth("LineWidth", Float) = 0 [HDR]_MainColor("MainColor", Color) = (0,0,0,0) [HDR]_OutLineColor("OutLineColor", Color) = (1,1,1,0) _Opcity("Opcity", Range( 0 , 1)) = 1 [HideInInspector] __dirty( "", Int ) = 1 } SubShader { Pass { ColorMask 0 ZTest Always ZWrite On } Tags{ "RenderType" = "Transparent" "Queue" = "Transparent+0" } ZWrite On ZTest Always Cull Front CGPROGRAM #pragma target 3.0 #pragma surface outlineSurf Outline nofog alpha:premul keepalpha noshadow noambient novertexlights nolightmap nodynlightmap nodirlightmap nometa noforwardadd vertex:outlineVertexDataFunc void outlineVertexDataFunc( inout appdata_full v, out Input o ) { UNITY_INITIALIZE_OUTPUT( Input, o ); float outlineVar = _LineWidth; v.vertex.xyz *= ( 1 + outlineVar); } inline half4 LightingOutline( SurfaceOutput s, half3 lightDir, half atten ) { return half4 ( 0,0,0, s.Alpha); } void outlineSurf( Input i, inout SurfaceOutput o ) { o.Emission = _OutLineColor.rgb; o.Alpha = 0.0; } ENDCG Tags{ "RenderType" = "TransparentCutout" "Queue" = "Overlay+0" "IsEmissive" = "true" } Cull Back ZWrite On ZTest LEqual Blend SrcAlpha OneMinusSrcAlpha AlphaToMask On CGINCLUDE #include "UnityPBSLighting.cginc" #include "Lighting.cginc" #pragma target 3.0 struct Input { half filler; }; uniform float4 _MainColor; uniform float _Opcity; uniform float4 _OutLineColor; uniform float _LineWidth; void vertexDataFunc( inout appdata_full v, out Input o ) { UNITY_INITIALIZE_OUTPUT( Input, o ); v.vertex.xyz += 0; v.vertex.w = 1; } void surf( Input i , inout SurfaceOutputStandard o ) { o.Emission = _MainColor.rgb; o.Alpha = _Opcity; } ENDCG CGPROGRAM #pragma surface surf Standard keepalpha fullforwardshadows vertex:vertexDataFunc ENDCG Pass { Name "ShadowCaster" Tags{ "LightMode" = "ShadowCaster" } ZWrite On AlphaToMask Off CGPROGRAM #pragma vertex vert #pragma fragment frag #pragma target 3.0 #pragma multi_compile_shadowcaster #pragma multi_compile UNITY_PASS_SHADOWCASTER #pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2 #include "HLSLSupport.cginc" #if ( SHADER_API_D3D11 || SHADER_API_GLCORE || SHADER_API_GLES || SHADER_API_GLES3 || SHADER_API_METAL || SHADER_API_VULKAN ) #define CAN_SKIP_VPOS #endif #include "UnityCG.cginc" #include "Lighting.cginc" #include "UnityPBSLighting.cginc" sampler3D _DitherMaskLOD; struct v2f { V2F_SHADOW_CASTER; float3 worldPos : TEXCOORD1; UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_OUTPUT_STEREO }; v2f vert( appdata_full v ) { v2f o; UNITY_SETUP_INSTANCE_ID( v ); UNITY_INITIALIZE_OUTPUT( v2f, o ); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o ); UNITY_TRANSFER_INSTANCE_ID( v, o ); Input customInputData; vertexDataFunc( v, customInputData ); float3 worldPos = mul( unity_ObjectToWorld, v.vertex ).xyz; half3 worldNormal = UnityObjectToWorldNormal( v.normal ); o.worldPos = worldPos; TRANSFER_SHADOW_CASTER_NORMALOFFSET( o ) return o; } half4 frag( v2f IN #if !defined( CAN_SKIP_VPOS ) , UNITY_VPOS_TYPE vpos : VPOS #endif ) : SV_Target { UNITY_SETUP_INSTANCE_ID( IN ); Input surfIN; UNITY_INITIALIZE_OUTPUT( Input, surfIN ); float3 worldPos = IN.worldPos; half3 worldViewDir = normalize( UnityWorldSpaceViewDir( worldPos ) ); SurfaceOutputStandard o; UNITY_INITIALIZE_OUTPUT( SurfaceOutputStandard, o ) surf( surfIN, o ); #if defined( CAN_SKIP_VPOS ) float2 vpos = IN.pos; #endif half alphaRef = tex3D( _DitherMaskLOD, float3( vpos.xy * 0.25, o.Alpha * 0.9375 ) ).a; clip( alphaRef - 0.01 ); SHADOW_CASTER_FRAGMENT( IN ) } ENDCG } } Fallback "Diffuse" CustomEditor "ASEMaterialInspector" } /*ASEBEGIN Version=18900 468.8;352;1231;619;1130.663;159.7037;1.3;True;False Node;AmplifyShaderEditor.RangedFloatNode;10;-605.5823,410.0142;Inherit;False;Property;_LineWidth;LineWidth;0;0;Create;True;0;0;0;False;0;False;0;0.04;0;0;0;1;FLOAT;0 Node;AmplifyShaderEditor.ColorNode;14;-743.7242,159.1825;Inherit;False;Property;_OutLineColor;OutLineColor;3;1;[HDR];Create;True;0;0;0;False;0;False;1,1,1,0;0.4078431,1.270588,1.498039,0;True;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.RangedFloatNode;29;-354.7667,122.19;Inherit;False;Property;_Opcity;Opcity;4;0;Create;True;0;0;0;False;0;False;1;0.557;0;1;0;1;FLOAT;0 Node;AmplifyShaderEditor.ColorNode;13;-684.3784,-45.97131;Inherit;False;Property;_MainColor;MainColor;2;1;[HDR];Create;True;0;0;0;False;0;False;0,0,0,0;0,0,0,0;True;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.OutlineNode;6;-312.6316,291.5536;Inherit;False;1;True;AlphaPremultiplied;1;7;Front;3;0;FLOAT3;0,0,0;False;2;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT3;0 Node;AmplifyShaderEditor.StandardSurfaceOutputNode;15;0,0;Float;False;True;-1;2;ASEMaterialInspector;0;0;Standard;My/OutLineAlways;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;Back;1;False;-1;0;False;-1;False;0;False;-1;0;False;-1;True;7;Custom;0.5;True;True;0;True;TransparentCutout;;Overlay;All;14;all;True;True;True;True;0;False;-1;False;0;False;-1;255;False;-1;255;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;False;2;15;10;25;False;0.5;True;2;5;False;-1;10;False;-1;0;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;0;0,0,0,0;VertexOffset;True;False;Cylindrical;False;Relative;0;;1;-1;-1;-1;0;True;0;0;False;-1;-1;0;False;-1;0;0;0;False;0.1;False;-1;0;False;-1;False;16;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT;0;False;4;FLOAT;0;False;5;FLOAT;0;False;6;FLOAT3;0,0,0;False;7;FLOAT3;0,0,0;False;8;FLOAT;0;False;9;FLOAT;0;False;10;FLOAT;0;False;13;FLOAT3;0,0,0;False;11;FLOAT3;0,0,0;False;12;FLOAT3;0,0,0;False;14;FLOAT4;0,0,0,0;False;15;FLOAT3;0,0,0;False;0 WireConnection;6;0;14;0 WireConnection;6;1;10;0 WireConnection;15;2;13;0 WireConnection;15;9;29;0 WireConnection;15;11;6;0 ASEEND*/ //CHKSM=8A52197AE9C2780C04B25997C660A079E3AA45EC