//角色卡通渲染 高级（半透明）
Shader "URP/Character/ToonCharacter_Hair" 
{
	Properties
	{
		[Enum(OFF, 0, FRONT, 1, BACK, 2)] _Cull ("Cull Mode：裁剪", int) = 2
		[Tex(_, _Color)]_MainTex("Texture", 2D) = "white" {}
		[HideInInspector]_Color("Main Color", Color) = (1,1,1,1)
		// [Tex(_, _NORMALMAP)]_BumpMap("Normalmap", 2D) = "white" {}
		// [HideInInspector][Toggle(_NORMALMAP)]_NORMALMAP("Normal",Float) = 0
        [HideInInspector] _Surface("__surface", Float) = 0.0
        [HideInInspector] _AlphaClip("__clip", Float) = 0.0
        [HideInInspector] _SrcBlend("__src", Float) = 1.0
        [HideInInspector] _DstBlend("__dst", Float) = 0.0
        //[HideInInspector] _ZWrite("__zw", Float) = 1.0
        [HideInInspector] _Cull("__cull", Float) = 2.0
		[HideInInspector]_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
		[HideInInspector]_MainAlpha("MainAlpha", Range(0.0, 1.0)) = 1
		//_shadowFalloff("shadow Falloff", Range(0,1)) = 1
		
		[ToggleOff]_Receive_Shadows("Shadows:接收阴影", Float) = 1.0

		[Title(_,Ramp)]
		[Tex(_,_RampColor)]_RampTex("Ramp", 2D) = "white"{}
		[HideInInspector]_RampColor("Ramp Color", Color) = (1,1,1,1)
		_RampNum("RampNum", Range(1,20)) = 10

		[Title(_,LightMask)]
		[Tex(_,_LightMask_Off)]_LightMaskTex("LightMask:R:闭塞A:RampID(G:金属B:高亮)", 2D) = "black" {}
		[HideInInspector][ToggleOff]_LightMask_Off ("LightMask", float) = 0
		_LightMaskParam("LightMask:范围", Range(-1.0,1.0)) = 0.7
		_LightMaskBackParam("LightMask:暗部闭塞增强", Range(0.0,1.0)) = 0.7

		[Title(_,Outline)]
		[KWEnum(_, Uv3, _, Tangent, _TANGENT)]
		_OutlineMode("Outline Mode",Float) = 0
		[Sub(_)]_OutlineColor("Outline Color", Color) = (0.3,0.3,0.3,1)
		_Outline("Outline Width", range(0,20)) = 0.24
		_OutlineStrength("Outline Strength", range(0,5)) = 0.6
		//[Toggle(_Tangent)]_Tangent("Use Tangent",Float) = 0
		
		[Main(HighLight, _, 2)]
		_HL("HighLight", float) = 0
		[Sub(HighLight)]_HighLightColor("HighLight Color", Color) = (1,1,1,1)
		[Sub(HighLight)]_HighLight("HighLightStrength",range(0,2)) = 0.9		// 高光范围
		[Sub(HighLight)]_HLightLength ("HLight Length", Range(0.1, 1.5)) = 1.5
        [Sub(HighLight)]_HLightFeather ("HLight Feather", Range(0, 1)) = 1
		
		[Main(Rim)]
		_Rim("Rim", float) = 0
		[HideInInspector][HDR]_RimColor("Rim Color", color) = (0,0,0,1)
		[HideInInspector]_RimWidth("Rim Width", Range(0,1)) = 0
		[Sub(Rim)][HDR]_BackRimColor("Back Rim Color", color) = (0,0,0,1)
		[Sub(Rim)]_BackRimMax("Back Rim Max", Range(0,1)) = 1
		[Sub(Rim)]_BackRimMin ("Back Rim Min", Range(0,1)) = 1

		[Main(Emission)]
		_Illumin_On ("Emission", float) = 0
		[Sub(Emission)]_TimeScale ("Time Scale", Float ) = 1
		[Sub(Emission)]_IlluminStrength("Emission Strength" , Range(0,30)) = 0
		[Sub(Emission)][HDR]_IlluminColor("Emission Color", Color) = (1,1,1,1)

		[HideInInspector][Toggle(FLASH_SWITCH)]_FLASH_SWITCH("FLASH SWITCH", Float) = 0
		[HideInInspector]_FlashTex("FlashTex", 2D) = "white" {}
		[HideInInspector]_FlashFactor("FlashFactor", Vector) = (0, -2, 1, 1)
		[HideInInspector]_FlashStrength("FlashStrength", Range(0, 5)) = 1
		[HideInInspector]_DissolveTex("DissolveTex", 2D) = "white" {}
		[HideInInspector]_DissolveFactor("DissolveFactor",Range(0, 1)) = 0
		//_QueueOffset("Queue offset", Float) = 0.0
			
	}
	SubShader
	{
		Tags
		{
			"IgnoreProjector" = "true"
			"RenderType"="Opaque"
			"Queue"="Geometry"
		}

		pass
		{
			Tags{ "LightMode" = "UniversalForward" }
			//Blend[_SrcBlend][_DstBlend]
            //ZWrite[_ZWrite]
            Cull[_Cull]
			HLSLPROGRAM
			#pragma vertex BasicVert
			#pragma fragment BasicFrag
			#define HAIR_LIGHT 1
			#include "CharacterPassForward.hlsl"

			#pragma target 3.0 
			//#pragma shader_feature _NORMALMAP
			//#pragma shader_feature USE_FACE_LIGHT
			//#pragma shader_feature _ALPHATEST_ON
			#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
			#pragma shader_feature _RECEIVE_SHADOWS_OFF
			#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
			#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
			#pragma multi_compile _ _SHADOWS_SOFT
			#pragma shader_feature FLASH_SWITCH
			#pragma multi_compile DISSOLVE
			ENDHLSL
		}
		UsePass "URP/Character/ToonCharacter_Base/CHAR_OUTLINE"
		UsePass "URP/Character/ToonCharacter_Base/DepthOnly"
		UsePass "URP/Character/ToonCharacter_Base/ShadowCaster"	
	}
	CustomEditor "FZDL.ShaderDrawer.LWGUI"
	//CustomEditor "Valkyrie.PBRToonShaderGUI"
}