summaryrefslogtreecommitdiff
path: root/Assets/ThirdParty/AmplifyShaderEditor/Plugins/EditorResources/Previews/Preview_DesaturateNode.shader
blob: 1bc967fa0374d9399a9babb3c99571d9df49c11e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Shader "Hidden/DesaturateNode"
{
	Properties
	{
		_A ( "_RBG",  2D ) = "white" {}
		_B ( "_Fraction",  2D ) = "white" {}
	}

	SubShader
	{
		Pass
		{
			CGPROGRAM
			#include "UnityCG.cginc"
			#pragma vertex vert_img
			#pragma fragment frag

			uniform sampler2D _A;
			uniform sampler2D _B;
			
			float4 frag ( v2f_img i ) : SV_Target
			{
				float3 rgb = tex2D ( _A, i.uv ).rgb;
				float fraction = tex2D ( _B, i.uv ).r;

				float dotResult = dot ( rgb, float3( 0.299, 0.587, 0.114 ) );
				float3 finalColor = lerp ( rgb, dotResult.xxx, fraction );
				
				return float4( finalColor, 1 );
			}
			ENDCG
		}
	}
}