Notice
Recent Posts
Recent Comments
Link
스토리지
[5.4] PolyBrush & Vertex Color을 이용해서 특정 영역 색칠 후 텍스쳐 삽입 본문
- 모든 면을 검정으로 칠함 => 변수를 0으로 초기화 하는 것과 비슷한 맥락이다.
- Color Mask를 지정하지 않고 칠해도 된다.
- 특정 Texture가 들어갈 위치에 색을 칠한다.
- 코드로 연결 ( CG : lerp 함수 이용 )
Stone.shader
Shader "Custom/Stone"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_SubTex ("Albedo (RGB)", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Standard fullforwardshadows
sampler2D _MainTex;
sampler2D _SubTex;
struct Input
{
float2 uv_MainTex;
float2 uv_SubTex;
float4 color:COLOR;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
fixed4 d = tex2D (_SubTex, IN.uv_SubTex);
//빨간색이 조금이라도 포함된 부분에 텍스쳐가 들어감.
o.Albedo = lerp(c.rgb, d.rgb, IN.color.r);
o.Alpha = c.a;
//Vertex Color 색을 확인하기 위한 테스트 코드
// o.Albedo = IN.color.rgb;
}
ENDCG
}
FallBack "Diffuse"
}
'Unity > Shader' 카테고리의 다른 글
[5.4] Ambient Occlusion (0) | 2021.05.04 |
---|---|
[5.4] 금속의 울퉁불퉁함을 표현 - Shader Normal (0) | 2021.05.04 |
[5.4] 색깔 영역에 각각 다른 텍스쳐 삽입 (0) | 2021.05.04 |
[5.4] Shader 복습 1 (0) | 2021.05.04 |
[5.3] 불 이펙트 만들기 (0) | 2021.05.03 |
Comments