Properties {
_MainTex ("Texture", 2D) = "white" {}
_NoiseTex ("Noise Texture", 2D) = "white" {}
_Color ("Main Color", Color) = (1,1,1,1)
_GlowColor ("Glow Color", Color) = (0,0.5,1,1)
_DissolveAmount ("Dissolve Amount",Range(0,1)) = 0
_StripeWidth ("Stripe Width", Range(1,50)) = 10
_StripeSpeed ("Stripe Speed", Range(0,10)) = 1
_StripeIntensity ("Stripe Intensity",Range(0,1)) = 0.5
_GlitchIntensity ("Glitch Intensity",Range(0,1)) = 0.3
_EdgeWidth ("Edge Width", Range(0,0.2))= 0.05
}
이 블록이 Inspector에 노출되는 UI를 정의하며, 각 이름이 CGPROGRAM 내부의 uniform 변수와 1:1 매핑됩니다.
SubShader {
Tags { "RenderType"="Transparent" "Queue"="Transparent" }
LOD 100
Blend SrcAlpha OneMinusSrcAlpha
Cull Off
ZWrite On
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 3.0
#include "UnityCG.cginc"
// … uniform, struct, 함수, vert/frag 정의 …
ENDCG
}
}
FallBack "Diffuse"
Tags
"RenderType"="Transparent": 투명 오브젝트로 분류"Queue"="Transparent": 렌더 큐를 투명(3000+)으로 설정Blend: 알파 블렌딩
Cull Off: 양면 렌더링
ZWrite On: Z-버퍼에 쓰기 (디졸브 진행 중에도 깊이 정보 유지)
Uniform 선언
_MainTex, _NoiseTex, _Color 등 Properties에서 매핑된 변수들구조체 정의
appdata: 버텍스 입력 (위치, UV, 노말)v2f:VERT → FRAG 전달 (클립좌표, UV, 월드Pos, 노말, 노이즈 값)도우미 함수
rand(): UV 기반 랜덤값 생성sampleNoise(): 노이즈 텍스처 샘플링applyGlitch(): 버텍스 위치 글리치vert()
_DissolveAmount에 따라 applyGlitch 호출 → 오프셋된 버텍스 월드·클립 변환 → UV, 월드 위치·노말 전달frag()
sin(worldPos.y * _StripeWidth + time)dissolveNoise_Colorstep()으로 디졸브 & 엣지 마스크 분리_GlowColor) & 스트라이프 깜빡임(알파 보정)1 – dissolveMask에 스트라이프 알파 변조임포트 설정
Custom/DigitalStripeDissolve 선택_Color / _GlowColor: 원하는 베이스·발광 색상 선택
Stripe / Glitch 값들
MaterialPropertyBlock 또는 매 프레임 스크립트로 _DissolveAmount 값을 0→1로 서서히 변화
예시 (C#):
IEnumerator AnimateDissolve(Material mat) {
float t = 0;
while (t < 1f) {
mat.SetFloat("_DissolveAmount", t);
t += Time.deltaTime;
yield return null;
}
mat.SetFloat("_DissolveAmount", 1f);
}
Material을 사용하는 오브젝트가 카메라에 보이도록 배치#pragma target 2.0을 시도해 보세요 (단 기능 일부 제한)