//角色卡通渲染 基本（不透明）
Shader "HiddenURP/Character/Basic"
{
	Properties
	{
		_Color("Main Color", Color) = (1,1,1,1)
		_ColorParam("Main ColorParam", Color) = (1,1,1,1)
		_MainTex("Texture", 2D) = "white" {}

		_MaskTex("Mask", 2D) = "black" {}
		_LightMaskTex("LightMask", 2D) = "black" {}
		_LightMaskParam("_LightMaskParam", Range(0.0,1.0)) = 0.7
		_LightMaskBackParam("_LightMaskBackParam", Range(0.0,1.0)) = 0.7
		_RampTex("Ramp", 2D) = "white"{}
		_RampColor("Ramp Color", Color) = (1,1,1,1)

		_HighLight("HighLight",range(0,1)) = 0.9		// 高光范围
		_HighLightColor("HighLight Color", Color) = (1,1,1,1)
		_HighLightStrength("HighLightStrength", range(0,1000)) = 5

		_BrightnessFactor("MinBrightness", range(0, 1)) = 0

		_LightInfo("LightInfo", Vector) = (0.9, -1, 0.5, 0.005)
		_LightColor("LightColor",color) = (1,1,1,1)

		_BrightnessRatio("Brightness Ratio", range(0,10)) = 0
		_BrightnessIncrease("Brightness Increase", range(0,10)) = 4

		_FlashTex("FlashTex", 2D) = "black" {}
		_FlashFactor("FlashFactor", Vector) = (0, -2, 1, 1)
		_FlashMixedColor("FlashMixedColor",Color) = (0.4,0.2,0,1)
		_FlashStrength("FlashStrength", Range(0, 5)) = 1
		_FlashMixedColorAdd("FlashMixedColorAdd",Color) = (0.4,0.2,0,1)
		_FlashStrengthAdd("FlashStrengthAdd", Range(0, 5)) = 1
		_FlashSpeed("FlashSpeed", Range(0, 5)) = 0.2

		_ShadowTex("Shadow (RGB) Trans (A)", 2D) = "white" {}
		//_DirX("DirX", Range(0,5)) = 0.5
		//_DirY("DirY", Range(0,5)) = 0.5
		_Speed("Speed", Range(-1,1)) = 0.1
		_ShadowAlphaRatio("ShadowAlphaRatio", Range(0.5,1.5)) = 1

		_Transparency("Transparency", range(0,1)) = 1
		[Toggle]_NewRamp("NewRamp", Range(0,1)) = 0

		[Toggle]_IsColoration("Is Coloration", Range(0,1)) = 0
		_Coloration("Coloration Color", color) = (1.1,1,1)

		_DissolveTex("DissolveTex", 2D) = "white" {}
		_DissolveFactor("DissolveFactor",Range(0, 1)) = 0
	}
	SubShader
	{
		Tags
		{
			"IgnoreProjector" = "true"
			"RenderType"="Opaque"
			"Queue"="Geometry"
		}
		
		pass
		{
			Name "CHAR_BASIC"
			Tags{ "LightMode" = "UniversalForward" }
			Lighting Off
			Blend[_SrcBlend][_DstBlend]
            ZWrite[_ZWrite]
            Cull[_Cull]
			//Blend SrcAlpha OneMinusSrcAlpha
			ColorMask RGBA
			HLSLPROGRAM
			#pragma vertex BasicVert
			#pragma fragment BasicFrag
			#pragma multi_compile_instancing
			#pragma multi_compile_local _ _GIANT_BAKED_ANIMATION_ON
			#include "HLSLToon.hlsl"

			#pragma target 3.0 
			//#pragma shader_feature _NORMALMAP
			#pragma shader_feature _Change
			#pragma shader_feature _ALPHATEST_ON
			#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
			#pragma shader_feature Receive_Shadows
			#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
			#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
			#pragma multi_compile _ _SHADOWS_SOFT
			#pragma multi_compile FLASH_SWITCH
			#pragma multi_compile DISSOLVE
			//#pragma shader_feature _USE_Ramp_Num4
			ENDHLSL
		}pass
		{
			Name "CHAR_BASIC_Foliage"
			Tags{ "LightMode" = "FoliageForward" }
			Lighting Off
			Blend[_SrcBlend][_DstBlend]
            ZWrite[_ZWrite]
            Cull[_Cull]
			//Blend SrcAlpha OneMinusSrcAlpha
			ColorMask RGBA
			HLSLPROGRAM
			#pragma vertex BasicVert
			#pragma fragment BasicFrag
			#include "HLSLToon.hlsl"

			#pragma target 3.0 
			#pragma shader_feature _Change
			#pragma shader_feature _ALPHATEST_ON
			#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
			#pragma shader_feature Receive_Shadows
			#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
			#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
			#pragma multi_compile _ _SHADOWS_SOFT
			#pragma multi_compile FLASH_SWITCH
			#pragma multi_compile DISSOLVE
			//#pragma shader_feature _USE_Ramp_Num4
			ENDHLSL
		}
		pass
		{
			Name "CHAR_PbrToon"
			Tags{ "LightMode" = "UniversalForward" }
			Lighting Off
			Blend[_SrcBlend][_DstBlend]
            ZWrite[_ZWrite]
            Cull[_Cull]
			//Blend SrcAlpha OneMinusSrcAlpha
			ColorMask RGBA
			HLSLPROGRAM
			#pragma vertex BasicVert
			#pragma fragment BasicFrag
			#include "HLSLPbrToon.hlsl"

			#pragma target 3.0 
			#pragma shader_feature _NORMALMAP
			#pragma shader_feature _Change
			#pragma shader_feature _ALPHATEST_ON
			#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
			#pragma shader_feature Receive_Shadows
			#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
			#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
			#pragma multi_compile _ _SHADOWS_SOFT
			#pragma multi_compile FLASH_SWITCH
			#pragma multi_compile DISSOLVE
			#pragma shader_feature _ENVIRONMENTREFLECTIONS_OFF
			//#define _ENVIRONMENTREFLECTIONS_OFF 1
			ENDHLSL
		}
		Pass
            {
                Name "a"
                Tags{ "LightMode" = "ShaderTag3" }
                //Cull Off
                Lighting Off
                ZWrite Off
                Blend SrcAlpha  OneMinusSrcAlpha
                ColorMask A
                CGPROGRAM
                #pragma vertex vert
                #pragma fragment frag
                //#pragma multi_compile_fog
				#include "UnityCG.cginc"
				uniform half4 _MainLightColor;
                float _BloomFactor;

            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                float4 vertex : SV_POSITION;
            };

            sampler2D _MainTex;
            float4 _MainTex_ST;

            v2f vert(appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = TRANSFORM_TEX(v.uv, _MainTex);
                return o;
            }

            fixed4 frag(v2f i) : SV_Target
            { 
            fixed4 col = tex2D(_MainTex, i.uv);
            col.w = col.w * _BloomFactor + 0.5;
			col.rgb *= _MainLightColor.w;
            return col;
        }
        ENDCG
    }
	}
	CustomEditor "Valkyrie.BasicShaderGUI"
}