Shader "New_hair" { Properties { [Header(BaseInfo)] [Space(8)] [Enum(UnityEngine.Rendering.CullMode)] _Cull ("Culling", Float) = 0 [Toggle(_ENABLEVFACE)] _EnableVest ("Black Vest", Float) = 0 [Enum(Off,0,On,1)]_Coverage ("Alpha To Coverage", Float) = 1 _BaseMap("Albedo (RGB) Alpha (A)", 2D) = "white" {} _BaseColor ("Base Color", Color) = (1,1,1,1) _BumpMap ("Normal Map", 2D) = "bump" {} _BumpScale ("Normal Str", Float) = 1.0 [NoScaleOffset] _MaskMap ("Shift(B) Occ(G)", 2D) = "white" {} _SpecColor ("Specular", Color) = (0.2, 0.2, 0.2) _Smoothness ("Smoothness", Range(0.0, 1.0)) = 1 [KeywordEnum(Bitangent,Tangent)] _StrandDir ("Connect Direction", Float) = 0 _SpecularShift ("Specular Shift", Range(-1.0, 1.0)) = 0.1 [HDR] _SpecularTint ("Specular Tint", Color) = (1, 1, 1, 1) _SpecularExponent ("Smoothness", Range(0.0, 1)) = .85 [Toggle(_RIMLIGHTING)] _Rim ("Rim Lighting", Float) = 0 [HDR] _RimColor ("Rim Color", Color) = (0.5,0.5,0.5,1) _RimPower ("Rim Power", Float) = 2 } SubShader { Tags { "RenderType" = "Opaque" } LOD 100 Pass { Name "ForwardLit" Tags{"LightMode" = "UniversalForward"} Stencil { Ref [_Stencil] ReadMask [_ReadMask] WriteMask [_WriteMask] Comp [_StencilComp] Pass [_StencilOp] Fail [_StencilFail] ZFail [_StencilZFail] } ZWrite On Cull [_Cull] AlphaToMask [_Coverage] HLSLPROGRAM // Required to compile gles 2.0 with standard SRP library #pragma prefer_hlslcc gles #pragma exclude_renderers d3d11_9x #pragma target 2.0 // ------------------------------------- // Material Keywords #define _SPECULAR_SETUP 1 #define _ALPHATEST_ON 1 #pragma shader_feature_local _ENABLEVFACE #pragma shader_feature_local_fragment _STRANDDIR_BITANGENT #pragma shader_feature_local_fragment _MASKMAP #pragma shader_feature_local_fragment _SECONDARYLOBE #pragma shader_feature_local _NORMALMAP #pragma shader_feature_local_fragment _RIMLIGHTING //#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 #pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS #pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS #pragma multi_compile_fragment _ _SHADOWS_SOFT #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING #pragma multi_compile _ SHADOWS_SHADOWMASK // ------------------------------------- // Unity defined keywords #pragma multi_compile _ DIRLIGHTMAP_COMBINED #pragma multi_compile _ LIGHTMAP_ON #pragma multi_compile_fog //-------------------------------------- // GPU Instancing #pragma multi_compile_instancing // #pragma multi_compile _ DOTS_INSTANCING_ON // needs shader target 4.5 // Include base inputs and all other needed "base" includes #include "Includes/Lux URP Hair Inputs.hlsl" #include "Includes/Lux URP Hair Core.hlsl" #pragma vertex LitPassVertex #pragma fragment LitPassFragment ENDHLSL } Pass { Name "ShadowCaster" Tags{"LightMode" = "ShadowCaster"} ZWrite On ZTest LEqual ColorMask 0 Cull [_ShadowCull] HLSLPROGRAM // Required to compile gles 2.0 with standard srp library #pragma prefer_hlslcc gles #pragma exclude_renderers d3d11_9x #pragma target 2.0 // Material Keywords #define _ALPHATEST_ON 1 // GPU Instancing #pragma multi_compile_instancing // #pragma multi_compile _ DOTS_INSTANCING_ON // needs shader target 4.5 #pragma vertex ShadowPassVertex #pragma fragment ShadowPassFragment // Include base inputs and all other needed "base" includes #include "Includes/Lux URP Hair Inputs.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl" // Shadow caster specific input float3 _LightDirection; VertexOutput ShadowPassVertex(VertexInput input) { VertexOutput output = (VertexOutput)0; UNITY_SETUP_INSTANCE_ID(input); UNITY_TRANSFER_INSTANCE_ID(input, output); float3 positionWS = TransformObjectToWorld(input.positionOS.xyz); float3 normalWS = TransformObjectToWorldDir(input.normalOS); output.uv = input.texcoord; output.positionCS = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, _LightDirection)); #if UNITY_REVERSED_Z output.positionCS.z = min(output.positionCS.z, output.positionCS.w * UNITY_NEAR_CLIP_VALUE); #else output.positionCS.z = max(output.positionCS.z, output.positionCS.w * UNITY_NEAR_CLIP_VALUE); #endif return output; } half4 ShadowPassFragment(VertexOutput input) : SV_TARGET { UNITY_SETUP_INSTANCE_ID(input); UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); half alpha = SampleAlbedoAlpha(input.uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap)).a; alpha *= _BaseColor.a; clip(alpha - _Cutoff); return 0; } ENDHLSL } Pass { Tags{"LightMode" = "DepthOnly"} ZWrite On ColorMask 0 Cull [_Cull] HLSLPROGRAM // Required to compile gles 2.0 with standard srp library #pragma prefer_hlslcc gles #pragma exclude_renderers d3d11_9x #pragma target 2.0 #define _ALPHATEST_ON 1 #pragma vertex DepthOnlyVertex #pragma fragment DepthOnlyFragment // Material Keywords // GPU Instancing #pragma multi_compile_instancing // #pragma multi_compile _ DOTS_INSTANCING_ON // needs shader target 4.5 #define DEPTHONLYPASS #include "Includes/Lux URP Hair Inputs.hlsl" VertexOutput DepthOnlyVertex(VertexInput input) { VertexOutput output = (VertexOutput)0; UNITY_SETUP_INSTANCE_ID(input); UNITY_TRANSFER_INSTANCE_ID(input, output); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); output.positionCS = TransformObjectToHClip(input.positionOS.xyz); output.uv = input.texcoord; return output; } half4 DepthOnlyFragment(VertexOutput input) : SV_TARGET { UNITY_SETUP_INSTANCE_ID(input); UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); half alpha = SampleAlbedoAlpha(input.uv.xy, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap)).a; alpha *= _BaseColor.a; clip(alpha - _Cutoff); return 0; } ENDHLSL } // Depth Normal --------------------------------------------- // This pass is used when drawing to a _CameraNormalsTexture texture Pass { Name "DepthNormals" Tags{"LightMode" = "DepthNormals"} ZWrite On Cull[_Cull] HLSLPROGRAM // Required to compile gles 2.0 with standard SRP library #pragma prefer_hlslcc gles #pragma exclude_renderers d3d11_9x #pragma target 2.0 #pragma vertex DepthNormalsVertex #pragma fragment DepthNormalsFragment // ------------------------------------- // Material Keywords #pragma shader_feature_local _NORMALMAP #define _ALPHATEST_ON 1 //-------------------------------------- // GPU Instancing #pragma multi_compile_instancing // #pragma multi_compile _ DOTS_INSTANCING_ON // needs shader target 4.5 //#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" #include "Includes/Lux URP Hair Inputs.hlsl" #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthNormalsPass.hlsl" ENDHLSL } Pass { Tags{"LightMode" = "Meta"} Cull Off HLSLPROGRAM // Required to compile gles 2.0 with standard srp library #pragma prefer_hlslcc gles #pragma vertex UniversalVertexMeta #pragma fragment UniversalFragmentMeta #define _SPECULAR_SETUP // First include all our custom stuff #include "Includes/Lux URP Hair Inputs.hlsl" // Fragment shader and functions inline void InitializeStandardLitSurfaceData(float2 uv, out SurfaceData outSurfaceData) { half4 albedoAlpha = SampleAlbedoAlpha(uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap)); outSurfaceData.alpha = 1; outSurfaceData.albedo = albedoAlpha.rgb; outSurfaceData.metallic = 0; outSurfaceData.specular = _SpecColor.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 } } CustomEditor "LuxURPUniversalCustomShaderGUI" FallBack "Hidden/InternalErrorShader" }