빈오브젝트 만들기
Mesh Filter 컴포넌트 추가 -> 골룸 메쉬 넣어주기
Mesh Renderer 컴포넌트 추가 -> 새로 만든 Material 넣어주기
골룸에 폴리브러쉬로 버텍스 컬러 출력하기
기본 쉐이더 만들고 폴리브러쉬 색칠하기
Shader "Custom/Golem"
{
Properties
{
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Standard fullforwardshadows
#pragma target 3.0
struct Input
{
float4 color:COLOR;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
o.Albedo = IN.color.rgb; //브러쉬 색칠하기
}
ENDCG
}
FallBack "Diffuse"
}
Shader "Custom/Golem"
{
Properties
{
_MainTex ("Golem", 2D) = "white" {}
_RedTex ("RedTex", 2D) = "white" {}
_BlueTex ("BlueTex", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Standard fullforwardshadows
#pragma target 3.0
sampler2D _MainTex;
sampler2D _RedTex;
sampler2D _BlueTex;
struct Input
{
float4 color :COLOR;
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
o.Albedo = IN.color.rgb; // 브러쉬 색칠 먼저 해주기
fixed4 body = tex2D (_MainTex, IN.uv_MainTex);
float4 red = tex2D(_RedTex,float2(IN.uv_MainTex.x,IN.uv_MainTex.y+_Time.y));
o.Albedo =lerp(body,red,IN.color.r);// 브러쉬 d.r
float4 blue = tex2D(_BlueTex,float2(IN.uv_MainTex.x,IN.uv_MainTex.y+_Time.y));
o.Albedo =lerp(o.Albedo,blue,IN.color.b);// 브러쉬 d.r
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
// o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
메쉬 스크립트 저장해서 원래 골룸 프리팹에 넣어주고
재생을 누르면 골룸 애니메이션 작동~
'게임개발 > 게임 그래픽 프로그래밍' 카테고리의 다른 글
Standard - Lambert -HalfLambert (0) | 2024.02.20 |
---|---|
커스텀 라이트 만들기 (0) | 2024.02.20 |
불 이펙트 만들기 (0) | 2024.02.19 |
Lerp 함수 사용하기 (0) | 2024.02.16 |
SurfaceShader 시작하기 (0) | 2024.02.16 |