Last active
June 18, 2016 15:26
-
-
Save smokelore/fde56060ca7ac23edd86cf99e2e1e208 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "CookbookShaders/TexturedShader" | |
{ | |
Properties | |
{ | |
... | |
// In the properties section we can refer to a texture like this: | |
_MainTex ("Albedo (RGB)", 2D) = "white" {}] | |
... | |
} | |
SubShader { | |
Tags { "RenderType"="Opaque" } | |
LOD 200 | |
CGPROGRAM | |
#pragma surface surf Standard fullforwardshadows | |
#pragma target 3.0 | |
// In the CGProgram section the texture is defined as sampler2D, the standard type for 2D textures: | |
sampler2D _MainTex; | |
// This is the input parameter for the surface function and contains a packed array | |
struct Input | |
{ | |
float2 uv_MainTex; | |
}; | |
... | |
void surf (Input IN, inout SurfaceOutputStandard o) | |
{ | |
// Every time the surf() surface function is called, the Input structure will contain | |
// the UV of _MainTex for the specific point of the 3D model that needs to be rendered. | |
// The shader recognizes the name uv_MainTex and initializes it automatically. | |
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; | |
... | |
} | |
ENDCG | |
} | |
FallBack "Diffuse" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment