Last active
May 23, 2019 07:08
-
-
Save gkagm2/9923aea282cce00009bf608cb7c7a53e 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 "Custom/Tex" { | |
Properties { | |
/// | |
/// "Albedo (RGB)" : Albedo 텍스쳐를 넣는 곳이고, 알파는 사용하지 않고 RGB 채널만 사용하겠다는 의미. | |
/// 2D : 이 인터페이스가 2D 텍스쳐를 받는 부분이라는 의미. | |
/// "white"{} : 는 이 텍스쳐가 인터페이스가 처음 생겨서 아무것도 들어 있지 않을 때. 흰색 텍스쳐가 들어있다고 생각되도록 만들라는 의미 | |
_MainTex ("Albedo (RGB)", 2D) = "white" {} // 텍스쳐를 입력받는 변수. | |
} | |
SubShader { | |
Tags { "RenderType"="Opaque" } | |
CGPROGRAM | |
// Physically based Standard lighting model, and enable shadows on all light types | |
#pragma surface surf Standard fullforwardshadows | |
// 텍스쳐는 uv와 만나기 전까지는 그냥 메모리에 올라와 있는 텍스쳐일 뿐이고, UV와 만나서 제대로 자리를 잡아야 비로소 float4로 표현할 수 있게 됩니다. 따라서 현재 이 텍스쳐는 float4_MainTex라고 선언하면 안되고, 아직은 “sampler”라고 불리는 sampler2D로 선언한 것. | |
sampler2D _MainTex; // 여기서 입력 받는 텍스쳐를 sampler로 받게 된다. | |
struct Input { | |
float2 uv_MainTex; | |
}; | |
fixed4 _Color; | |
void surf (Input IN, inout SurfaceOutputStandard o) { | |
fixed4 c = tex2D (_MainTex, IN.uv_MainTex); | |
o.Albedo = c.rgb; | |
o.Alpha = c.a; | |
} | |
ENDCG | |
} | |
FallBack "Diffuse" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment