Blend 4 Bumped Textures

2014. 7. 29. 18:59 - 묘쿠
  1. Shader "VPaint/Lit/Blend 4 Bumped Textures" {
  2.     Properties {
  3.         _Color ("Base Color"Color) = (1,1,1,1)
  4.        
  5.         _Texture1 ("Texture 1 (RGB: Red Channel) (A: Spec)", 2D) = "white" {}
  6.         _Texture1Bump ("Texture 1 Bump", 2D) = "bump" {}
  7.        
  8.         _Texture2 ("Texture 2 (RGB: Blue Channel) (A: Spec)", 2D) = "white" {}
  9.         _Texture2Bump ("Texture 2 Bump", 2D) = "bump" {}
  10.        
  11.         _Texture3 ("Texture 3 (RGB: Green Channel) (A: Spec)", 2D) = "white" {}
  12.         _Texture3Bump ("Texture 3 Bump", 2D) = "bump" {}
  13.        
  14.         _Texture4 ("Texture 4 (RGB: Alpha Channel) (A: Spec)", 2D) = "white" {}
  15.         _Texture4Bump ("Texture 4 Bump", 2D) = "bump" {}
  16.     }
  17.     SubShader {
  18.         Tags { "RenderType"="Opaque" }
  19.         LOD 200
  20.        
  21.         CGPROGRAM
  22.         #pragma surface surf Lambert
  23.         #pragma target 3.0
  24.  
  25.         half4 _Color;
  26.         sampler2D _Texture1;
  27.         sampler2D _Texture1Bump;
  28.        
  29.         sampler2D _Texture2;
  30.         sampler2D _Texture2Bump;
  31.  
  32.         sampler2D _Texture3;
  33.         sampler2D _Texture3Bump;
  34.        
  35.         sampler2D _Texture4;
  36.         sampler2D _Texture4Bump;
  37.  
  38.         struct Input {
  39.             half2 uv_Texture1;         
  40.             half2 uv_Texture2;         
  41.             half2 uv_Texture3;         
  42.             half2 uv_Texture4;
  43.            
  44.             float4 color : COLOR;
  45.         };
  46.  
  47.         void surf (Input IN, inout SurfaceOutput o) {
  48.             float4 color = IN.color;
  49.            
  50.             half4 t1 = tex2D (_Texture1, IN.uv_Texture1);
  51.             half4 t2 = tex2D (_Texture2, IN.uv_Texture2);
  52.             half4 t3 = tex2D (_Texture3, IN.uv_Texture3);
  53.             half4 t4 = tex2D (_Texture4, IN.uv_Texture4);
  54.            
  55.             half4 t1b = tex2D (_Texture1Bump, IN.uv_Texture1);
  56.             half4 t2b = tex2D (_Texture2Bump, IN.uv_Texture2);
  57.             half4 t3b = tex2D (_Texture3Bump, IN.uv_Texture3);
  58.             half4 t4b = tex2D (_Texture4Bump, IN.uv_Texture4);
  59.            
  60.             half4 cum = t1 * color.r + t2 * color.g + t3 * color.b + t4 * color.a;
  61.             half4 nrm = t1b * color.r + t2b * color.g + t3b * color.b + t4b * color.a;
  62.             fixed fac = color.r + color.g + color.b + color.a;
  63.            
  64.             if(fac != 0)
  65.             {
  66.                 cum /= fac;
  67.                 nrm /= fac;
  68.             }
  69.             cum = lerp(_Color, cum, fac);
  70.            
  71.             o.Albedo = cum.rgb;
  72.             o.Specular = cum.a;
  73.             o.Normal = lerp(half3(0,0,1), UnpackNormal(nrm), fac);
  74.         }
  75.         ENDCG
  76.     }
  77.     FallBack "Diffuse"
  78. }


4 diffuse + 4bump



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

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

다른 카테고리의 글 목록

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