// Made with Amplify Shader Editor // Available at the Unity Asset Store - http://u3d.as/y3X Shader "Zyc/Toon" { Properties { _ASEOutlineColor( "Outline Color", Color ) = (0,0,0,0) _ASEOutlineWidth( "Outline Width", Float ) = 0.02 _ToonRamp("Toon Ramp", 2D) = "white" {} _RimColor("Rim Color", Color) = (0,1,0.8758622,0) _RimPower("Rim Power", Range( 0 , 10)) = 0.5 _RimOffset("Rim Offset", Float) = 0.24 _Diffuse("Diffuse", 2D) = "white" {} [HideInInspector] _texcoord( "", 2D ) = "white" {} [HideInInspector] __dirty( "", Int ) = 1 } SubShader { Tags{ } Cull Front CGPROGRAM #pragma target 3.0 #pragma surface outlineSurf Outline nofog keepalpha noshadow noambient novertexlights nolightmap nodynlightmap nodirlightmap nometa noforwardadd vertex:outlineVertexDataFunc uniform half4 _ASEOutlineColor; uniform half _ASEOutlineWidth; void outlineVertexDataFunc( inout appdata_full v, out Input o ) { UNITY_INITIALIZE_OUTPUT( Input, o ); v.vertex.xyz += ( v.normal * _ASEOutlineWidth ); } 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 = _ASEOutlineColor.rgb; o.Alpha = 1; } ENDCG Tags{ "RenderType" = "Opaque" "Queue" = "Geometry+0" } Cull Back CGINCLUDE #include "UnityPBSLighting.cginc" #include "UnityCG.cginc" #include "UnityShaderVariables.cginc" #include "Lighting.cginc" #pragma target 3.0 #ifdef UNITY_PASS_SHADOWCASTER #undef INTERNAL_DATA #undef WorldReflectionVector #undef WorldNormalVector #define INTERNAL_DATA half3 internalSurfaceTtoW0; half3 internalSurfaceTtoW1; half3 internalSurfaceTtoW2; #define WorldReflectionVector(data,normal) reflect (data.worldRefl, half3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal))) #define WorldNormalVector(data,normal) half3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal)) #endif struct Input { float2 uv_texcoord; float3 worldNormal; INTERNAL_DATA float3 worldPos; }; struct SurfaceOutputCustomLightingCustom { half3 Albedo; half3 Normal; half3 Emission; half Metallic; half Smoothness; half Occlusion; half Alpha; Input SurfInput; UnityGIInput GIData; }; uniform sampler2D _Diffuse; uniform float4 _Diffuse_ST; uniform sampler2D _ToonRamp; uniform float _RimOffset; uniform float _RimPower; uniform float4 _RimColor; inline half4 LightingStandardCustomLighting( inout SurfaceOutputCustomLightingCustom s, half3 viewDir, UnityGI gi ) { UnityGIInput data = s.GIData; Input i = s.SurfInput; half4 c = 0; #ifdef UNITY_PASS_FORWARDBASE float ase_lightAtten = data.atten; if( _LightColor0.a == 0) ase_lightAtten = 0; #else float3 ase_lightAttenRGB = gi.light.color / ( ( _LightColor0.rgb ) + 0.000001 ); float ase_lightAtten = max( max( ase_lightAttenRGB.r, ase_lightAttenRGB.g ), ase_lightAttenRGB.b ); #endif #if defined(HANDLE_SHADOWS_BLENDING_IN_GI) half bakedAtten = UnitySampleBakedOcclusion(data.lightmapUV.xy, data.worldPos); float zDist = dot(_WorldSpaceCameraPos - data.worldPos, UNITY_MATRIX_V[2].xyz); float fadeDist = UnityComputeShadowFadeDistance(data.worldPos, zDist); ase_lightAtten = UnityMixRealtimeAndBakedShadows(data.atten, bakedAtten, UnityComputeShadowFade(fadeDist)); #endif float2 uv_Diffuse = i.uv_texcoord * _Diffuse_ST.xy + _Diffuse_ST.zw; float3 ase_worldNormal = WorldNormalVector( i, float3( 0, 0, 1 ) ); float3 ase_worldPos = i.worldPos; #if defined(LIGHTMAP_ON) && UNITY_VERSION < 560 //aseld float3 ase_worldlightDir = 0; #else //aseld float3 ase_worldlightDir = normalize( UnityWorldSpaceLightDir( ase_worldPos ) ); #endif //aseld float dotResult3 = dot( ase_worldNormal , ase_worldlightDir ); float2 temp_cast_0 = (saturate( (dotResult3*0.5 + 0.5) )).xx; #if defined(LIGHTMAP_ON) && UNITY_VERSION < 560 //aselc float4 ase_lightColor = 0; #else //aselc float4 ase_lightColor = _LightColor0; #endif //aselc UnityGI gi11 = gi; float3 diffNorm11 = ase_worldNormal; gi11 = UnityGI_Base( data, 1, diffNorm11 ); float3 indirectDiffuse11 = gi11.indirect.diffuse + diffNorm11 * 0.0001; float3 ase_worldViewDir = normalize( UnityWorldSpaceViewDir( ase_worldPos ) ); float dotResult38 = dot( ase_worldNormal , ase_worldViewDir ); c.rgb = ( ( ( tex2D( _Diffuse, uv_Diffuse ) * tex2D( _ToonRamp, temp_cast_0 ) ) * ( ase_lightColor * float4( ( indirectDiffuse11 + ase_lightAtten ) , 0.0 ) ) ) + ( saturate( ( ( ase_lightAtten * dotResult3 ) * pow( ( 1.0 - saturate( ( dotResult38 + _RimOffset ) ) ) , _RimPower ) ) ) * ( _RimColor * ase_lightColor ) ) ).rgb; c.a = 1; return c; } inline void LightingStandardCustomLighting_GI( inout SurfaceOutputCustomLightingCustom s, UnityGIInput data, inout UnityGI gi ) { s.GIData = data; } void surf( Input i , inout SurfaceOutputCustomLightingCustom o ) { o.SurfInput = i; o.Normal = float3(0,0,1); } ENDCG CGPROGRAM #pragma surface surf StandardCustomLighting keepalpha fullforwardshadows exclude_path:deferred ENDCG Pass { Name "ShadowCaster" Tags{ "LightMode" = "ShadowCaster" } ZWrite On 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_GLES3 || SHADER_API_METAL || SHADER_API_VULKAN ) #define CAN_SKIP_VPOS #endif #include "UnityCG.cginc" #include "Lighting.cginc" #include "UnityPBSLighting.cginc" struct v2f { V2F_SHADOW_CASTER; float2 customPack1 : TEXCOORD1; float4 tSpace0 : TEXCOORD2; float4 tSpace1 : TEXCOORD3; float4 tSpace2 : TEXCOORD4; UNITY_VERTEX_INPUT_INSTANCE_ID }; v2f vert( appdata_full v ) { v2f o; UNITY_SETUP_INSTANCE_ID( v ); UNITY_INITIALIZE_OUTPUT( v2f, o ); UNITY_TRANSFER_INSTANCE_ID( v, o ); Input customInputData; float3 worldPos = mul( unity_ObjectToWorld, v.vertex ).xyz; half3 worldNormal = UnityObjectToWorldNormal( v.normal ); half3 worldTangent = UnityObjectToWorldDir( v.tangent.xyz ); half tangentSign = v.tangent.w * unity_WorldTransformParams.w; half3 worldBinormal = cross( worldNormal, worldTangent ) * tangentSign; o.tSpace0 = float4( worldTangent.x, worldBinormal.x, worldNormal.x, worldPos.x ); o.tSpace1 = float4( worldTangent.y, worldBinormal.y, worldNormal.y, worldPos.y ); o.tSpace2 = float4( worldTangent.z, worldBinormal.z, worldNormal.z, worldPos.z ); o.customPack1.xy = customInputData.uv_texcoord; o.customPack1.xy = v.texcoord; 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 ); surfIN.uv_texcoord = IN.customPack1.xy; float3 worldPos = float3( IN.tSpace0.w, IN.tSpace1.w, IN.tSpace2.w ); half3 worldViewDir = normalize( UnityWorldSpaceViewDir( worldPos ) ); surfIN.worldPos = worldPos; surfIN.worldNormal = float3( IN.tSpace0.z, IN.tSpace1.z, IN.tSpace2.z ); surfIN.internalSurfaceTtoW0 = IN.tSpace0.xyz; surfIN.internalSurfaceTtoW1 = IN.tSpace1.xyz; surfIN.internalSurfaceTtoW2 = IN.tSpace2.xyz; SurfaceOutputCustomLightingCustom o; UNITY_INITIALIZE_OUTPUT( SurfaceOutputCustomLightingCustom, o ) surf( surfIN, o ); #if defined( CAN_SKIP_VPOS ) float2 vpos = IN.pos; #endif SHADOW_CASTER_FRAGMENT( IN ) } ENDCG } } Fallback "Diffuse" CustomEditor "ASEMaterialInspector" } /*ASEBEGIN Version=16301 24;74;1866;959;1302.502;-506.595;1;True;True Node;AmplifyShaderEditor.CommentaryNode;49;-2016,528;Float;False;507.201;385.7996;Comment;3;36;37;38;N . V;1,1,1,1;0;0 Node;AmplifyShaderEditor.WorldNormalVector;36;-1968,576;Float;False;False;1;0;FLOAT3;0,0,0;False;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3 Node;AmplifyShaderEditor.ViewDirInputsCoordNode;37;-1920,736;Float;False;World;False;0;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3 Node;AmplifyShaderEditor.CommentaryNode;50;-1344,768;Float;False;1617.938;553.8222;;13;33;46;32;31;34;47;35;30;29;28;27;25;24;Rim Light;1,1,1,1;0;0 Node;AmplifyShaderEditor.DotProductOpNode;38;-1664,656;Float;False;2;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;1;FLOAT;0 Node;AmplifyShaderEditor.CommentaryNode;48;-2016,32;Float;False;540.401;320.6003;Comment;3;1;3;2;N . L;1,1,1,1;0;0 Node;AmplifyShaderEditor.RangedFloatNode;24;-1264,1040;Float;False;Property;_RimOffset;Rim Offset;3;0;Create;True;0;0;False;0;0.24;0.62;0;0;0;1;FLOAT;0 Node;AmplifyShaderEditor.SimpleAddOpNode;25;-1056,928;Float;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.CommentaryNode;51;-1143.099,-115.6995;Float;False;723.599;290;Also know as Lambert Wrap or Half Lambert;3;5;4;15;Diffuse Wrap;1,1,1,1;0;0 Node;AmplifyShaderEditor.WorldNormalVector;1;-1904,80;Float;False;False;1;0;FLOAT3;0,0,0;False;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3 Node;AmplifyShaderEditor.WorldSpaceLightDirHlpNode;2;-1952,240;Float;False;False;1;0;FLOAT;0;False;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3 Node;AmplifyShaderEditor.CommentaryNode;52;-880,320;Float;False;812;304;Comment;5;7;8;11;10;12;Attenuation and Ambient;1,1,1,1;0;0 Node;AmplifyShaderEditor.DotProductOpNode;3;-1616,144;Float;False;2;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;1;FLOAT;0 Node;AmplifyShaderEditor.RangedFloatNode;5;-1093.099,59.30051;Float;False;Constant;_WrapperValue;Wrapper Value;0;0;Create;True;0;0;False;0;0.5;0;0;0;0;1;FLOAT;0 Node;AmplifyShaderEditor.SaturateNode;27;-896,928;Float;False;1;0;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.OneMinusNode;29;-720,928;Float;False;1;0;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.LightAttenuation;7;-809.6001,504;Float;False;0;1;FLOAT;0 Node;AmplifyShaderEditor.RangedFloatNode;28;-832,1056;Float;False;Property;_RimPower;Rim Power;2;0;Create;True;0;0;False;0;0.5;0.13;0;10;0;1;FLOAT;0 Node;AmplifyShaderEditor.ScaleAndOffsetNode;4;-827.6974,-65.69949;Float;False;3;0;FLOAT;0;False;1;FLOAT;1;False;2;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.IndirectDiffuseLighting;11;-624,448;Float;False;Tangent;1;0;FLOAT3;0,0,0;False;1;FLOAT3;0 Node;AmplifyShaderEditor.PowerNode;30;-528,928;Float;False;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.SaturateNode;15;-594.4999,-58.89988;Float;False;1;0;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.SimpleMultiplyOpNode;35;-544,816;Float;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.SimpleAddOpNode;12;-384,480;Float;False;2;2;0;FLOAT3;0,0,0;False;1;FLOAT;0;False;1;FLOAT3;0 Node;AmplifyShaderEditor.LightColorNode;8;-768,368;Float;False;0;3;COLOR;0;FLOAT3;1;FLOAT;2 Node;AmplifyShaderEditor.ColorNode;34;-368,1040;Float;False;Property;_RimColor;Rim Color;1;0;Create;True;0;0;False;0;0,1,0.8758622,0;0.4187416,0.6471461,0.6370694,1;False;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.LightColorNode;47;-256,1216;Float;False;0;3;COLOR;0;FLOAT3;1;FLOAT;2 Node;AmplifyShaderEditor.SimpleMultiplyOpNode;31;-288,896;Float;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.SamplerNode;43;-224,-304;Float;True;Property;_Diffuse;Diffuse;4;0;Create;True;0;0;False;0;84508b93f15f2b64386ec07486afc7a3;68c284538d8ce7f4ca063923a9a29d3c;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;1;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.SamplerNode;6;-224,-80;Float;True;Property;_ToonRamp;Toon Ramp;0;0;Create;True;0;0;False;0;52e66a9243cdfed44b5e906f5910d35b;a05b8a3c2404508429e177f17cf2c05c;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;1;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.SimpleMultiplyOpNode;42;192,-96;Float;False;2;2;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;1;COLOR;0 Node;AmplifyShaderEditor.SimpleMultiplyOpNode;10;-224,368;Float;False;2;2;0;COLOR;0,0,0,0;False;1;FLOAT3;0,0,0;False;1;COLOR;0 Node;AmplifyShaderEditor.SimpleMultiplyOpNode;46;-64,1024;Float;False;2;2;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;1;COLOR;0 Node;AmplifyShaderEditor.SaturateNode;32;-96,896;Float;False;1;0;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.SimpleMultiplyOpNode;23;485.6002,153.2;Float;False;2;2;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;1;COLOR;0 Node;AmplifyShaderEditor.SimpleMultiplyOpNode;33;96,896;Float;False;2;2;0;FLOAT;0;False;1;COLOR;0,0,0,0;False;1;COLOR;0 Node;AmplifyShaderEditor.SimpleAddOpNode;39;832,384;Float;False;2;2;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;1;COLOR;0 Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;1077.3,350.7;Float;False;True;2;Float;ASEMaterialInspector;0;0;CustomLighting;Zyc/Toon;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;Back;0;False;-1;0;False;-1;False;0;False;-1;0;False;-1;False;0;Opaque;0.5;True;True;0;False;Opaque;;Geometry;ForwardOnly;True;True;True;True;True;True;True;True;True;True;True;True;True;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;0;4;10;25;False;0.5;True;0;0;False;-1;0;False;-1;0;0;False;-1;0;False;-1;1;False;-1;1;False;-1;0;True;0.02;0,0,0,0;VertexOffset;True;False;Cylindrical;False;Relative;0;;-1;-1;-1;-1;0;False;0;0;False;-1;-1;0;False;-1;0;0;0;False;0.1;False;-1;0;False;-1;15;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT3;0,0,0;False;4;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;38;0;36;0 WireConnection;38;1;37;0 WireConnection;25;0;38;0 WireConnection;25;1;24;0 WireConnection;3;0;1;0 WireConnection;3;1;2;0 WireConnection;27;0;25;0 WireConnection;29;0;27;0 WireConnection;4;0;3;0 WireConnection;4;1;5;0 WireConnection;4;2;5;0 WireConnection;30;0;29;0 WireConnection;30;1;28;0 WireConnection;15;0;4;0 WireConnection;35;0;7;0 WireConnection;35;1;3;0 WireConnection;12;0;11;0 WireConnection;12;1;7;0 WireConnection;31;0;35;0 WireConnection;31;1;30;0 WireConnection;6;1;15;0 WireConnection;42;0;43;0 WireConnection;42;1;6;0 WireConnection;10;0;8;0 WireConnection;10;1;12;0 WireConnection;46;0;34;0 WireConnection;46;1;47;0 WireConnection;32;0;31;0 WireConnection;23;0;42;0 WireConnection;23;1;10;0 WireConnection;33;0;32;0 WireConnection;33;1;46;0 WireConnection;39;0;23;0 WireConnection;39;1;33;0 WireConnection;0;13;39;0 ASEEND*/ //CHKSM=0B71FC8023704FEB7B2446D8125287CFDC469C3F