You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
849 B

  1. Shader "Hidden/ParallaxMappingNode"
  2. {
  3. Properties
  4. {
  5. _A ("_UV", 2D) = "white" {}
  6. _B ("_Height", 2D) = "white" {}
  7. _C ("_Scale", 2D) = "white" {}
  8. _D ("_ViewDirTan", 2D) = "white" {}
  9. }
  10. SubShader
  11. {
  12. Pass
  13. {
  14. CGPROGRAM
  15. #include "UnityCG.cginc"
  16. #pragma vertex vert_img
  17. #pragma fragment frag
  18. sampler2D _A;
  19. sampler2D _B;
  20. sampler2D _C;
  21. sampler2D _D;
  22. float _ParallaxType;
  23. float4 frag(v2f_img i) : SV_Target
  24. {
  25. float2 uv = tex2D( _A, i.uv ).rg;
  26. float h = tex2D( _B, i.uv ).r;
  27. float s = tex2D( _C, i.uv ).r;
  28. float3 vt = tex2D( _D, i.uv ).xyz;
  29. float2 parallaxed = uv;
  30. if ( _ParallaxType == 1 ) {
  31. parallaxed = ( ( h - 1 )*( vt.xy / vt.z ) * s ) + uv;
  32. }
  33. else {
  34. parallaxed = ( ( h - 1 )*( vt.xy ) * s ) + uv;
  35. }
  36. return float4(parallaxed, 0 , 0);
  37. }
  38. ENDCG
  39. }
  40. }
  41. }