﻿Shader "Hidden/RiderFlowURPSceneHighlighting"
{
    Properties
    {
    }

    SubShader
    {
        Tags
        {
            "RenderType" = "Opaque"
        }

        Pass
        {
            Tags
            {
                "LightMode"="MyPass"
            }

            HLSLPROGRAM
            #pragma vertex VertexMain
            #pragma fragment FragmentMain
            
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"

			struct VertexInput {
				float4 position : POSITION;
                float2 uv           : TEXCOORD0;
			};

			struct VertexOut {
				float4 position : SV_POSITION;
			    float2 uv           : TEXCOORD0;
			};
            
            VertexOut VertexMain(VertexInput input)
            {
                VertexOut vertexOut;
                vertexOut.position = TransformObjectToHClip(input.position.xyz);
                return vertexOut;
            }

            sampler2D _MainTex;

            float4 FragmentMain(VertexOut i) : SV_TARGET
            {
                return float4(1, 0, 0, 1);
            }
            ENDHLSL
        }
        
        Pass
        {
            Tags
            {
                "LightMode"="MyPass"
            }


			HLSLPROGRAM

			#pragma vertex VertexMain
			#pragma fragment FragmentMain

			#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
			
			struct VertexInput {
				float4 position : POSITION;
                float2 uv           : TEXCOORD0;
			};

			struct VertexOut {
				float4 position : SV_POSITION;
			    float2 uv           : TEXCOORD0;
			};


			TEXTURE2D(_BaseMap);
            SAMPLER(sampler_BaseMap);

            CBUFFER_START(UnityPerMaterial)
                float4 _BaseMap_ST;
            CBUFFER_END


			TEXTURE2D(_BaseMap2);
            SAMPLER(sampler_BaseMap2);

            CBUFFER_START(UnityPerMaterial)
                float4 _BaseMap2_ST;
            CBUFFER_END
			
			VertexOut VertexMain(VertexInput input) {
				VertexOut vertexOut;
				vertexOut.position = TransformObjectToHClip(input.position.xyz);
			    vertexOut.uv = TRANSFORM_TEX(input.uv, _BaseMap);
				return vertexOut;
			}


			float4  FragmentMain(VertexOut o) : SV_TARGET{

				float4  col = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, o.uv);
				float4  col2 = SAMPLE_TEXTURE2D(_BaseMap2, sampler_BaseMap2, o.uv);

				if (col.x == 0.0f && col.y == 0.0f && col.z == 0.0f && col.w == 0.0f)
				{
					float d = 0.299*col2.x + 0.587*col2.y + 0.184*col2.z;
					return float4(d, d, d, 1);
				}
				return col2 * float4(1, 0, 0, 1);
			}

			ENDHLSL
        }
    	
    	        Pass
        {
            Tags
            {
                "LightMode"="MyPass"
            }


			HLSLPROGRAM

			#pragma vertex VertexMain
			#pragma fragment FragmentMain

			#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
			
			struct VertexInput {
				float4 position : POSITION;
                float2 uv           : TEXCOORD0;
			};

			struct VertexOut {
				float4 position : SV_POSITION;
			    float2 uv           : TEXCOORD0;
			};


			TEXTURE2D(_BaseMap);
            SAMPLER(sampler_BaseMap);

            CBUFFER_START(UnityPerMaterial)
                float4 _BaseMap_ST;
            CBUFFER_END


			TEXTURE2D(_BaseMap2);
            SAMPLER(sampler_BaseMap2);

            CBUFFER_START(UnityPerMaterial)
                float4 _BaseMap2_ST;
            CBUFFER_END
			
			VertexOut VertexMain(VertexInput input) {
				VertexOut vertexOut;
				vertexOut.position = TransformObjectToHClip(input.position.xyz);
			    vertexOut.uv = TRANSFORM_TEX(input.uv, _BaseMap);
				return vertexOut;
			}


			half4  FragmentMain(VertexOut o) : SV_TARGET{

				half4  col = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, o.uv);
				return col;
			}

			ENDHLSL
        }
    }
}