1.
Shader "Custom/Metalic"
{
Properties
{
_MainTex("Main Texture 2D", 2D) = "white"{}
_Metallic("Metalic", Range(0, 1)) = 0
_Smoothness ("Smoothness", Range(0, 1)) = 0.5
_BumpMap("Normalmap", 2D) = "bump" {}
_NormalXStrength("Normal StrengthX", Range(1, 3)) = 1
_NormalYStrength("Normal StrengthY", Range(1, 3)) = 1
_Occlusion("Occlusion", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Standard
#pragma target 3.0
// 2D 변수
sampler2D _MainTex;
sampler2D _BumpMap;
sampler2D _Occlusion;
// 변수 정의
float _Metallic;
float _Smoothness;
float _NormalXStrength;
float _NormalYStrength;
struct Input
{
float4 color:COLOR;
float2 uv_MainTex;
float2 uv_BumpMap;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
// color 값 넣기 (가져오기)
float4 c = tex2D(_MainTex, IN.uv_MainTex);
float4 n = tex2D(_BumpMap, IN.uv_BumpMap); // 노멀맵의 픽셀을 가져온다
float3 normal = UnpackNormal(n); // 가져온 픽셀값을 추출 한다
o.Normal = float3(normal.x * _NormalXStrength, normal.y * _NormalYStrength, normal.z); //노멀 적용
float4 occlusion = tex2D(_Occlusion, IN.uv_MainTex); // 오클루전
o.Occlusion = occlusion;
o.Albedo = c.rgb;
o.Albedo = n.rgb;
// 구조체 변수에 할당
o.Metallic = _Metallic;
o.Smoothness = _Smoothness;
//o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
'[학원 Unity] > [게임 그래픽 프로그래밍]' 카테고리의 다른 글
그래픽스) 시험 내용 정리 (0) | 2024.09.09 |
---|---|
09-05 수업내용 ) NPR 렌더링 (0) | 2024.09.05 |
09-03 ) 버텍스 컬러 (0) | 2024.09.03 |
09-03 수업내용 ) UV 이미지 이용해보기 (0) | 2024.09.03 |
09-02 두번째 수업내용 (0) | 2024.09.02 |