Blend 5 Textures

2014. 7. 29. 18:22 - 묘쿠
  1.  
  2. Shader "VPaint/Lit/Blend 5 Textures" {
  3.     Properties {
  4.         _BaseTexture ("Base Texture", 2D) = "white" {}
  5.         _Texture1 ("Texture 1 (Red Channel)", 2D) = "white" {}
  6.         _Texture2 ("Texture 2 (Blue Channel)", 2D) = "white" {}
  7.         _Texture3 ("Texture 3 (Green Channel)", 2D) = "white" {}
  8.         _Texture4 ("Texture 4 (Alpha Channel)", 2D) = "white" {}
  9.     }
  10.     SubShader {
  11.         Tags { "RenderType"="Opaque" }
  12.         LOD 200
  13.        
  14.         CGPROGRAM
  15.         #pragma surface surf Lambert
  16.         #pragma exclude_renderers flash
  17.  
  18.         sampler2D _BaseTexture;
  19.         sampler2D _Texture1;
  20.         sampler2D _Texture2;
  21.         sampler2D _Texture3;
  22.         sampler2D _Texture4;
  23.  
  24.         struct Input {
  25.             half2 uv_BaseTexture;
  26.             half2 uv_Texture1;
  27.             half2 uv_Texture2;
  28.             half2 uv_Texture3;
  29.             half2 uv_Texture4;
  30.             float4 color : COLOR;
  31.         };
  32.  
  33.         void surf (Input IN, inout SurfaceOutput o) {
  34.             float4 color = IN.color;
  35.            
  36.             half4 t0 = tex2D (_BaseTexture, IN.uv_BaseTexture);
  37.             half4 t1 = tex2D (_Texture1, IN.uv_Texture1);
  38.             half4 t2 = tex2D (_Texture2, IN.uv_Texture2);
  39.             half4 t3 = tex2D (_Texture3, IN.uv_Texture3);
  40.             half4 t4 = tex2D (_Texture4, IN.uv_Texture4);
  41.            
  42.             half4 cum = t1 * color.r + t2 * color.g + t3 * color.b + t4 * color.a;
  43.             fixed fac = color.r + color.g + color.b + color.a;
  44.            
  45.             if(fac != 0) cum /= fac;
  46.             cum = lerp(t0, cum, fac);
  47.            
  48.             o.Albedo = cum.rgb;
  49.             o.Alpha = cum.a;
  50.         }
  51.         ENDCG
  52.     }
  53.     FallBack "Diffuse"
  54. }

버텍스 컬러를 이용한 5 텍스쳐 블렌딩

vPaint in asset store

'Shader > Surface' 카테고리의 다른 글

Surface Shader Custom Lighting 언릿 설정  (0) 2014.07.31
Blend 5 Bumped Textures  (0) 2014.07.30
Blend 4 Bumped Textures  (0) 2014.07.29

다른 카테고리의 글 목록

Shader/Surface 카테고리의 포스트를 톺아봅니다