Shader "Custom/Metalic"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
_BumpMap("Normalmap", 2D) = "bump" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Standard fullforwardshadows
#pragma target 3.0
sampler2D _MainTex;
sampler2D _BumpMap;
struct Input
{
float2 uv_MainTex;
float2 uv_BumpMap;
};
half _Smoothness;
half _Metallic;
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
fixed4 n = tex2D(_BumpMap, IN.uv_BumpMap);
float3 normal = UnpackNormal(n);
o.Normal = float3(normal.x * 2, normal.y * 2, normal.z);
o.Albedo = c.rgb;
o.Metallic = _Metallic;
o.Smoothness = _Smoothness;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
+++
NomalMap의 강도 조절바 추가해서 조절 해보기
Shader "Custom/Metalic"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
_BumpMap("Normalmap", 2D) = "bump" {}
_NormalStength("Normal Stength", Range(0.1, 2)) = 0
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Standard fullforwardshadows
#pragma target 3.0
sampler2D _MainTex;
sampler2D _BumpMap;
float _NormalStength;
struct Input
{
float2 uv_MainTex;
float2 uv_BumpMap;
};
half _Smoothness;
half _Metallic;
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
fixed4 n = tex2D(_BumpMap, IN.uv_BumpMap);
float3 normal = UnpackNormal(n);
o.Normal = float3(normal.x * _NormalStength, normal.y * _NormalStength, normal.z);
o.Albedo = c.rgb;
o.Metallic = _Metallic;
o.Smoothness = _Smoothness;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
+++
Occlusion 적용하기
미세하게 음영이 짙어진 것이 눈에 보인다.
Shader "Custom/Metalic"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
_BumpMap("Normalmap", 2D) = "bump" {}
_NormalStength("Normal Stength", Range(0.1, 2)) = 0
_Occlusion("Occlusion", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Standard fullforwardshadows
#pragma target 3.0
sampler2D _MainTex;
sampler2D _BumpMap;
sampler2D _Occlusion;
float _NormalStength;
struct Input
{
float2 uv_MainTex;
float2 uv_BumpMap;
};
half _Smoothness;
half _Metallic;
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
fixed4 n = tex2D(_BumpMap, IN.uv_BumpMap);
fixed4 occlusion = tex2D(_Occlusion, IN.uv_MainTex);
o.Occlusion = occlusion;
float3 normal = UnpackNormal(n);
o.Normal = float3(normal.x * _NormalStength, normal.y * _NormalStength, normal.z);
o.Albedo = c.rgb;
o.Metallic = _Metallic;
o.Smoothness = _Smoothness;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
'산대특 > 게임 그래픽 프로그래밍' 카테고리의 다른 글
[LearnShader] NPR 렌더링 - 외곽선의 두께와 색깔을 조절해보기 (0) | 2024.02.21 |
---|---|
[LearnShader] NPR 렌더링 - 2Pass로 외곽선 그리기 (0) | 2024.02.21 |
[LearnShader] 스켈레톤에 버텍스 컬러 및 홀로그램 적용 연습해보기 (0) | 2024.02.21 |
[LearnShader] 홀로그램 만들어보기 (0) | 2024.02.20 |
[LearnShader] SurfaceShader (1) (0) | 2024.02.18 |