Why render pipeline converter think my custom urp shader to be upgrade?


Before the start, I’m korean junior developer. Sorry for bad English.

Now I’m trying to convert our project builtin to URP.

There are many legacy Shader that cant change automaticaly. So, I try to upgrade shaders by my hand.

I try very hard, finally I Sucess upgrade that texture.

No Error, SRP Batcher compatible, and Look good in Scene.

But, When I initialize Render Pipeline Converter’s material upgrades.

That converter think my new shader need to upgrade. I don’t know why…

I asked to gpt. but didn’t work. Please Help~~

Shader "Universal Render Pipeline/Custom/OPCD Dual Texture Ext_URP"
{
	Properties
	{
		_OPCD_OverallColor("Overall Color", Color) = (1,1,1,1)
		_DiffuseColor("Diffuse Color", Color) = (1,1,1,0)
		_DiffuseTiling("Diffuse Tiling", Float) = 0
		[NoScaleOffset]_DiffuseTexture("Diffuse Texture", 2D) = "white" {}
		_DetailTiling("Detail Tiling", Float) = 1
		[NoScaleOffset]_DetailTexture("Detail Texture", 2D) = "white" {}
		_NormalTiling("Normal Tiling", Float) = 0
		[NoScaleOffset]_Normal("Normal", 2D) = "bump" {}
		_NormalStrength("Normal Strength", Range( 0 , 1)) = 0
		_SurfaceTexTiling("Surface Tex Tiling", Float) = 0
		[NoScaleOffset]_SurfaceTexture("Surface Texture", 2D) = "white" {}
		_SurfaceTexOpacity("Surface Tex Opacity", Range(0 , 1)) = 0
		_BlendDistance("Blend Distance",Float) = 30
		_RotationDegrees("Texture Rotation Degrees", Float) = 0

		/////////////////////////////////////////////////////////////////////////
		[MaterialToggle]_USE_VertexColor_r("Use Vertex Color_r", Float) = 0
		_VertexColorRange_r("Vertex Color Range_r", Range(0 , 1)) = 0
		_OPCD_OverallColor_r("Overall Color_r", Color) = (1,1,1,1)
		_DiffuseColor_r("Diffuse Color_r", Color) = (1,1,1,0)
		_DiffuseTiling_r("Diffuse Tiling_r", Float) = 0
		[NoScaleOffset]_DiffuseTexture_r("Diffuse Texture_r", 2D) = "white" {}
		_DetailTiling_r("Detail Tiling_r", Float) = 1
		[NoScaleOffset]_DetailTexture_r("Detail Texture_r", 2D) = "white" {}
		_NormalTiling_r("Normal Tiling_r", Float) = 0
		[NoScaleOffset]_Normal_r("Normal_r", 2D) = "bump" {}
		_NormalStrength_r("Normal Strength_r", Range(0 , 1)) = 0
		_SurfaceTexTiling_r("Surface Tex Tiling_r", Float) = 0
		[NoScaleOffset]_SurfaceTexture_r("Surface Texture_r", 2D) = "white" {}
		_SurfaceTexOpacity_r("Surface Tex Opacity_r", Range(0 , 1)) = 0

		_RotationDegrees_r("Texture Rotation Degrees_r", Float) = 0

		////////////////////////////////////////////////////////////////////////
		[MaterialToggle]_USE_VertexColor_g("Use Vertex Color_g", Float) = 0
		_VertexColorRange_g("Vertex Color Range_g", Range(0 , 1)) = 0
		_OPCD_OverallColor_g("Overall Color_g", Color) = (1,1,1,1)
		_DiffuseColor_g("Diffuse Color_g", Color) = (1,1,1,0)
		_DiffuseTiling_g("Diffuse Tiling_g", Float) = 0
		[NoScaleOffset]_DiffuseTexture_g("Diffuse Texture_g", 2D) = "white" {}
		_DetailTiling_g("Detail Tiling_g", Float) = 1
		[NoScaleOffset]_DetailTexture_g("Detail Texture_g", 2D) = "white" {}
		_NormalTiling_g("Normal Tiling_g", Float) = 0
		[NoScaleOffset]_Normal_g("Normal_g", 2D) = "bump" {}
		_NormalStrength_g("Normal Strength_g", Range(0 , 1)) = 0
		_SurfaceTexTiling_g("Surface Tex Tiling_g", Float) = 0
		[NoScaleOffset]_SurfaceTexture_g("Surface Texture_g", 2D) = "white" {}
		_SurfaceTexOpacity_g("Surface Tex Opacity_g", Range(0 , 1)) = 0

		_RotationDegrees_g("Texture Rotation Degrees_g", Float) = 0

		////////////////////////////////////////////////////////////////////////
		[MaterialToggle]_USE_VertexColor_b("Use Vertex Color_b", Float) = 0
		_VertexColorRange_b("Vertex Color Range_b", Range(0 , 1)) = 0
		_OPCD_OverallColor_b("Overall Color_b", Color) = (1,1,1,1)
		_DiffuseColor_b("Diffuse Color_b", Color) = (1,1,1,0)
		_DiffuseTiling_b("Diffuse Tiling_b", Float) = 0
		[NoScaleOffset]_DiffuseTexture_b("Diffuse Texture_b", 2D) = "white" {}
		_DetailTiling_b("Detail Tiling_b", Float) = 1
		[NoScaleOffset]_DetailTexture_b("Detail Texture_b", 2D) = "white" {}
		_NormalTiling_b("Normal Tiling_b", Float) = 0
		[NoScaleOffset]_Normal_b("Normal_b", 2D) = "bump" {}
		_NormalStrength_b("Normal Strength_b", Range(0 , 1)) = 0
		_SurfaceTexTiling_b("Surface Tex Tiling_b", Float) = 0
		[NoScaleOffset]_SurfaceTexture_b("Surface Texture_b", 2D) = "white" {}
		_SurfaceTexOpacity_b("Surface Tex Opacity_b", Range(0 , 1)) = 0

		_RotationDegrees_b("Texture Rotation Degrees_b", Float) = 0



		[HideInInspector] __dirty("", Int) = 1

	}

	//CustomEditor "OPCD_Dual_Texture_CustomEditor"

	SubShader
	{
		Tags{ "RenderType" = "Opaque"  "Queue" = "Geometry+0" "RenderPipeline" = "UniversalPipeline"}
        ZWrite On
		Cull Back
        Pass
        {
            Name "ForwardLit"
            Tags{"LightMode" = "UniversalForward" "RenderPipeline"="UniversalPipeline" }
            ZWrite On
            Cull Back

            HLSLPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma target 3.5
            #pragma multi_compile_fog
            #pragma multi_compile _ _MAIN_LIGHT_SHADOWS
            #pragma multi_compile _ _ADDITIONAL_LIGHTS

            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl"
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl"
            #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl"

            
            CBUFFER_START(UnityPerMaterial)
		    sampler2D _Normal;
		    float _NormalTiling;
		    float _NormalStrength;
		    float4 _OPCD_OverallColor;
		    sampler2D _DetailTexture;
		    float _DetailTiling;
		    float4 _DiffuseColor;
		    sampler2D _DiffuseTexture;
		    float _DiffuseTiling;
		    sampler2D _SurfaceTexture;
		    float _SurfaceTexTiling;
		    float _SurfaceTexOpacity;

		    float _USE_VertexColor_r;
		    float _VertexColorRange_r;
		    sampler2D _Normal_r;
		    float _NormalTiling_r;
		    float _NormalStrength_r;
		    float4 _OPCD_OverallColor_r;
		    sampler2D _DetailTexture_r;
		    float _DetailTiling_r;
		    float4 _DiffuseColor_r;
		    sampler2D _DiffuseTexture_r;
		    float _DiffuseTiling_r;
		    sampler2D _SurfaceTexture_r;
		    float _SurfaceTexTiling_r;
		    float _SurfaceTexOpacity_r;

		    float _USE_VertexColor_g;
		    float _VertexColorRange_g;
		    sampler2D _Normal_g;
		    float _NormalTiling_g;
		    float _NormalStrength_g;
		    float4 _OPCD_OverallColor_g;
		    sampler2D _DetailTexture_g;
		    float _DetailTiling_g;
		    float4 _DiffuseColor_g;
		    sampler2D _DiffuseTexture_g;
		    float _DiffuseTiling_g;
		    sampler2D _SurfaceTexture_g;
		    float _SurfaceTexTiling_g;
		    float _SurfaceTexOpacity_g;

		    float _USE_VertexColor_b;
		    float _VertexColorRange_b;
		    sampler2D _Normal_b;
		    float _NormalTiling_b;
		    float _NormalStrength_b;
		    float4 _OPCD_OverallColor_b;
		    sampler2D _DetailTexture_b;
		    float _DetailTiling_b;
		    float4 _DiffuseColor_b;
		    sampler2D _DiffuseTexture_b;
		    float _DiffuseTiling_b;
		    sampler2D _SurfaceTexture_b;
		    float _SurfaceTexTiling_b;
		    float _SurfaceTexOpacity_b;

		    float _BlendDistance;

		    /////////////////////////////////////
		    //
		    // kimhs20 2022.09.30 rotate texture
		    //
		    float _RotationDegrees;
		    float _RotationDegrees_r;
		    float _RotationDegrees_g;
		    float _RotationDegrees_b;

		    //uniform sampler2D _EdgeTexture;
		    //uniform float _EdgeTexOpacity;
            CBUFFER_END

		    inline float2 RotTex(float2 v, float degree)
		    {
			    v.xy -= 0.5;

			    float s = sin(degree);
			    float c = cos(degree);

			    float2x2 rotationMatrix = float2x2(c, -s, s, c);

			    v.xy = mul(v.xy, rotationMatrix);

			    v.xy += 0.5;

			    return v;
		    }


		    inline float3 TriplanarSampling44( sampler2D topTexMap, float3 worldPos, float3 worldNormal, float falloff, float2 tiling, float3 normalScale, float degree )
		    {
			    float3 projNormal = ( pow( abs( worldNormal ), falloff ) );
			    projNormal /= ( projNormal.x + projNormal.y + projNormal.z ) + 0.00001;
			    float3 nsign = sign( worldNormal );
			    half4 xNorm; half4 yNorm; half4 zNorm;

			    ///////////////////////////////////////////////////////////
			    float2 xn = worldPos.zy * float2(nsign.x, 1.0);
			    float2 yn = worldPos.xz * float2(nsign.y, 1.0);
			    float2 zn = worldPos.xy * float2(-nsign.z, 1.0);

			    xn = RotTex(xn, degree);
			    yn = RotTex(yn, degree);
			    zn = RotTex(zn, degree);

			    xNorm = tex2D(topTexMap, tiling*xn);
			    yNorm = tex2D(topTexMap, tiling*yn);
			    zNorm = tex2D(topTexMap, tiling*zn);
			    ////////////////////////////////////////////////////////////

			    xNorm.xyz  = half3( UnpackNormalScale( xNorm, normalScale.y ).xy * float2(  nsign.x, 1.0 ) + worldNormal.zy, worldNormal.x ).zyx;
			    yNorm.xyz  = half3( UnpackNormalScale( yNorm, normalScale.x ).xy * float2(  nsign.y, 1.0 ) + worldNormal.xz, worldNormal.y ).xzy;
			    zNorm.xyz  = half3( UnpackNormalScale( zNorm, normalScale.y ).xy * float2( -nsign.z, 1.0 ) + worldNormal.xy, worldNormal.z ).xyz;
			    return normalize( xNorm.xyz * projNormal.x + yNorm.xyz * projNormal.y + zNorm.xyz * projNormal.z );
		    }


		    inline float4 TriplanarSampling32( sampler2D topTexMap, float3 worldPos, float3 worldNormal, float falloff, float2 tiling, float3 normalScale, float3 index, float degree)
		    {
			    float3 projNormal = ( pow( abs( worldNormal ), falloff ) );
			    projNormal /= ( projNormal.x + projNormal.y + projNormal.z ) + 0.00001;
			    float3 nsign = sign( worldNormal );
			    half4 xNorm; half4 yNorm; half4 zNorm;


			    ///////////////////////////////////////////////////////////
			    float2 xn = worldPos.zy * float2(nsign.x, 1.0);
			    float2 yn = worldPos.xz * float2(nsign.y, 1.0);
			    float2 zn = worldPos.xy * float2(-nsign.z, 1.0);

			    xn = RotTex(xn, degree);
			    yn = RotTex(yn, degree);
			    zn = RotTex(zn, degree);

			    xNorm = tex2D(topTexMap, tiling*xn);
			    yNorm = tex2D(topTexMap, tiling*yn);
			    zNorm = tex2D(topTexMap, tiling*zn);
			    ////////////////////////////////////////////////////////////

			    return xNorm * projNormal.x + yNorm * projNormal.y + zNorm * projNormal.z;
		    }

		    inline float4 TriplanarSampling25( sampler2D topTexMap, float3 worldPos, float3 worldNormal, float falloff, float2 tiling, float3 normalScale, float3 index, float degree)
		    {
			    float3 projNormal = ( pow( abs( worldNormal ), falloff ) );
			    projNormal /= ( projNormal.x + projNormal.y + projNormal.z ) + 0.00001;
			    float3 nsign = sign( worldNormal );
			    half4 xNorm; half4 yNorm; half4 zNorm;

			    ///////////////////////////////////////////////////////////
			    float2 xn = worldPos.zy * float2(nsign.x, 1.0);
			    float2 yn = worldPos.xz * float2(nsign.y, 1.0);
			    float2 zn = worldPos.xy * float2(-nsign.z, 1.0);

			    xn = RotTex(xn, degree);
			    yn = RotTex(yn, degree);
			    zn = RotTex(zn, degree);

			    xNorm = tex2D(topTexMap, tiling*xn);
			    yNorm = tex2D(topTexMap, tiling*yn);
			    zNorm = tex2D(topTexMap, tiling*zn);
			    ////////////////////////////////////////////////////////////

			    return xNorm * projNormal.x + yNorm * projNormal.y + zNorm * projNormal.z;
		    }

            inline float4 TriplanarSampling71( sampler2D topTexMap, float3 worldPos, float3 worldNormal, float falloff, float2 tiling, float3 normalScale, float3 index, float degree )
		    {
			    float3 projNormal = ( pow( abs( worldNormal ), falloff ) );
			    projNormal /= ( projNormal.x + projNormal.y + projNormal.z ) + 0.00001;
			    float3 nsign = sign( worldNormal );
			    half4 xNorm; half4 yNorm; half4 zNorm;


			    ///////////////////////////////////////////////////////////
			    float2 xn = worldPos.zy * float2(nsign.x, 1.0);
			    float2 yn = worldPos.xz * float2(nsign.y, 1.0);
			    float2 zn = worldPos.xy * float2(-nsign.z, 1.0);

			    xn = RotTex(xn, degree);
			    yn = RotTex(yn, degree);
			    zn = RotTex(zn, degree);

			    xNorm = tex2D(topTexMap, tiling*xn);
			    yNorm = tex2D(topTexMap, tiling*yn);
			    zNorm = tex2D(topTexMap, tiling*zn);
			    ////////////////////////////////////////////////////////////

			    return xNorm * projNormal.x + yNorm * projNormal.y + zNorm * projNormal.z;
		    }


            struct Attributes
            {
                float4 positionOS : POSITION;
                float3 normalOS : NORMAL;
                float4 tangent : TANGENT;
                float2 texcoord : TEXCOORD0;
                float4 color : COLOR;
                UNITY_VERTEX_INPUT_INSTANCE_ID
            };

            struct Varyings
            {
                float4 positionHCS : SV_POSITION;
                float3 worldPos : TEXCOORD0;
                float3 worldNormal : TEXCOORD1;
                float4 color : COLOR;
    
                // 접선 공간 (TBN 매트릭스를 월드 위치와 함께 저장)
                float4 tSpace0 : TEXCOORD2; // tangent.x, binormal.x, normal.x, worldPos.x
                float4 tSpace1 : TEXCOORD3; // tangent.y, binormal.y, normal.y, worldPos.y
                float4 tSpace2 : TEXCOORD4; // tangent.z, binormal.z, normal.z, worldPos.z
    
                // SH 및 버텍스 라이팅 (항상 사용)
                half3 vertexSH : TEXCOORD5; // SH + vertex lights
    
                // 뷰 방향
                float3 viewDir : TEXCOORD6;
                
                float4 shadowCoord : TEXCOORD7; // 그림자 좌표


                UNITY_VERTEX_INPUT_INSTANCE_ID
                UNITY_VERTEX_OUTPUT_STEREO
            };

            // Built-in의 Input 구조체 역할을 하는 데이터
            struct SurfaceInput {
                float3 worldPos;
                float3 worldNormal;
                float4 color;
                float3x3 tangentToWorld;
            };

            inline void surf(SurfaceInput i,inout SurfaceData sd,inout InputData id)
            {
                float2 temp_cast_0 = (( 1 / _NormalTiling )).xx;
                float3 ase_worldPos = i.worldPos;
                float3 ase_worldTangent   = i.tangentToWorld[0]; // X축
                float3 ase_worldBitangent = i.tangentToWorld[1]; // Y축
                float3 ase_worldNormal    = i.tangentToWorld[2]; // Z축
			    float3x3 ase_worldToTangent = float3x3( ase_worldTangent, ase_worldBitangent, ase_worldNormal );
			    
                float3 triplanar44 = TriplanarSampling44( _Normal, ase_worldPos, ase_worldNormal, 2.0, temp_cast_0, _NormalStrength, _RotationDegrees);
			    float3 tanTriplanarNormal44 = mul( ase_worldToTangent, triplanar44 );
                
                float2 temp_cast_1 = (( 1 / _DetailTiling )).xx;
			    float4 triplanar32 = TriplanarSampling32( _DetailTexture, ase_worldPos, ase_worldNormal, 1.0, temp_cast_1, 1.0, 0, _RotationDegrees);
			    
                float2 temp_cast_3 = (( 1 / _DiffuseTiling )).xx;

                float4 triplanar25 = TriplanarSampling25( _DiffuseTexture, ase_worldPos, ase_worldNormal, 1.0, temp_cast_3, 1.0, 0, _RotationDegrees);
			    float4 blendOpSrc37 = triplanar32;
			    float4 blendOpDest37 = ( _DiffuseColor * triplanar25 );
			    float4 temp_output_37_0 = ( saturate( (( blendOpDest37 > 0.5 ) ? ( 1.0 - 2.0 * ( 1.0 - blendOpDest37 ) * ( 1.0 - blendOpSrc37 ) ) : ( 2.0 * blendOpDest37 * blendOpSrc37 ) ) ));
			    float2 temp_cast_5 = (( 1 / _SurfaceTexTiling )).xx;
			    float4 triplanar71 = TriplanarSampling71( _SurfaceTexture, ase_worldPos, ase_worldNormal, 1.0, temp_cast_5, 1.0, 0, _RotationDegrees);
			    float4 blendOpSrc80 = triplanar71;
			    float4 blendOpDest80 = temp_output_37_0;
			    float4 lerpResult78 = lerp( temp_output_37_0 , ( saturate( (( blendOpDest80 > 0.5 ) ? ( 1.0 - 2.0 * ( 1.0 - blendOpDest80 ) * ( 1.0 - blendOpSrc80 ) ) : ( 2.0 * blendOpDest80 * blendOpSrc80 ) ) )) , _SurfaceTexOpacity);

			    float4 A = _OPCD_OverallColor * lerpResult78;

			    float4 result = A;
			    float3 resultNormal = tanTriplanarNormal44;

			    float4 resultR = 0;
			    float4 resultG = 0;
			    float4 resultB = 0;

                sd.normalTS = resultNormal;

			    int count=0;

			    if (_USE_VertexColor_r == 1 && i.color.rgb.r> 0)
			    {
				    float2 B_temp_cast_0 = ((1 / _NormalTiling_r)).xx;
				    float3 B_triplanar44 = TriplanarSampling44(_Normal_r, ase_worldPos, ase_worldNormal, 2.0, B_temp_cast_0, _NormalStrength_r, _RotationDegrees_r);
				    float3 B_tanTriplanarNormal44 = mul(ase_worldToTangent, B_triplanar44);
				 
				    float2 B_temp_cast_1 = ((1 / _DetailTiling_r)).xx;
				    float4 B_triplanar32 = TriplanarSampling32(_DetailTexture_r, ase_worldPos, ase_worldNormal, 1.0, B_temp_cast_1, 1.0, 0, _RotationDegrees_r);
				    float2 B_temp_cast_3 = ((1 / _DiffuseTiling_r)).xx;
				    float4 B_triplanar25 = TriplanarSampling25(_DiffuseTexture_r, ase_worldPos, ase_worldNormal, 1.0, B_temp_cast_3, 1.0, 0, _RotationDegrees_r);
				    float4 B_blendOpSrc37 = B_triplanar32;
				    float4 B_blendOpDest37 = (_DiffuseColor_r * B_triplanar25);
				    float4 B_temp_output_37_0 = (saturate(((B_blendOpDest37 > 0.5) ? (1.0 - 2.0 * (1.0 - B_blendOpDest37) * (1.0 - B_blendOpSrc37)) : (2.0 * B_blendOpDest37 * B_blendOpSrc37))));
				    float2 B_temp_cast_5 = ((1 / _SurfaceTexTiling_r)).xx;
				    float4 B_triplanar71 = TriplanarSampling71(_SurfaceTexture_r, ase_worldPos, ase_worldNormal, 1.0, B_temp_cast_5, 1.0, 0, _RotationDegrees_r);
				    float4 B_blendOpSrc80 = B_triplanar71;
				    float4 B_blendOpDest80 = B_temp_output_37_0;
				    float4 B_lerpResult78 = lerp(B_temp_output_37_0, (saturate(((B_blendOpDest80 > 0.5) ? (1.0 - 2.0 * (1.0 - B_blendOpDest80) * (1.0 - B_blendOpSrc80)) : (2.0 * B_blendOpDest80 * B_blendOpSrc80)))), _SurfaceTexOpacity_r);

				    float4 B = _OPCD_OverallColor_r * B_lerpResult78;
				    ///////////////////////////////////////////////////////////////////////
				
				    float r = i.color.rgb.r;

				    resultNormal = ((1- r)*resultNormal + r * B_tanTriplanarNormal44);
				    r = pow(abs(r), 1+ _VertexColorRange_r * 10);

				    //result = ((1 - r)*result + r * B);
                    float camDist = length(id.viewDirectionWS);
				    if (camDist > 300) // use _BlendDistance
					    result = A;
				    else
					    result =  ((1- r)*result + r * B);
			    }
                if (_USE_VertexColor_g == 1 && i.color.rgb.g>0)
			    {
				    float2 B_temp_cast_0 = ((1 / _NormalTiling_g)).xx;
				    float3 B_triplanar44 = TriplanarSampling44(_Normal_g, ase_worldPos, ase_worldNormal, 2.0, B_temp_cast_0, _NormalStrength_g, _RotationDegrees_g);
				    float3 B_tanTriplanarNormal44 = mul(ase_worldToTangent, B_triplanar44);
				
				    float2 B_temp_cast_1 = ((1 / _DetailTiling_g)).xx;
				    float4 B_triplanar32 = TriplanarSampling32(_DetailTexture_g, ase_worldPos, ase_worldNormal, 1.0, B_temp_cast_1, 1.0, 0, _RotationDegrees_g);
				    float2 B_temp_cast_3 = ((1 / _DiffuseTiling_g)).xx;
				    float4 B_triplanar25 = TriplanarSampling25(_DiffuseTexture_g, ase_worldPos, ase_worldNormal, 1.0, B_temp_cast_3, 1.0, 0, _RotationDegrees_g);
				    float4 B_blendOpSrc37 = B_triplanar32;
				    float4 B_blendOpDest37 = (_DiffuseColor_g * B_triplanar25);
				    float4 B_temp_output_37_0 = (saturate(((B_blendOpDest37 > 0.5) ? (1.0 - 2.0 * (1.0 - B_blendOpDest37) * (1.0 - B_blendOpSrc37)) : (2.0 * B_blendOpDest37 * B_blendOpSrc37))));
				    float2 B_temp_cast_5 = ((1 / _SurfaceTexTiling_g)).xx;
				    float4 B_triplanar71 = TriplanarSampling71(_SurfaceTexture_g, ase_worldPos, ase_worldNormal, 1.0, B_temp_cast_5, 1.0, 0, _RotationDegrees_g);
				    float4 B_blendOpSrc80 = B_triplanar71;
				    float4 B_blendOpDest80 = B_temp_output_37_0;
				    float4 B_lerpResult78 = lerp(B_temp_output_37_0, (saturate(((B_blendOpDest80 > 0.5) ? (1.0 - 2.0 * (1.0 - B_blendOpDest80) * (1.0 - B_blendOpSrc80)) : (2.0 * B_blendOpDest80 * B_blendOpSrc80)))), _SurfaceTexOpacity_g);

				    float4 B = _OPCD_OverallColor_g * B_lerpResult78;
				    ///////////////////////////////////////////////////////////////////////
				
				    float g = i.color.rgb.g;
				    resultNormal = ((1- g)*resultNormal + g * B_tanTriplanarNormal44);
				    g = pow(abs(g), 1+ _VertexColorRange_g * 10);
				
				    //result = ((1 - g)*result + g * B);

                    float camDist = length(id.viewDirectionWS);
				    if (camDist > 300)// use _BlendDistance
					    result = A;
				    else
					    result = ((1 - g)*result + g * B);
			    }

                sd.normalTS = resultNormal;
                sd.albedo = result.rgb;
                sd.smoothness = 0.0;
                sd.alpha = 1.0;
                sd.emission = float3(0, 0, 0);
                sd.metallic = 0.0;
                sd.occlusion = 1.0;
            }

            Varyings vert(Attributes input)
            {
                Varyings output = (Varyings)0;
    
                // 인스턴싱 및 스테레오 설정
                UNITY_SETUP_INSTANCE_ID(input);
                UNITY_TRANSFER_INSTANCE_ID(input, output);
                UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
    
                // 위치 변환
                VertexPositionInputs posInputs = GetVertexPositionInputs(input.positionOS.xyz);
                output.positionHCS = posInputs.positionCS;
                output.worldPos = posInputs.positionWS;
                output.shadowCoord = GetShadowCoord(posInputs);
    
                // 노멀 및 접선 벡터 변환
                VertexNormalInputs normalInputs = GetVertexNormalInputs(input.normalOS, input.tangent);
                float3 worldNormal = normalInputs.normalWS;
                float3 worldTangent = normalInputs.tangentWS;
                float3 worldBinormal = normalInputs.bitangentWS;
    
                output.worldNormal = worldNormal;
    
                // 접선 공간 매트릭스 (Built-in RP와 동일한 방식)
                output.tSpace0 = float4(worldTangent.x, worldBinormal.x, worldNormal.x, posInputs.positionWS.x);
                output.tSpace1 = float4(worldTangent.y, worldBinormal.y, worldNormal.y, posInputs.positionWS.y);
                output.tSpace2 = float4(worldTangent.z, worldBinormal.z, worldNormal.z, posInputs.positionWS.z);
    
                // 뷰 방향
                output.viewDir = GetWorldSpaceViewDir(posInputs.positionWS);
    
                // 정점 컬러
                output.color = input.color;
    
                // SH 및 버텍스 라이팅 (항상 계산)
                // SH 계산
                output.vertexSH = SampleSH(worldNormal);
    
                // 추가 버텍스 라이팅 (최대 4개의 추가 라이트)
                uint lightsCount = GetAdditionalLightsCount();
                for (uint lightIndex = 0u; lightIndex < lightsCount; ++lightIndex)
                {
                    Light light = GetAdditionalLight(lightIndex, posInputs.positionWS);
                    half3 attenuatedLightColor = light.color * (light.distanceAttenuation * light.shadowAttenuation);
                    output.vertexSH += LightingLambert(attenuatedLightColor, light.direction, worldNormal);
                }
                return output;
            }

            half4 frag(Varyings i) : SV_Target
            {
                UNITY_SETUP_INSTANCE_ID(i);
                UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
                float3 worldPos = float3(i.tSpace0.w,i.tSpace1.w,i.tSpace2.w);
                Light mainLight = GetMainLight();

                float3 lightDir = mainLight.direction;
                float3 worldViewDir = GetWorldSpaceNormalizeViewDir(worldPos);

                float3x3 tangentToWorld = float3x3(
                    i.tSpace0.xyz,
                    i.tSpace1.xyz, 
                    i.tSpace2.xyz
                );
    
                SurfaceInput surfIN;
                surfIN.worldPos = worldPos;
                surfIN.worldNormal = normalize(i.worldNormal);
                surfIN.color = i.color;
                surfIN.tangentToWorld = tangentToWorld;

                SurfaceData surfaceData = (SurfaceData)0;
                surfaceData.albedo = half3(0,0,0);
                surfaceData.normalTS = half3(0,0,1);
                surfaceData.emission = half3(0,0,0);
                surfaceData.metallic = 0.0;
                surfaceData.smoothness = 0.0;
                surfaceData.occlusion = 1.0;
                surfaceData.alpha = 1.0;

                InputData inputData = (InputData)0;
                inputData.positionWS = worldPos;
                inputData.normalWS = mul(tangentToWorld, surfaceData.normalTS);
                inputData.viewDirectionWS = worldViewDir;
                inputData.shadowCoord = i.shadowCoord; // 그림자
                inputData.fogCoord = 0; // 포그 없음
                inputData.vertexLighting = i.vertexSH; // SH 라이팅
                inputData.bakedGI = i.vertexSH;
                inputData.normalizedScreenSpaceUV = 0;
                inputData.shadowMask = half4(1,1,1,1);

                //여기서 surf 함수를 대체
                surf(surfIN, surfaceData, inputData);

                half4 color = UniversalFragmentPBR(inputData,surfaceData.albedo,0.0,surfaceData.specular,surfaceData.smoothness,surfaceData.occlusion,surfaceData.emission,surfaceData.alpha);
                return color;
            }
            ENDHLSL
        }
	}
	Fallback "Universal Render Pipeline/Lit"
	//CustomEditor "ASEMaterialInspector"
}