Shader "Custom/Standard-HueShift Metallic" { Properties { _Color ("Color", Color) = (1,1,1,1) _MainTex ("Albedo (RGB)", 2D) = "white" {} _Cutoff ("Cutoff", Range(0,1)) = 0 _MetallicGlossMap ("Metallic Gloss Map", 2D) = "white" {} _Metallic("Metallic",Range(0,1)) = 0 _Glossiness("Smoothness",Range(0,1)) = 0.5 [Toggle(USE_EMIT_UV)] _UseEmitUv("Use Emission UV Offsets", Float) = 0 _EmissionMap ("Emission", 2D) = "white" {} _EmissionColor ("Emission Color", Color) = (0,0,0,1) _EmissionIntensity("Emission Intensity", Range(0,1)) = 1 _BaseEmission("Base Emission", Range(0,1)) = 0 _BumpMap ("Bumpmap", 2D) = "bump" {} _BumpMapSecondary ("Secondary Bumpmap", 2D) = "bump" {} _BumpMapSecondaryIntensity ("Secondary Bumpmap Intensity", Range(0,1)) = 0 _BumpMapTertiary ("Tertiary Bumpmap", 2D) = "bump" {} _BumpMapTertiaryIntensity ("Tertiary Bumpmap Intensity", Range(0,1)) = 0 _Hue ("Hue", Range(0,6.28)) = 0 _EmissionHue ("Emission Hue", Range(0,6.28)) = 0 _NoiseMap ("Noise Texture",2D) = "white" {} _Dissolve ("Dissolve Progress", Range(0,1)) = 0 _OcclusionMap("AO", 2D) = "white" {} _OcclusionIntensity("Occlusion Intensity",Range(0,1)) = 1 } SubShader { Tags { "RenderType"="Opaque" } LOD 200 Cull Off CGPROGRAM // Physically based Standard lighting model, and enable shadows on all light types #pragma surface surf Standard fullforwardshadows addshadow nodirlightmap // Use shader model 3.0 target, to get nicer looking lighting #pragma target 3.0 #pragma shader_feature USE_EMIT_UV sampler2D _MainTex; sampler2D _MetallicGlossMap; sampler2D _EmissionMap; sampler2D _BumpMap; sampler2D _BumpMapSecondary; sampler2D _BumpMapTertiary; sampler2D _NoiseMap; sampler2D _OcclusionMap; struct Input { float2 uv_MainTex; float2 uv_NoiseMap; float2 uv_EmissionMap; }; half _Specular; half _Glossiness; half _Metallic; half _BumpMapSecondaryIntensity; half _BumpMapTertiaryIntensity; fixed4 _Color; fixed4 _EmissionColor; fixed _Hue; fixed _EmissionHue; fixed _EmissionIntensity; fixed _Dissolve; fixed _OcclusionIntensity; fixed _BaseEmission; // #pragma instancing_options assumeuniformscaling UNITY_INSTANCING_BUFFER_START(Props) // put more per-instance properties here UNITY_INSTANCING_BUFFER_END(Props) float4 ApplyHue(float4 col, float hueAdjust) { const float3 k = float3(0.57735, 0.57735, 0.57735); half cosAngle = cos(hueAdjust); return float4(col.rgb * cosAngle + cross(k, col.rgb) * sin(hueAdjust) + k * dot(k, col.rgb) * (1.0 - cosAngle),col.a); } float3 BlendNormalRNM(float3 n1, float3 n2) { float3 t = n1.xyz + float3(0.0, 0.0, 1.0); float3 u = n2.xyz * float3(-1.0, -1.0, 1.0); float3 r = (t / t.z) * dot(t, u) - u; return r; } float _Cutoff; void surf (Input IN, inout SurfaceOutputStandard o) { #ifdef USE_EMIT_UV float2 uv = IN.uv_EmissionMap; #else float2 uv = IN.uv_MainTex; #endif _Dissolve = (_Dissolve - 0.02) * 1.04; float noise = tex2D(_NoiseMap, IN.uv_NoiseMap).r; // Albedo comes from a texture tinted by color float4 c = ApplyHue(tex2D (_MainTex, uv) * _Color,_Hue); if (noise < _Dissolve || c.a < _Cutoff) { discard; } fixed4 metalMap = tex2D (_MetallicGlossMap, uv); float3 normal = UnpackNormal (tex2D (_BumpMap, uv)); float3 secondaryNormal = UnpackScaleNormal (tex2D (_BumpMapSecondary, uv), _BumpMapSecondaryIntensity); float3 tertiaryNormal = UnpackScaleNormal (tex2D (_BumpMapTertiary, uv), _BumpMapTertiaryIntensity); o.Normal = BlendNormalRNM(BlendNormalRNM(normal,secondaryNormal),tertiaryNormal); if (noise < _Dissolve + 0.02) o.Emission = _EmissionColor; o.Albedo = c.rgb* lerp(1,tex2D(_OcclusionMap, uv).rgb, _OcclusionIntensity); o.Emission = ApplyHue(tex2D(_EmissionMap,uv) * _EmissionColor,_EmissionHue)* _EmissionIntensity + _BaseEmission*o.Albedo; // Metallic and smoothness come from slider variables o.Metallic = metalMap.r*_Metallic; o.Smoothness = metalMap.a*_Glossiness; o.Alpha = c.a; } ENDCG } FallBack "Diffuse" }