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.

63 lines
1.3 KiB

  1. Shader "Hidden/TextureArrayNode"
  2. {
  3. Properties
  4. {
  5. _A ("_UVs", 2D) = "white" {}
  6. _B ("_Index", 2D) = "white" {}
  7. _C ("_Lod", 2D) = "white" {}
  8. _D ("_NormalScale", 2D) = "white" {}
  9. _G ("_Tex", 2D) = "white" {}
  10. _TexConnected ("_TexConnected", Int) = 0
  11. }
  12. SubShader
  13. {
  14. Pass
  15. {
  16. CGPROGRAM
  17. #pragma vertex vert_img
  18. #pragma fragment frag
  19. #pragma target 3.5
  20. #include "UnityCG.cginc"
  21. #include "UnityStandardUtils.cginc"
  22. uniform UNITY_DECLARE_TEX2DARRAY( _Sampler );
  23. sampler2D _A;
  24. sampler2D _B;
  25. sampler2D _C;
  26. sampler2D _D;
  27. sampler2D _G;
  28. float _CustomUVs;
  29. float _LodType;
  30. float _Unpack;
  31. int _TexConnected;
  32. float4 frag( v2f_img i ) : SV_Target
  33. {
  34. float2 uvs = i.uv;
  35. if ( _CustomUVs == 1 )
  36. uvs = tex2D( _A, i.uv ).xy;
  37. float n = tex2D( _D, i.uv ).r;
  38. float4 c = 0;
  39. if ( _LodType == 1 ) {
  40. float lod = tex2D( _C, i.uv ).r;
  41. c = UNITY_SAMPLE_TEX2DARRAY_LOD( _Sampler, float3( uvs, tex2D( _B, i.uv ).r ), lod );
  42. }
  43. else if( _TexConnected == 0) {
  44. c = UNITY_SAMPLE_TEX2DARRAY( _Sampler, float3( uvs, tex2D( _B, i.uv ).r ) );
  45. }
  46. else {
  47. c = tex2D( _G, uvs );
  48. }
  49. if ( _Unpack == 1 )
  50. {
  51. c.rgb = UnpackScaleNormal(c, n);
  52. }
  53. return c;
  54. }
  55. ENDCG
  56. }
  57. }
  58. }