// Toony Colors Pro+Mobile 2 // (c) 2014-2025 Jean Moreno Shader "Reset/BuildingStyleTest" { Properties { [TCP2HeaderHelp(Base)] [MainColor] _BaseColor ("Color", Color) = (1,1,1,1) [TCP2ColorNoAlpha] _HColor ("Highlight Color", Color) = (0.75,0.75,0.75,1) [TCP2ColorNoAlpha] _SColor ("Shadow Color", Color) = (0.2,0.2,0.2,1) [MainTexture] _BaseMap ("Albedo", 2D) = "white" {} [TCP2Separator] [TCP2Header(Ramp Shading)] _RampThreshold ("Threshold", Range(0.01,1)) = 0.5 _RampSmoothing ("Smoothing", Range(0.001,1)) = 0.5 [TCP2Separator] [TCP2HeaderHelp(Normal Mapping)] [NoScaleOffset] _BumpMap ("Normal Map", 2D) = "bump" {} [TCP2Separator] [ToggleOff(_RECEIVE_SHADOWS_OFF)] _ReceiveShadowsOff ("Receive Shadows", Float) = 1 // Avoid compile error if the properties are ending with a drawer [HideInInspector] __dummy__ ("unused", Float) = 0 } SubShader { Tags { "RenderPipeline" = "UniversalPipeline" "RenderType"="Opaque" } HLSLINCLUDE #define fixed half #define fixed2 half2 #define fixed3 half3 #define fixed4 half4 #if UNITY_VERSION >= 202020 #define URP_10_OR_NEWER #endif #if UNITY_VERSION >= 202120 #define URP_12_OR_NEWER #endif #if UNITY_VERSION >= 202220 #define URP_14_OR_NEWER #endif // Texture/Sampler abstraction #define TCP2_TEX2D_WITH_SAMPLER(tex) TEXTURE2D(tex); SAMPLER(sampler##tex) #define TCP2_TEX2D_NO_SAMPLER(tex) TEXTURE2D(tex) #define TCP2_TEX2D_SAMPLE(tex, samplertex, coord) SAMPLE_TEXTURE2D(tex, sampler##samplertex, coord) #define TCP2_TEX2D_SAMPLE_LOD(tex, samplertex, coord, lod) SAMPLE_TEXTURE2D_LOD(tex, sampler##samplertex, coord, lod) #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" // Uniforms // Shader Properties TCP2_TEX2D_WITH_SAMPLER(_BumpMap); TCP2_TEX2D_WITH_SAMPLER(_BaseMap); CBUFFER_START(UnityPerMaterial) // Shader Properties float4 _BaseMap_ST; fixed4 _BaseColor; float _RampThreshold; float _RampSmoothing; fixed4 _SColor; fixed4 _HColor; CBUFFER_END // Built-in renderer (CG) to SRP (HLSL) bindings #define UnityObjectToClipPos TransformObjectToHClip #define _WorldSpaceLightPos0 _MainLightPosition ENDHLSL Pass { Name "Main" Tags { "LightMode"="UniversalForward" } HLSLPROGRAM // Required to compile gles 2.0 with standard SRP library // All shaders must be compiled with HLSLcc and currently only gles is not using HLSLcc by default #pragma prefer_hlslcc gles #pragma exclude_renderers d3d11_9x #pragma target 3.0 // ------------------------------------- // Material keywords #pragma shader_feature_local _ _RECEIVE_SHADOWS_OFF // ------------------------------------- // Universal Render Pipeline keywords #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS #pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS #pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING #pragma multi_compile _ SHADOWS_SHADOWMASK #pragma multi_compile _ _CLUSTER_LIGHT_LOOP #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl" // ------------------------------------- //-------------------------------------- // GPU Instancing #pragma multi_compile_instancing #pragma vertex Vertex #pragma fragment Fragment // vertex input struct Attributes { float4 vertex : POSITION; float3 normal : NORMAL; float4 tangent : TANGENT; float4 texcoord0 : TEXCOORD0; UNITY_VERTEX_INPUT_INSTANCE_ID }; // vertex output / fragment input struct Varyings { float4 positionCS : SV_POSITION; float3 normal : NORMAL; float4 worldPosAndFog : TEXCOORD0; #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) float4 shadowCoord : TEXCOORD1; // compute shadow coord per-vertex for the main light #endif #ifdef _ADDITIONAL_LIGHTS_VERTEX half3 vertexLights : TEXCOORD2; #endif float3 pack0 : TEXCOORD3; /* pack0.xyz = tangent */ float3 pack1 : TEXCOORD4; /* pack1.xyz = bitangent */ float2 pack2 : TEXCOORD5; /* pack2.xy = texcoord0 */ UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_OUTPUT_STEREO }; #if USE_FORWARD_PLUS || USE_CLUSTER_LIGHT_LOOP // Fake InputData struct needed for Forward+ macro struct InputDataForwardPlusDummy { float3 positionWS; float2 normalizedScreenSpaceUV; }; #endif Varyings Vertex(Attributes input) { Varyings output = (Varyings)0; UNITY_SETUP_INSTANCE_ID(input); UNITY_TRANSFER_INSTANCE_ID(input, output); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); // Texture Coordinates output.pack2.xy.xy = input.texcoord0.xy * _BaseMap_ST.xy + _BaseMap_ST.zw; VertexPositionInputs vertexInput = GetVertexPositionInputs(input.vertex.xyz); #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) output.shadowCoord = GetShadowCoord(vertexInput); #endif VertexNormalInputs vertexNormalInput = GetVertexNormalInputs(input.normal, input.tangent); #ifdef _ADDITIONAL_LIGHTS_VERTEX // Vertex lighting output.vertexLights = VertexLighting(vertexInput.positionWS, vertexNormalInput.normalWS); #endif // world position output.worldPosAndFog = float4(vertexInput.positionWS.xyz, 0); // normal output.normal = normalize(vertexNormalInput.normalWS); // tangent output.pack0.xyz = vertexNormalInput.tangentWS; output.pack1.xyz = vertexNormalInput.bitangentWS; // clip position output.positionCS = vertexInput.positionCS; return output; } half4 Fragment(Varyings input ) : SV_Target { UNITY_SETUP_INSTANCE_ID(input); UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); float3 positionWS = input.worldPosAndFog.xyz; float3 normalWS = normalize(input.normal); half3 tangentWS = input.pack0.xyz; half3 bitangentWS = input.pack1.xyz; half3x3 tangentToWorldMatrix = half3x3(tangentWS.xyz, bitangentWS.xyz, normalWS.xyz); // Shader Properties Sampling float4 __normalMap = ( TCP2_TEX2D_SAMPLE(_BumpMap, _BumpMap, input.pack2.xy).rgba ); float4 __albedo = ( TCP2_TEX2D_SAMPLE(_BaseMap, _BaseMap, input.pack2.xy).rgba ); float4 __mainColor = ( _BaseColor.rgba ); float __alpha = ( __albedo.a * __mainColor.a ); float __ambientIntensity = ( 1.0 ); float __rampThreshold = ( _RampThreshold ); float __rampSmoothing = ( _RampSmoothing ); float3 __shadowColor = ( _SColor.rgb ); float3 __highlightColor = ( _HColor.rgb ); half4 normalMap = __normalMap; half3 normalTS = UnpackNormal(normalMap); normalWS = normalize( mul(normalTS, tangentToWorldMatrix) ); // main texture half3 albedo = __albedo.rgb; half alpha = __alpha; half3 emission = half3(0,0,0); albedo *= __mainColor.rgb; // main light: direction, color, distanceAttenuation, shadowAttenuation #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) float4 shadowCoord = input.shadowCoord; #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS) float4 shadowCoord = TransformWorldToShadowCoord(positionWS); #else float4 shadowCoord = float4(0, 0, 0, 0); #endif #if defined(URP_10_OR_NEWER) #if defined(SHADOWS_SHADOWMASK) && defined(LIGHTMAP_ON) half4 shadowMask = SAMPLE_SHADOWMASK(input.staticLightmapUV); #elif !defined (LIGHTMAP_ON) half4 shadowMask = unity_ProbesOcclusion; #else half4 shadowMask = half4(1, 1, 1, 1); #endif Light mainLight = GetMainLight(shadowCoord, positionWS, shadowMask); #else Light mainLight = GetMainLight(shadowCoord); #endif #if defined(_SCREEN_SPACE_OCCLUSION) || defined(USE_FORWARD_PLUS) || defined(USE_CLUSTER_LIGHT_LOOP) float2 normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS); #endif // ambient or lightmap // Samples SH fully per-pixel. SampleSHVertex and SampleSHPixel functions // are also defined in case you want to sample some terms per-vertex. half3 bakedGI = SampleSH(normalWS); half occlusion = 1; half3 indirectDiffuse = bakedGI; indirectDiffuse *= occlusion * albedo * __ambientIntensity; half3 lightDir = mainLight.direction; half3 lightColor = mainLight.color.rgb; half atten = mainLight.shadowAttenuation * mainLight.distanceAttenuation; half ndl = dot(normalWS, lightDir); half3 ramp; half rampThreshold = __rampThreshold; half rampSmooth = __rampSmoothing * 0.5; ndl = saturate(ndl); ramp = smoothstep(rampThreshold - rampSmooth, rampThreshold + rampSmooth, ndl); // apply attenuation ramp *= atten; half3 color = half3(0,0,0); half3 accumulatedRamp = ramp * max(lightColor.r, max(lightColor.g, lightColor.b)); half3 accumulatedColors = ramp * lightColor.rgb; // Additional lights loop #ifdef _ADDITIONAL_LIGHTS uint pixelLightCount = GetAdditionalLightsCount(); #if USE_FORWARD_PLUS || USE_CLUSTER_LIGHT_LOOP // Additional directional lights in Forward+ for (uint lightIndex = 0; lightIndex < min(URP_FP_DIRECTIONAL_LIGHTS_COUNT, MAX_VISIBLE_LIGHTS); lightIndex++) { CLUSTER_LIGHT_LOOP_SUBTRACTIVE_LIGHT_CHECK Light light = GetAdditionalLight(lightIndex, positionWS, shadowMask); #if defined(_LIGHT_LAYERS) if (IsMatchingLightLayer(light.layerMask, meshRenderingLayers)) #endif { half atten = light.shadowAttenuation * light.distanceAttenuation; #if defined(_LIGHT_LAYERS) half3 lightDir = half3(0, 1, 0); half3 lightColor = half3(0, 0, 0); if (IsMatchingLightLayer(light.layerMask, meshRenderingLayers)) { lightColor = light.color.rgb; lightDir = light.direction; } #else half3 lightColor = light.color.rgb; half3 lightDir = light.direction; #endif half ndl = dot(normalWS, lightDir); half3 ramp; ndl = saturate(ndl); ramp = smoothstep(rampThreshold - rampSmooth, rampThreshold + rampSmooth, ndl); // apply attenuation (shadowmaps & point/spot lights attenuation) ramp *= atten; accumulatedRamp += ramp * max(lightColor.r, max(lightColor.g, lightColor.b)); accumulatedColors += ramp * lightColor.rgb; } } // Data with dummy struct used in Forward+ macro (LIGHT_LOOP_BEGIN) InputDataForwardPlusDummy inputData; inputData.normalizedScreenSpaceUV = normalizedScreenSpaceUV; inputData.positionWS = positionWS; #endif LIGHT_LOOP_BEGIN(pixelLightCount) { #if defined(URP_10_OR_NEWER) Light light = GetAdditionalLight(lightIndex, positionWS, shadowMask); #else Light light = GetAdditionalLight(lightIndex, positionWS); #endif half atten = light.shadowAttenuation * light.distanceAttenuation; #if defined(_LIGHT_LAYERS) half3 lightDir = half3(0, 1, 0); half3 lightColor = half3(0, 0, 0); if (IsMatchingLightLayer(light.layerMask, meshRenderingLayers)) { lightColor = light.color.rgb; lightDir = light.direction; } #else half3 lightColor = light.color.rgb; half3 lightDir = light.direction; #endif half ndl = dot(normalWS, lightDir); half3 ramp; ndl = saturate(ndl); ramp = smoothstep(rampThreshold - rampSmooth, rampThreshold + rampSmooth, ndl); // apply attenuation (shadowmaps & point/spot lights attenuation) ramp *= atten; accumulatedRamp += ramp * max(lightColor.r, max(lightColor.g, lightColor.b)); accumulatedColors += ramp * lightColor.rgb; } LIGHT_LOOP_END #endif #ifdef _ADDITIONAL_LIGHTS_VERTEX color += input.vertexLights * albedo; #endif accumulatedRamp = saturate(accumulatedRamp); half3 shadowColor = (1 - accumulatedRamp.rgb) * __shadowColor; accumulatedRamp = accumulatedColors.rgb * __highlightColor + shadowColor; color += albedo * accumulatedRamp; // apply ambient color += indirectDiffuse; color += emission; return half4(color, alpha); } ENDHLSL } // Depth & Shadow Caster Passes HLSLINCLUDE #if defined(SHADOW_CASTER_PASS) || defined(DEPTH_ONLY_PASS) #define fixed half #define fixed2 half2 #define fixed3 half3 #define fixed4 half4 float3 _LightDirection; float3 _LightPosition; struct Attributes { float4 vertex : POSITION; float3 normal : NORMAL; float4 texcoord0 : TEXCOORD0; UNITY_VERTEX_INPUT_INSTANCE_ID }; struct Varyings { float4 positionCS : SV_POSITION; #if defined(DEPTH_NORMALS_PASS) float3 normalWS : TEXCOORD0; #endif float2 pack0 : TEXCOORD1; /* pack0.xy = texcoord0 */ #if defined(DEPTH_ONLY_PASS) UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_OUTPUT_STEREO #endif }; float4 GetShadowPositionHClip(Attributes input) { float3 positionWS = TransformObjectToWorld(input.vertex.xyz); float3 normalWS = TransformObjectToWorldNormal(input.normal); #if _CASTING_PUNCTUAL_LIGHT_SHADOW float3 lightDirectionWS = normalize(_LightPosition - positionWS); #else float3 lightDirectionWS = _LightDirection; #endif float4 positionCS = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, lightDirectionWS)); #if UNITY_REVERSED_Z positionCS.z = min(positionCS.z, UNITY_NEAR_CLIP_VALUE); #else positionCS.z = max(positionCS.z, UNITY_NEAR_CLIP_VALUE); #endif return positionCS; } Varyings ShadowDepthPassVertex(Attributes input) { Varyings output = (Varyings)0; UNITY_SETUP_INSTANCE_ID(input); #if defined(DEPTH_ONLY_PASS) UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); #endif // Texture Coordinates output.pack0.xy.xy = input.texcoord0.xy * _BaseMap_ST.xy + _BaseMap_ST.zw; #if defined(DEPTH_ONLY_PASS) output.positionCS = TransformObjectToHClip(input.vertex.xyz); #if defined(DEPTH_NORMALS_PASS) float3 normalWS = TransformObjectToWorldNormal(input.normal); output.normalWS = normalWS; // already normalized in TransformObjectToWorldNormal #endif #elif defined(SHADOW_CASTER_PASS) output.positionCS = GetShadowPositionHClip(input); #else output.positionCS = float4(0,0,0,0); #endif return output; } half4 ShadowDepthPassFragment( Varyings input #if defined(DEPTH_NORMALS_PASS) && defined(_WRITE_RENDERING_LAYERS) #if UNITY_VERSION >= 60020000 , out uint outRenderingLayers : SV_Target1 #else , out float4 outRenderingLayers : SV_Target1 #endif #endif ) : SV_TARGET { #if defined(DEPTH_ONLY_PASS) UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); #endif // Shader Properties Sampling float4 __albedo = ( TCP2_TEX2D_SAMPLE(_BaseMap, _BaseMap, input.pack0.xy).rgba ); float4 __mainColor = ( _BaseColor.rgba ); float __alpha = ( __albedo.a * __mainColor.a ); half3 albedo = half3(1,1,1); half alpha = __alpha; half3 emission = half3(0,0,0); #if defined(DEPTH_NORMALS_PASS) #if defined(_WRITE_RENDERING_LAYERS) #if UNITY_VERSION >= 60020000 outRenderingLayers = EncodeMeshRenderingLayer(); #else outRenderingLayers = float4(EncodeMeshRenderingLayer(GetMeshRenderingLayer()), 0, 0, 0); #endif #endif #if defined(URP_12_OR_NEWER) return float4(input.normalWS.xyz, 0.0); #else return float4(PackNormalOctRectEncode(TransformWorldToViewDir(input.normalWS, true)), 0.0, 0.0); #endif #endif return 0; } #endif ENDHLSL Pass { Name "ShadowCaster" Tags { "LightMode" = "ShadowCaster" } ZWrite On ZTest LEqual HLSLPROGRAM // Required to compile gles 2.0 with standard srp library #pragma prefer_hlslcc gles #pragma exclude_renderers d3d11_9x #pragma target 2.0 // using simple #define doesn't work, we have to use this instead #pragma multi_compile SHADOW_CASTER_PASS //-------------------------------------- // GPU Instancing #pragma multi_compile_instancing #pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW #pragma vertex ShadowDepthPassVertex #pragma fragment ShadowDepthPassFragment #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl" ENDHLSL } Pass { Name "DepthOnly" Tags { "LightMode" = "DepthOnly" } ZWrite On ColorMask 0 HLSLPROGRAM // Required to compile gles 2.0 with standard srp library #pragma prefer_hlslcc gles #pragma exclude_renderers d3d11_9x #pragma target 2.0 //-------------------------------------- // GPU Instancing #pragma multi_compile_instancing // using simple #define doesn't work, we have to use this instead #pragma multi_compile DEPTH_ONLY_PASS #pragma vertex ShadowDepthPassVertex #pragma fragment ShadowDepthPassFragment ENDHLSL } Pass { Name "DepthNormals" Tags { "LightMode" = "DepthNormals" } ZWrite On HLSLPROGRAM #pragma exclude_renderers gles gles3 glcore #pragma target 2.0 #pragma multi_compile_instancing // using simple #define doesn't work, we have to use this instead #pragma multi_compile DEPTH_ONLY_PASS #pragma multi_compile DEPTH_NORMALS_PASS #pragma vertex ShadowDepthPassVertex #pragma fragment ShadowDepthPassFragment ENDHLSL } // Used for Baking GI. This pass is stripped from build. UsePass "Universal Render Pipeline/Lit/Meta" } FallBack "Hidden/InternalErrorShader" CustomEditor "ToonyColorsPro.ShaderGenerator.MaterialInspector_SG2" } /* TCP_DATA u config(ver:"2.9.20";unity:"6000.2.1f1";tmplt:"SG2_Template_URP";features:list["UNITY_5_4","UNITY_5_5","UNITY_5_6","UNITY_2017_1","UNITY_2018_1","UNITY_2018_2","UNITY_2018_3","UNITY_2019_1","UNITY_2019_2","UNITY_2019_3","UNITY_2019_4","UNITY_2020_1","UNITY_2021_1","UNITY_2021_2","UNITY_2022_2","UNITY_6000_2","UNITY_6000_1","UNITY_6000_0","BUMP","ENABLE_FORWARD_PLUS","ENABLE_META_PASS","ENABLE_DEPTH_NORMALS_PASS","TEMPLATE_LWRP"];flags:list[];flags_extra:dict[pragma_gpu_instancing=list[]];keywords:dict[RENDER_TYPE="Opaque",RampTextureDrawer="[TCP2Gradient]",RampTextureLabel="Ramp Texture",SHADER_TARGET="3.0"];shaderProperties:list[,sp(name:"Main Color";imps:list[imp_mp_color(def:RGBA(1, 1, 1, 1);hdr:False;cc:4;chan:"RGBA";prop:"_BaseColor";md:"[MainColor]";gbv:False;custom:False;refs:"";pnlock:False;guid:"6607a4eb-4ec3-4a2f-91f4-5e9d30c96b2c";op:Multiply;lbl:"Color";gpu_inst:False;dots_inst:False;locked:False;impl_index:0)];layers:list[];unlocked:list[];layer_blend:dict[];custom_blend:dict[];clones:dict[];isClone:False),,,,,,,,,,,,,,,,,,,,,,sp(name:"Depth Test";imps:list[imp_enum(value_type:0;value:7;enum_type:"ToonyColorsPro.ShaderGenerator.CompareFunction";guid:"cb90e6a6-ef1d-4afe-97a6-a628f305e8e9";op:Multiply;lbl:"Depth Test";gpu_inst:False;dots_inst:False;locked:False;impl_index:0)];layers:list[];unlocked:list[];layer_blend:dict[];custom_blend:dict[];clones:dict[];isClone:False),sp(name:"Face Culling";imps:list[imp_enum(value_type:0;value:2;enum_type:"ToonyColorsPro.ShaderGenerator.Culling";guid:"23b023a2-e593-418e-97f2-8408d65cee24";op:Multiply;lbl:"Face Culling";gpu_inst:False;dots_inst:False;locked:False;impl_index:0)];layers:list[];unlocked:list[];layer_blend:dict[];custom_blend:dict[];clones:dict[];isClone:False)];customTextures:list[];codeInjection:codeInjection(injectedFiles:list[];mark:False);matLayers:list[]) */ /* TCP_HASH b4abb9a88ff2f062c74f59baf3daf9e1 */