SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200

기본

CGPROGRAM

중요하지만 이름이 없음.

// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard fullforwardshadows

// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0

설정부분 스니핏(snippet)
쉐이더의 조명계산 설정이나, 세부적인 분기를 정해주는 부분

sampler2D _MainTex;

중요하지만 이름이 없음.
대소문자를 중요하게 생각하세요.

struct Input
{
float2 uv_MainTex;
};

Input이라는 구조체(structure)입니다.
엔진으로 부터 받아와야할 데이터가 들어갑니다.

{ }
안에 들어 있으며, ; 끝에 있다.

uv uv 2개의 숫자로 float2이며, MainTax uv라는 뜻으로
uv_MainTex
처럼 텍스쳐 샘플러 이름 앞에 uv라는 글자를 붙입니다.

half _Glossiness;
half _Metallic;
fixed4 _Color;

중요하지만 이름이 없음.

void surf (Input IN, inout SurfaceOutputStandard o)
{
// Albedo comes from a texture tinted by color
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
// Metallic and smoothness come from slider variables
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = c.a;
}

surf라는 이름의 함수 영역.
색상이나 이미지가 출력되는 부분을 만들수 있다.
;
없다.

fixed4 c라는 변수를 선언하였습니다.
float
보다 1/2 half(16비트), fixed(11비트) 필요에 따라 사용됩니다.
대부분 텍스쳐컬러는 8비트 이하이므로 fixed 충분하기 때문에 사용.
float
사용해도 무방합니다.
float4
결과 = text2D(샘플러, UV)

ENDCG

중요하지만 이름이 없음.

 

'Unity > Surface Shader' 카테고리의 다른 글

texture  (0) 2020.05.16
CGPROGRAM03  (0) 2020.05.16
CGPROGRAM02  (0) 2020.05.16
Propeties  (0) 2020.05.16
기초  (0) 2020.05.16