셰이더 (Shader)/유니티 쉐이더 스타트업 - 정종필
[Unity/Shader] 파트12-3 : 홀로그램 제작
Minkyu Lee
2023. 8. 17. 01:01


뷰포트 애니메이션 활성화 방법

핵심 제작법
외곽선 : 내적
줄무늬 : 월드 포지션을 frac한 것에 시간으로 offset을 준 것이다.
코드
Shader "Custom/Part12-1"
{
Properties
{
_BumpMap("NormalMap", 2D) = "bump" {}
}
SubShader
{
Tags { "RenderType"="Transparent" "Queue" = "Transparent" } // 반투명 재질로 적용
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf nolight noambient alpha:fade
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _BumpMap;
struct Input
{
float2 uv_BumpMap;
float3 viewDir;
float3 worldPos;
};
UNITY_INSTANCING_BUFFER_START(Props)
// put more per-instance properties here
UNITY_INSTANCING_BUFFER_END(Props)
void surf (Input IN, inout SurfaceOutput o)
{
o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
o.Emission = float3(0,1,0);
// 윤곽선
float rim = 1-saturate(dot(o.Normal, IN.viewDir));
rim = pow(rim, 3);
// 줄무늬
rim += pow(frac(IN.worldPos.g * 3 - _Time.y), 5)*0.1;
rim = saturate(rim);
o.Alpha = rim; // 알파로 사용한다.
}
float4 Lightingnolight(SurfaceOutput s, float3 lightDir, float atten)
{
return float4(0,0,0,s.Alpha); // 오직 알파만 리턴하는 커스텀 라이트이다.
}
ENDCG
}
FallBack "Diffuse"
}