SebastianLague

2 Texture blend shader

Jan 14th, 2017
422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. Shader "Custom/Blend" {
  2. Properties {
  3. _Color ("Color", Color) = (1,1,1,1)
  4. _MainTex ("Main Texture", 2D) = "white" {}
  5. _BlendTex ("Blend Texture", 2D) = "white" {}
  6. _BlendPercent ("Texture Blend", Range(0,1)) = 0.0
  7. _Glossiness ("Smoothness", Range(0,1)) = 0.5
  8. _Metallic ("Metallic", Range(0,1)) = 0.0
  9. }
  10. SubShader {
  11. Tags { "RenderType"="Opaque" }
  12. LOD 200
  13.  
  14. CGPROGRAM
  15. // Physically based Standard lighting model, and enable shadows on all light types
  16. #pragma surface surf Standard fullforwardshadows
  17.  
  18. // Use shader model 3.0 target, to get nicer looking lighting
  19. #pragma target 3.0
  20.  
  21. sampler2D _MainTex;
  22. sampler2D _BlendTex;
  23.  
  24. struct Input {
  25. float2 uv_MainTex;
  26. };
  27.  
  28. half _Glossiness;
  29. half _Metallic;
  30. half _BlendPercent;
  31. fixed4 _Color;
  32.  
  33. void surf (Input IN, inout SurfaceOutputStandard o) {
  34. // Albedo comes from a texture tinted by color
  35. fixed4 tex_1 = tex2D (_MainTex, IN.uv_MainTex);
  36. fixed4 tex_2 = tex2D (_BlendTex, IN.uv_MainTex);
  37. fixed4 c = (tex_1 * (1-_BlendPercent) + tex_2 * _BlendPercent) * _Color;
  38. o.Albedo = c.rgb;
  39. // Metallic and smoothness come from slider variables
  40. o.Metallic = _Metallic;
  41. o.Smoothness = _Glossiness;
  42. o.Alpha = c.a;
  43. }
  44. ENDCG
  45. }
  46. FallBack "Diffuse"
  47. }
Advertisement
Add Comment
Please, Sign In to add comment