Advertisement
axoila

textures.shader

Mar 23rd, 2018
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Tutorial/03_Textures"{
  2.     Properties{
  3.         _Color ("Tint", Color) = (0, 0, 0, 1)
  4.         _MainTex ("Texture", 2D) = "white" {}
  5.     }
  6.  
  7.     SubShader{
  8.         Tags{ "RenderType"="Opaque" "Queue"="Geometry"}
  9.  
  10.         Pass{
  11.             CGPROGRAM
  12.  
  13.             #include "UnityCG.cginc"
  14.  
  15.             #pragma vertex vert
  16.             #pragma fragment frag
  17.  
  18.             sampler2D _MainTex;
  19.             float4 _MainTex_ST;
  20.  
  21.             fixed4 _Color;
  22.  
  23.             struct appdata{
  24.                 float4 vertex : POSITION;
  25.                 float2 uv : TEXCOORD0;
  26.             };
  27.  
  28.             struct v2f{
  29.                 float4 position : SV_POSITION;
  30.                 float2 uv : TEXCOORD0;
  31.             };
  32.  
  33.             v2f vert(appdata v){
  34.                 v2f o;
  35.                 o.position = UnityObjectToClipPos(v.vertex);
  36.                 o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  37.                 return o;
  38.             }
  39.  
  40.             fixed4 frag(v2f i) : SV_TARGET{
  41.                 fixed4 col = tex2D(_MainTex, i.uv);
  42.                 col *= _Color;
  43.                 return col;
  44.             }
  45.  
  46.             ENDCG
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement