게임개발/게임 그래픽 프로그래밍
Dissove
pudding81
2024. 2. 23. 16:14
Shader "Custom/dissolve"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_NoiseTex ("Noise", 2D) = "white" {}
_Cut("Cut",Range(0,1)) = 0 //디졸브 정도
_Outline("outline",Color) =(1,1,1,1) //라인색
_Line("Line",Range(1,2)) = 1.1 //라인두께
}
SubShader
{
Tags { "RenderType"="Transparent" "Queue"="Transparent" }
//1pass
//z버퍼쓰기
ZWrite On
//랜더링안하기
ColorMask 0
CGPROGRAM
#pragma surface surf _Nolight
#pragma target 3.0
struct Input
{
float4 color:COLOR;
};
void surf (Input IN, inout SurfaceOutput o)
{
}
//커스텀라이트
float4 Lighting_Nolight(SurfaceOutput s,float3 lightDir,float atten)
{
return 0;
}
ENDCG
//2pass
//리퍼에 안쓰기
ZWrite Off
CGPROGRAM
#pragma surface surf Lambert alpha:fade //알파블렌드
#pragma target 3.0
sampler2D _MainTex;
sampler2D _NoiseTex;
float _Cut;
float4 _Outline;
float _Line;
struct Input
{
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o)
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
float4 d = tex2D (_NoiseTex, IN.uv_MainTex); //noise
float alpha;
if(d.r>=_Cut) alpha =1;
else alpha =0;
//노이즈 경계색 입히기
float outline;
if (d.r>=_Cut*_Line) outline =0;
else outline =1;
o.Emission =_Outline.rgb* outline;
o.Alpha = alpha;
}
ENDCG
}
FallBack "Diffuse"
}