summaryrefslogtreecommitdiff
path: root/Assets/ThirdParty/AmplifyShaderEditor/Plugins/EditorResources/Previews/Preview_ParallaxMappingNode.shader
blob: 5ea1a1bb2ac4e19d8852115895a758bcc3430d4d (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
35
36
37
38
39
40
41
42
43
44
Shader "Hidden/ParallaxMappingNode"
{
	Properties
	{
		_A ("_UV", 2D) = "white" {}
		_B ("_Height", 2D) = "white" {}
		_C ("_Scale", 2D) = "white" {}
		_D ("_ViewDirTan", 2D) = "white" {}
	}
	SubShader
	{
		Pass
		{
			CGPROGRAM
			#include "UnityCG.cginc"
			#pragma vertex vert_img
			#pragma fragment frag

			sampler2D _A;
			sampler2D _B;
			sampler2D _C;
			sampler2D _D;
			float _ParallaxType;

			float4 frag(v2f_img i) : SV_Target
			{
				float2 uv = tex2D( _A, i.uv ).rg;
				float h = tex2D( _B, i.uv ).r;
				float s = tex2D( _C, i.uv ).r;
				float3 vt = tex2D( _D, i.uv ).xyz;
				float2 parallaxed = uv;
				if ( _ParallaxType == 1 ) {
					parallaxed = ( ( h - 1 )*( vt.xy / vt.z ) * s ) + uv;
				}
				else {
					parallaxed = ( ( h - 1 )*( vt.xy ) * s ) + uv;
				}

				return float4(parallaxed, 0 , 0);
			}
			ENDCG
		}
	}
}