// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'

// Rainbow shader with lots of adjustable properties!

Shader "_Shaders/BattleRoyaleSpecial" {
	Properties{
		[PerRendererData]_Color("Color", Color) = (1,1,1,1)
		_MainTex("Albedo (RGB)", 2D) = "white" {}
		_Grayscale("Grayscale", Range(0, 1)) = 0.0
		_Glossiness("Smoothness", Range(0,1)) = 0.5
		_Metallic("Metallic", Range(0,1)) = 0.0
	}
		SubShader{
		Pass{
			Tags{ "RenderType" = "Transparent"  "Queue" = "Transparent" }
			Blend SrcAlpha OneMinusSrcAlpha
			Cull Back
			LOD 200
			ZWrite Off

		CGPROGRAM
// Upgrade NOTE: excluded shader from DX11; has structs without semantics (struct v2f members uv_MainTex)
#pragma exclude_renderers d3d11

#pragma vertex vert
#pragma fragment frag fullforwardshadows keepalpha
#pragma target 3.0
#include "UnityCG.cginc"
#include "ShaderTools.cginc"

		sampler2D _MainTex;
		uniform float _Grayscale;

		struct vertexInput {
			float4 vertex : POSITION;
			float4 texcoord0 : TEXCOORD0;
		};

		struct v2f
		{
			float4 pos : POSITION;
			float4 color : COLOR;
			float2 uv_MainTex;
			float2 vertex : SV_POSITION;
		};

		struct Input {
			float2 uv_MainTex;
			float2 vertex : SV_POSITION;
			float4 color : COLOR;
		};

		v2f vert(vertexInput v) {
			v2f o;
			UNITY_INITIALIZE_OUTPUT(v2f,o);
			o.color = v.color;
			o.vertex = UnityObjectToClipPos(v.vertex);
			return o;
		}

		half _Glossiness;
		half _Metallic;
		fixed4 _Color;

		// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
		// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
		// #pragma instancing_options assumeuniformscaling
		UNITY_INSTANCING_BUFFER_START(Props)
			// put more per-instance properties here
		UNITY_INSTANCING_BUFFER_END(Props)

		fixed4 frag(Input IN) : SV_TARGET{

			//fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
			fixed4 c = _Color;
			float alpha = IN.color.a;
			float3 rgb = lerp(c.rgb * IN.color.rgb, dot(c.rgb * IN.color.rgb, float3(0.3, 0.59, 0.11)), _Grayscale);
			c.rgb = rgb;
			c.a = alpha;
			return c;

		}

		ENDCG
	}
	}
		FallBack "Diffuse"
}