Shader "OF3D_Shader/ZZY_URP" { Properties { [Header(Surface Options)] [Space(8)] [Enum(UnityEngine.Rendering.CullMode)] _Cull ("Culling", Float) = 2 [ToggleOff(_RECEIVE_SHADOWS_OFF)] _ReceiveShadows ("Receive Shadows", Float) = 1.0 _SkinShadowBias (" Shadow Caster Bias", Range(.1, 1.0)) = 1.0 _SkinShadowSamplingBias (" Shadow Sampling Bias", Range(0, 0.05)) = 0 [Toggle(_ALPHATEST_ON)] _AlphaClip ("Alpha Clipping", Float) = 0.0 _Cutoff (" Threshold", Range(0.0, 1.0)) = 0.5 [Header(Surface Inputs)] [Space(8)] [NoScaleOffset] [MainTexture] _BaseMap ("Albedo (RGB) Alpha (A)", 2D) = "white" {} [MainColor] _BaseColor ("Color", Color) = (1,1,1,1) [Header(Lighting)] [Space(5)] // For some reason android did not like _SpecColor!? _Smoothness ("Smoothness", Range(0.0, 1.0)) = 0.5 _SpecularColor ("Specular", Color) = (0.2, 0.2, 0.2) _Metallic ("Metallic", Range(0.0, 2.0)) = 1.0 _Anisotropy ("GGX Anisotropy", Range(-1.0, 1.0)) = 0.0 _clothSpecIntensity ("Cloth Intensity", Range(0.0, 100.0)) = 1.0 [Space(5)] [Toggle(_NORMALMAP)] _ApplyNormal ("Enable Normal Map", Float) = 0.0 [NoScaleOffset] _BumpMap ("Normal Map", 2D) = "bump" {} _BumpScale ("Normal Scale", Float) = 1.0 [Toggle(_NORMALINDEPTHNORMALPASS)] _ApplyNormalDepthNormal ("Enable Normal in Depth Normal Pass", Float) = 1.0 _Bias ("Bias", Range(0.0, 8.0)) = 3.0 [Toggle]_VertexNormal ("Use Vertex Normal for Diffuse", Float) = 1 [Header(Skin Lighting)] [Space(8)] [NoScaleOffset] _SSSAOMap ("Skin Mask (R) Metallic (G) Smoothness (B) Occlusion (A)", 2D) = "white" {} _OcclusionStrength ("Occlusion Strength", Range(0.0, 4.0)) = 1.0 [Toggle] _SampleCurvature ("Sample Curvature", Float) = 0 _Curvature ("Curvature", Range(0.0, 1.0)) = 0.5 _SubsurfaceColor ("Subsurface Color", Color) = (1.0, 0.4, 0.25, 1.0) _TranslucencyPower ("Transmission Power", Range(0.0, 10.0)) = 7.0 _TranslucencyStrength ("Transmission Strength", Range(0.0, 1.0)) = 1.0 _ShadowStrength ("Shadow Strength", Range(0.0, 1.0)) = 0.7 _MaskByShadowStrength ("Mask by incoming Shadow Strength", Range(0.0, 1.0)) = 1.0 _Distortion ("Transmission Distortion", Range(0.0, 0.1)) = 0.01 _DecalTransmission ("Decal Transmission", Range(0.0, 1)) = 1 [Space(5)] [Toggle(_BACKSCATTER)] _EnableBackscatter ("Enable Ambient Back Scattering", Float) = 0 _Backscatter ("Ambient Back Scattering", Range(0.0, 8.0)) = 1 [Space(5)] _AmbientReflectionStrength ("Ambient Reflection Strength", Range(0.0, 1)) = 1 [Space(5)] [NoScaleOffset] _SkinLUT ("Skin LUT", 2D) = "white" {} [Header(Advanced)] [Space(8)] [ToggleOff] _SpecularHighlights ("Enable Specular Highlights", Float) = 1.0 [ToggleOff] _EnvironmentReflections ("Environment Reflections", Float) = 1.0 // Needed by the inspector [HideInInspector] _Culling ("Culling", Float) = 0.0 // Lightmapper and outline selection shader need _MainTex, _Color and _Cutoff [HideInInspector] _MainTex ("Albedo", 2D) = "white" {} [HideInInspector] _Color ("Color", Color) = (1,1,1,1) [HideInInspector] _Cutoff ("Alpha Cutoff", Range(0.0, 1.0)) = 0.0 [HideInInspector] _Surface("__surface", Float) = 0.0 } SubShader { Tags{ "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "UniversalMaterialType" = "Lit" "IgnoreProjector" = "True" "ShaderModel"="4.5" } LOD 300 // ForwardLit ----------------------------------------------------- Pass { Name "ForwardLit" // Needs "UniversalForwardOnly" to render in deferred Tags{"LightMode" = "UniversalForwardOnly"} ZWrite On Cull [_Cull] HLSLPROGRAM // #pragma exclude_renderers gles gles3 glcore #pragma target 4.5 // ------------------------------------- // ------------------------------------- // Material Keywords #define _SPECULAR_SETUP #pragma shader_feature_local _NORMALMAP #pragma shader_feature_local _ALPHATEST_ON // not per fragment! #pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF #pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF #pragma shader_feature_local _RECEIVE_SHADOWS_OFF // ------------------------------------- // Universal 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 _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX //#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS //#pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING //#pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION #pragma multi_compile_fragment _ _SHADOWS_SOFT #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION //#pragma multi_compile_fragment _ _LIGHT_LAYERS //#pragma multi_compile_fragment _ _LIGHT_COOKIES //#pragma multi_compile _ _FORWARD_PLUS //0428 added #pragma skip_variants _REFLECTION_PROBE_BLENDING _REFLECTION_PROBE_BOX_PROJECTION #pragma skip_variants _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS _ADDITIONAL_LIGHT_SHADOWS // 移除渲染层支持 #pragma skip_variants _LIGHT_LAYERS #pragma skip_variants _LIGHT_COOKIES #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" // ------------------------------------- // Unity defined keywords #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING #pragma multi_compile _ SHADOWS_SHADOWMASK #pragma multi_compile _ DIRLIGHTMAP_COMBINED //#pragma multi_compile_fragment _ LOD_FADE_CROSSFADE #pragma multi_compile_fog #pragma multi_compile_fragment _ DEBUG_DISPLAY //-------------------------------------- //GPU Instancing #pragma multi_compile_instancing //#pragma instancing_options renderinglayer //#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" // Include base inputs and all other needed "base" includes #include "Includes/URP Inputs.hlsl" #include "Includes/URP ForwardLit Pass.hlsl" #pragma vertex LitPassVertex #pragma fragment LitPassFragment ENDHLSL } // Shadows ----------------------------------------------------- Pass { Name "ShadowCaster" Tags{"LightMode" = "ShadowCaster"} ZWrite On ZTest LEqual ColorMask 0 Cull Back HLSLPROGRAM //#pragma exclude_renderers gles gles3 glcore #pragma target 4.5 // ------------------------------------- // Material Keywords //-------------------------------------- // GPU Instancing #pragma multi_compile_instancing #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" // ------------------------------------- // Universal Pipeline keywords // #pragma multi_compile_fragment _ LOD_FADE_CROSSFADE #pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW #pragma vertex ShadowPassVertex #pragma fragment ShadowPassFragment // Include base inputs and all other needed "base" includes #include "Includes/URP Inputs.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl" // #if defined(LOD_FADE_CROSSFADE) // #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl" // #endif struct Attributes { float3 positionOS : POSITION; float3 normalOS : NORMAL; UNITY_VERTEX_INPUT_INSTANCE_ID }; struct Varyings { float4 positionCS : SV_POSITION; }; // Shadow caster specific input float3 _LightDirection; float3 _LightPosition; Varyings ShadowPassVertex(Attributes input) { Varyings output = (Varyings)0; UNITY_SETUP_INSTANCE_ID(input); float3 positionWS = TransformObjectToWorld(input.positionOS.xyz); float3 normalWS = TransformObjectToWorldDir(input.normalOS); #if _CASTING_PUNCTUAL_LIGHT_SHADOW float3 lightDirectionWS = normalize(_LightPosition - positionWS); #else float3 lightDirectionWS = _LightDirection; #endif output.positionCS = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS * _SkinShadowBias, lightDirectionWS)); #if UNITY_REVERSED_Z output.positionCS.z = min(output.positionCS.z, UNITY_NEAR_CLIP_VALUE); #else output.positionCS.z = max(output.positionCS.z, UNITY_NEAR_CLIP_VALUE); #endif return output; } half4 ShadowPassFragment(Varyings input) : SV_TARGET { // #ifdef LOD_FADE_CROSSFADE // LODFadeCrossFade(input.positionCS); // #endif return 0; } // 1 2 3 4 5 6 //锐不可当 924 1395 1920 1296 5535 //奇正 726 1350 1813 1306 5195 //层数 4.5 9 13.5 ENDHLSL } // Depth Only ----------------------------------------------------- Pass { Name "DepthOnly" Tags{"LightMode" = "DepthOnly"} ZWrite On ColorMask R Cull Back HLSLPROGRAM // #pragma exclude_renderers gles gles3 glcore #pragma target 4.5 #pragma vertex DepthOnlyVertex #pragma fragment DepthOnlyFragment // ------------------------------------- // Material Keywords // ------------------------------------- // Unity defined keywords // #pragma multi_compile_fragment _ LOD_FADE_CROSSFADE //-------------------------------------- // GPU Instancing #pragma multi_compile_instancing #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" #include "Includes/URP Inputs.hlsl" // #if defined(LOD_FADE_CROSSFADE) // #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl" // #endif struct Attributes { float3 positionOS : POSITION; UNITY_VERTEX_INPUT_INSTANCE_ID }; struct Varyings { float4 positionCS : SV_POSITION; UNITY_VERTEX_OUTPUT_STEREO }; Varyings DepthOnlyVertex(Attributes input) { Varyings output = (Varyings)0; UNITY_SETUP_INSTANCE_ID(input); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); output.positionCS = TransformObjectToHClip(input.positionOS.xyz); return output; } half4 DepthOnlyFragment(Varyings input) : SV_TARGET { UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); // #ifdef LOD_FADE_CROSSFADE // LODFadeCrossFade(input.positionCS); // #endif return input.positionCS.z; } ENDHLSL } // // Depth Normals -------------------------------------------- // Pass // { // Name "DepthNormals" // Tags{"LightMode" = "DepthNormals"} // ZWrite On // Cull Back // HLSLPROGRAM // // #pragma exclude_renderers gles gles3 glcore // #pragma target 4.5 // #pragma vertex DepthNormalVertex // #pragma fragment DepthNormalFragment // // ------------------------------------- // // Material Keywords // #pragma shader_feature_local _NORMALINDEPTHNORMALPASS // // ------------------------------------- // // Unity defined keywords // //#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT // #pragma multi_compile_fragment _ LOD_FADE_CROSSFADE // //-------------------------------------- // // GPU Instancing // #pragma multi_compile_instancing // #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" // #include "Includes/URP Inputs.hlsl" // #if defined(LOD_FADE_CROSSFADE) // #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl" // #endif // // Structs // struct Attributes // { // float3 positionOS : POSITION; // float3 normalOS : NORMAL; // float4 tangentOS : TANGENT; // float2 texcoord : TEXCOORD0; // UNITY_VERTEX_INPUT_INSTANCE_ID // }; // struct Varyings // { // float4 positionCS : SV_POSITION; // float2 uv : TEXCOORD0; // half3 normalWS : TEXCOORD1; // half4 tangentWS : TEXCOORD2; // //UNITY_VERTEX_INPUT_INSTANCE_ID // UNITY_VERTEX_OUTPUT_STEREO // }; // Varyings DepthNormalVertex(Attributes input) // { // Varyings output = (Varyings)0; // UNITY_SETUP_INSTANCE_ID(input); // //UNITY_TRANSFER_INSTANCE_ID(input, output); // UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); // output.uv = input.texcoord; //TRANSFORM_TEX(input.texcoord, _BaseMap); // output.positionCS = TransformObjectToHClip(input.positionOS.xyz); // VertexNormalInputs normalInput = GetVertexNormalInputs(input.normalOS, input.tangentOS); // output.normalWS = normalInput.normalWS; // real sign = input.tangentOS.w * GetOddNegativeScale(); // output.tangentWS = half4(normalInput.tangentWS.xyz, sign); // return output; // } // void DepthNormalFragment( // Varyings input // , out half4 outNormalWS : SV_Target0 // /*#ifdef _WRITE_RENDERING_LAYERS // , out float4 outRenderingLayers : SV_Target1 // #endif */ // ) // { // //UNITY_SETUP_INSTANCE_ID(input); // UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); // #ifdef LOD_FADE_CROSSFADE // LODFadeCrossFade(input.positionCS); // #endif // half4 sampleNormal = SAMPLE_TEXTURE2D_BIAS(_BumpMap, sampler_BumpMap, input.uv, _Bias); // half3 normalTS = UnpackNormalScale(sampleNormal, _BumpScale); // float sgn = input.tangentWS.w; // float3 bitangent = sgn * cross(input.normalWS.xyz, input.tangentWS.xyz); // input.normalWS = TransformTangentToWorld(normalTS, half3x3(input.tangentWS.xyz, bitangent.xyz, input.normalWS.xyz)); // float3 normalWS = NormalizeNormalPerPixel(input.normalWS); // outNormalWS = half4(normalWS, 0.0); // /*#ifdef _WRITE_RENDERING_LAYERS // uint renderingLayers = GetMeshRenderingLayer(); // outRenderingLayers = float4(EncodeMeshRenderingLayer(renderingLayers), 0, 0, 0); // #endif */ // } // ENDHLSL // } // // Meta ----------------------------------------------------- // Pass // { // Name "Meta" // Tags{"LightMode" = "Meta"} // Cull Off // HLSLPROGRAM // // #pragma exclude_renderers gles gles3 glcore // #pragma target 4.5 // #pragma vertex UniversalVertexMeta // #pragma fragment UniversalFragmentMetaLit // #define _SPECULAR_SETUP // // First include all our custom stuff // #include "Includes/URP Inputs.hlsl" // // Fragment function // inline void InitializeStandardLitSurfaceData(float2 uv, out SurfaceData outSurfaceData) // { // half4 albedoAlpha = SampleAlbedoAlpha(uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap)); // outSurfaceData.alpha = 1; // outSurfaceData.albedo = albedoAlpha.rgb * _BaseColor.rgb; // outSurfaceData.metallic = 0; // outSurfaceData.specular = _SpecularColor.rgb; // outSurfaceData.smoothness = _Smoothness; // outSurfaceData.normalTS = half3(0,0,1); // outSurfaceData.occlusion = 1; // outSurfaceData.emission = 0; // outSurfaceData.clearCoatMask = 0; // outSurfaceData.clearCoatSmoothness = 0; // } // // Finally include the meta pass related stuff // #include "Packages/com.unity.render-pipelines.universal/Shaders/LitMetaPass.hlsl" // ENDHLSL // } } // -------------------------------------------------- FallBack "Hidden/InternalErrorShader" }