Advertisement
Asyncron

Untitled

Jul 14th, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. Shader "Nature/Terrain/Diffuse"
  2. {
  3. Properties
  4. {
  5. [HideInInspector] _Control ("Control (RGBA)", 2D) = "red" {}
  6. [HideInInspector] _Splat3 ("Layer 3 (A)", 2D) = "white" {}
  7. [HideInInspector] _Splat2 ("Layer 2 (B)", 2D) = "white" {}
  8. [HideInInspector] _Splat1 ("Layer 1 (G)", 2D) = "white" {}
  9. [HideInInspector] _Splat0 ("Layer 0 (R)", 2D) = "white" {}
  10. //Used in fallback on old cards & base map
  11. [HideInInspector] _MainTex ("BaseMap (RGB)", 2D) = "white" {}
  12. [HideInInspector] _Color ("Main Color", Color) = (1,1,1,1)
  13. }
  14.  
  15. SubShader
  16. {
  17. Tags
  18. {
  19. "SplatCount" = "4"
  20. "Queue" = "Geometry-100"
  21. "RenderType" = "Opaque"
  22. }
  23. Blend SrcAlpha OneMinusSrcAlpha
  24. CGPROGRAM
  25. #pragma surface surf Lambert nolightmap
  26. #pragma target 3.0
  27. struct Input
  28. {
  29. float2 uv_Control : TEXCOORD0;
  30. float2 uv_Splat0 : TEXCOORD1;
  31. float2 uv_Splat1 : TEXCOORD2;
  32. float2 uv_Splat2 : TEXCOORD3;
  33. float2 uv_Splat3 : TEXCOORD4;
  34. };
  35.  
  36. sampler2D _Control;
  37. sampler2D _Splat0,_Splat1,_Splat2,_Splat3;
  38.  
  39. void surf (Input IN, inout SurfaceOutput o)
  40. {
  41. fixed4 splat_control = tex2D (_Control, IN.uv_Control);
  42. fixed4 firstSplat = tex2D (_Splat0, IN.uv_Splat0);
  43. fixed3 col;
  44. col = splat_control.r * tex2D (_Splat0, IN.uv_Splat0).rgb;
  45. col += splat_control.g * tex2D (_Splat1, IN.uv_Splat1).rgb;
  46. col += splat_control.b * tex2D (_Splat2, IN.uv_Splat2).rgb;
  47. col += splat_control.a * tex2D (_Splat3, IN.uv_Splat3).rgb;
  48. o.Albedo = col;
  49. o.Alpha = 1;
  50. if(tex2D(_Splat0, IN.uv_Splat0).a == 0)
  51. o.Alpha = 1 - splat_control.r;
  52. else if(tex2D(_Splat1, IN.uv_Splat1).a == 0)
  53. o.Alpha = 1 - splat_control.g;
  54. else if(tex2D(_Splat2, IN.uv_Splat2).a == 0)
  55. o.Alpha = 1 - splat_control.b;
  56. else if(tex2D(_Splat3, IN.uv_Splat3).a == 0)
  57. o.Alpha = 1 - splat_control.a;
  58. }
  59. ENDCG
  60. }
  61.  
  62. Dependency "AddPassShader" = "Hidden/TerrainEngine/Splatmap/Lightmap-AddPass"
  63. Dependency "BaseMapShader" = "Diffuse"
  64.  
  65. //Fallback to Diffuse
  66. Fallback "Diffuse"
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement