Advertisement
axoila

basic surface shader

Mar 30th, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Tutorial/04_surface" {
  2.     Properties {
  3.         _Color ("Tint", Color) = (0, 0, 0, 1)
  4.         _MainTex ("Texture", 2D) = "white" {}
  5.         _Smoothness ("Smoothness", Range(0, 1)) = 0
  6.         _Metallic ("Metalness", Range(0, 1)) = 0
  7.         [HDR] _Emission ("Emission", color) = (0,0,0)
  8.     }
  9.     SubShader {
  10.         Tags{ "RenderType"="Opaque" "Queue"="Geometry"}
  11.  
  12.         CGPROGRAM
  13.  
  14.         #pragma surface surf Standard fullforwardshadows
  15.         #pragma target 3.0
  16.  
  17.         sampler2D _MainTex;
  18.         fixed4 _Color;
  19.  
  20.         half _Smoothness;
  21.         half _Metallic;
  22.         half3 _Emission;
  23.  
  24.         struct Input {
  25.             float2 uv_MainTex;
  26.         };
  27.  
  28.         void surf (Input i, inout SurfaceOutputStandard o) {
  29.             fixed4 col = tex2D(_MainTex, i.uv_MainTex);
  30.             col *= _Color;
  31.             //changed this to only use the rgb values because this color doesn't take a alpha value
  32.             //(the alpha is cut automatically, but I think it's better to do it explicitly)
  33.             o.Albedo = col.rgb;
  34.             o.Metallic = _Metallic;
  35.             o.Smoothness = _Smoothness;
  36.             o.Emission = _Emission;
  37.         }
  38.         ENDCG
  39.     }
  40.     FallBack "Standard"
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement