모델의 안팎 뒤집어 출력 - 커스텀 버텍스 라이트 생성 - 버텍스 적용 범위 지정 inout appdate_full - 커스텀 라이트 설정 - 1pass에서 뒤집은 걸 다시 정상화 - 원본인 1pass 출력
Shader "Custom/2pass"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_ExColor("ExColor", Color) = (1,1,1,1) // 외곽선 색
_ExThickness("ExThickness", float) =0 // 두께조절
}
SubShader
{
Tags { "RenderType"="Opaque" }
Cull Front // 안팎을 뒤집음
CGPROGRAM // 외곽선인 1pass 시작
#pragma surface surf _NoLight vertex:vert // 버택스 커스텀 라이트 생성
#pragma target 3.0
sampler2D _MainTex;
float4 _ExColor; // 색이니까 알파까지 4
float _ExThickness;
void vert(inout appdata_full v)
{
v.vertex.xyz = v.vertex.xyz + (v.normal.xyz * _ExThickness); // 두께
}
struct Input
{
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o)
{
}
float4 Lighting_NoLight(SurfaceOutput s, float3 lightDir, float atten) // 커스텀 Lighting 여기서 설정해 함수
{
return _ExColor; // 색깔
}
ENDCG // 1pass 끝
Cull Back // 1pass 에서 뒤짚은 걸 정상화
CGPROGRAM // 2pass 시작
#pragma surface surf Lambert
#pragma target 3.0
sampler2D _MainTex;
struct Input
{
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o)
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG //2pass 끝
}
FallBack "Diffuse"
}
'게임 그래픽 프로그래밍' 카테고리의 다른 글
도끼 (0) | 2024.09.06 |
---|---|
셰이더: 외곽선에 색, 텍스쳐 넣기 (0) | 2024.09.05 |
셰이더: 골렘? (1) | 2024.09.04 |
셰이더: lerpf로 텍스쳐 섞기 (1) | 2024.09.04 |
셰이더: 홀로그램 총 만들기 (0) | 2024.09.04 |