0504 쉐이더 특정 부분만 반짝거리게 하기
2021. 5. 4. 14:45ㆍunity/쉐이더
방법 #1.
Shader "Custom/rock"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_MainTex2("Albedo (RGB)", 2D) = "white" {}
_BumpMap("Normal Map",2D) = "bump"{}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Standard
sampler2D _MainTex;
sampler2D _MainTex2;
sampler2D _BumpMap;
struct Input
{
float2 uv_MainTex;
float2 uv_MainTex2;
float2 uv_BumpMap;
float4 color:COLOR;
};
half _Glossiness;
half _Metallic;
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
fixed4 d = tex2D(_MainTex2, IN.uv_MainTex2);
fixed3 n = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
o.Albedo = c.rgb;
//o.Albedo = IN.color.rgb;
o.Albedo = lerp(o.Albedo, c, IN.color.r);
o.Albedo = lerp(o.Albedo, d, IN.color.b);
o.Smoothness = _Glossiness * IN.color.r;
o.Normal = n;
}
ENDCG
}
FallBack "Diffuse"
}
방법 #2. 더 정교하게 수치를 조장할 수 있도록
Shader "Custom/rock"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_MainTex2("Albedo (RGB)", 2D) = "white" {}
_BumpMap("Normal Map",2D) = "bump"{}
_Smoothness("Smoothness", Range(0,1)) = 0
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Standard
sampler2D _MainTex;
sampler2D _MainTex2;
sampler2D _BumpMap;
struct Input
{
float2 uv_MainTex;
float2 uv_MainTex2;
float2 uv_BumpMap;
float4 color:COLOR;
};
half _Glossiness;
half _Metallic;
float _Smoothness;
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
fixed4 d = tex2D(_MainTex2, IN.uv_MainTex2);
fixed3 n = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
o.Albedo = c.rgb;
//o.Albedo = IN.color.rgb;
o.Albedo = lerp(o.Albedo, c, IN.color.r);
o.Albedo = lerp(o.Albedo, d, IN.color.b);
o.Smoothness = (IN.color.r * 0.5) * _Smoothness;
o.Normal = n;
}
ENDCG
}
FallBack "Diffuse"
}
'unity > 쉐이더' 카테고리의 다른 글
0506 쉐이더 라이트닝 연산 (0) | 2021.05.06 |
---|---|
0504 쉐이더 커스텀 라이트 Lambert, BlinnPhong, Standard (0) | 2021.05.04 |
0504 버텍스에 컬러 입히고 다중 텍스쳐 반영하기 (0) | 2021.05.04 |
0503 쉐이더를 이용해서 불 이펙트 만들기 (0) | 2021.05.03 |
0503 쉐이더 UV (0) | 2021.05.03 |