Advertisement
tonynogo

Demo 54 - Texture depending normal

Jul 6th, 2017
3,029
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/TextureDependingNormal"
  2. {
  3.     Properties
  4.     {
  5.         _FloorTex ("Floor Texture", 2D) = "white" {}
  6.         _WallTex ("Wall Texture", 2D) = "white" {}
  7.         _CeilTex ("Ceil Texture", 2D) = "white" {}
  8.     }
  9.  
  10.     SubShader
  11.     {
  12.         Tags { "RenderType"="Opaque" }
  13.  
  14.  
  15.         CGPROGRAM
  16.         #pragma surface surf Standard
  17.  
  18.         struct Input {
  19.             float3 worldNormal;
  20.             float2 uv_FloorTex;
  21.             float2 uv_WallTex;
  22.             float2 uv_CeilTex;
  23.         };
  24.  
  25.         sampler2D _FloorTex;
  26.         sampler2D _WallTex;
  27.         sampler2D _CeilTex;
  28.  
  29.         void surf(Input IN, inout SurfaceOutputStandard o) {
  30.             // Floor
  31.             if(IN.worldNormal.y > 0.9)
  32.             {
  33.                 o.Albedo = tex2D(_FloorTex, IN.uv_FloorTex).rgb;
  34.             }
  35.             // Ceil
  36.             else if(IN.worldNormal.y < -0.9)
  37.             {
  38.                 o.Albedo = tex2D(_CeilTex, IN.uv_CeilTex).rgb;
  39.             }
  40.             // Wall
  41.             else
  42.             {
  43.                 o.Albedo = tex2D(_WallTex, IN.uv_WallTex).rgb;
  44.             }
  45.             o.Emission = half3(1, 1, 1) * o.Albedo;
  46.             o.Metallic = 0.0;
  47.             o.Smoothness = 0.5;
  48.         }
  49.  
  50.         ENDCG
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement