#하나. 불 셰이더 만들기(두 개의 셰이더를 혼합하고 _Time을 사용하여 이동)
Shader "Custom/Fire"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_MainTex2 ("Albedo (RGB)", 2D) = "white" {}
_STRENGH("Strengh",Range(1,4))=1
}
SubShader
{
Tags { "RenderType"="Transparent""Queue"="Transparent"} //Opaque , Transparent 투명도
LOD 200
CGPROGRAM
#pragma surface surf Standard alpha:fade
sampler2D _MainTex;
sampler2D _MainTex2;
float _STRENGH;
struct Input
{
float2 uv_MainTex;
float2 uv_MainTex2;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 d = tex2D(_MainTex2, float2(IN.uv_MainTex2.x, IN.uv_MainTex2.y -_Time.y));
fixed4 c = tex2D (_MainTex, IN.uv_MainTex+d.r* _STRENGH); //(u+0,v+0) ,d.r=0
o.Emission =c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
#텍스처 블렌딩 (2개의 텍스처를 섞어서 r영역에서만 블렌딩)
Shader "Custom/Golem"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_MainTex2("Albedo (RGB)", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Standard fullforwardshadows
sampler2D _MainTex;
sampler2D _MainTex2;
struct Input
{
float2 uv_MainTex;
float2 uv_MainTex2;
float4 color:COLOR;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
fixed4 d = tex2D(_MainTex2, IN.uv_MainTex2);
o.Albedo = lerp(c.rgb,d.rgb,IN.color.r);
//o.Albedo = IN.color.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}

#홀로그램 만들기(2Pass AlphaBlend 사용)
Shader "Custom/Blend"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_HoloColor("holo color",Color) = (1,1,1,1) //holo color추가
_BumpMap("BumpMap",2D) = "bump"{} //bump map
}
SubShader
{
Tags { "RenderType"="Transparent""Queue"="Transparent"} //반투명
ZWrite On //default
ColorMask 0 //아무것도 그리지 않는다
//1pass
CGPROGRAM
#pragma surface surf _NoLight //noambient alpha:fade 반투명
struct Input
{
float4 color:COLOR;
};
void surf (Input IN, inout SurfaceOutput o)
{
}
float4 Lighting_NoLight(SurfaceOutput s, float3 lightDir, float atten)
{
return float4(0, 0, 0, 0);
}
ENDCG
ZWrite Off
//2pass
CGPROGRAM
#pragma surface surf _NoLight alpha:fade
sampler2D _MainTex;
sampler2D _BumpMap;
float4 _HoloColor;
struct Input
{
float2 uv_MainTex;
float2 uv_BumpMap;
float3 viewDir;
float3 worldPos;
};
void surf(Input IN, inout SurfaceOutput o)
{
//노멀맵적용
float3 n = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
o.Normal = n;
//프레넬
float ndotv = max(0, dot(o.Normal, IN.viewDir));
float rim = pow(1 - ndotv, 3); //프래넬 반전
//움직이는 라인만들기
rim += pow(frac(IN.worldPos.g * 10 - _Time.y), 30);
//컬러 적용
o.Emission = _HoloColor.rgb; //0~0.99 // _HoloColor;
//알파
o.Alpha = rim;
}
float4 Lighting_NoLight(SurfaceOutput s, float3 lightDir, float atten)
{
return float4(0, 0, 0, s.Alpha);
}
ENDCG
}
FallBack "Diffuse"
}
#아웃라인 셰이더(1패스, 2패스, 색상 및 두께 조정)
*1pass 이용방법
*2pass 이용방법
Shader "Custom/toon"
{
Properties
{
_MainTex("Main Texture", 2D) = "white"{}
_PatternTex("Panttern Texture", 2D) = "white"{}
_OutlineThickness("outline thickness", Range(0, 1)) = 0
_HandThickness("hand thickness", Range(0, 1)) = 0
}
SubShader
{
Tags { "RenderType" = "Opaque" }
Cull Front
CGPROGRAM
#pragma surface surf _NoLight vertex:vert
#pragma target 3.0
float _OutlineThickness;
float _HandThickness;
void vert(inout appdata_full v)
{
v.vertex.xyz += v.normal.xyz * _OutlineThickness;
v.vertex.xyz += v.normal.xyz * _HandThickness * v.color.rgb; //흰색
}
sampler2D _PatternTex;
struct Input
{
float2 uv_PatternTex;
};
void surf(Input IN, inout SurfaceOutput o)
{
}
float4 Lighting_NoLight(SurfaceOutput s, float3 lightDir, float atten)
{
return float4(0, 0, 0, 1);
}
ENDCG
//2pass 시작
Cull Back
CGPROGRAM
#pragma surface surf Lambert vertex:vert
#pragma target 3.0
float _HandThickness;
void vert(inout appdata_full v) {
v.vertex.xyz = v.vertex.xyz + (v.normal.xyz * _HandThickness * v.color.rgb);
}
sampler2D _MainTex;
struct Input
{
float2 uv_MainTex;
float4 color:COLOR;
};
void surf(Input IN, inout SurfaceOutput o)
{
float4 c = tex2D(_MainTex, IN.uv_MainTex);
o.Emission = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
#디퓨저(램프 텍스처)
Shader "Custom/warp"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_RampTex("Ramp",2D) = "white"{}
_BumpTex("Normal",2D) = "bump"{}
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf _Toon noambient
#pragma target 3.0
sampler2D _MainTex;
sampler2D _RampTex;
sampler2D _BumpTex;
struct Input
{
float2 uv_MainTex;
float2 uv_BumpTex;
};
void surf (Input IN, inout SurfaceOutput o)
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
//o.Normal = UnpackNormal(tex2D(_BumpMap,IN.uv_BumpTex));
o.Albedo = c.rgb;
o.Alpha = c.a;
}
float4 Lighting_Toon(SurfaceOutput s, float3 lightDir, float3 viewDir, float atten)
{
float4 final;
float ndotl = dot(s.Normal, lightDir)*0.5+0.5; //half lambert
float3 h = normalize(lightDir + viewDir);
float spec = dot(s.Normal, h);
float4 ramp = tex2D(_RampTex, float2(ndotl, spec));
final.rgb = s.Albedo * (ramp.rgb * 0.5 + 0.5);// +pow(spec, 100)*_LightColor0.rgb;
final.a = 1;
return final;
}
ENDCG
}
FallBack "Diffuse"
}

#워터 셰이더(높이, 속도 제어)
#dissolve(윤곽선, 사후 음영 처리)
Shader "Custom/Disolbe"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_NoiseTex("Noise",2D) = "white"{}
_Cut("cut",Range(0,1))=0
_Thickness("thickness",Range(1,2))=1.1
(HDR)_Color("color",Color)=(1,1,1,1)
}
SubShader
{
Tags { "RenderType"="Transparent""Queue"="Transparent"}
ZWrite On
ColorMask 0 //채널을 그리지 않는다
//1pass
CGPROGRAM
#pragma surface surf _NoLight
#pragma target 3.0
sampler2D _MainTex;
struct Input
{
float4 color:COLOR;
};
void surf (Input IN, inout SurfaceOutput o)
{
}
float4 Lighting_NoLight(SurfaceOutput s, float3 lightDir, float atte)
{
return 0;
}
ENDCG
ZWrite Off
//2pass
CGPROGRAM
#pragma surface surf Lambert alpha:fade
#pragma target 3.0
sampler2D _MainTex;
sampler2D _NoiseTex;
float _Cut;
float _Thickness;
float4 _Color;
struct Input
{
float2 uv_MainTex;
float2 uv_NoiseTex;
};
void surf(Input IN, inout SurfaceOutput o)
{
fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
fixed4 noise = tex2D(_NoiseTex, IN.uv_NoiseTex);
o.Albedo = c.rgb;
float alpha;
if (noise.r > _Cut)
alpha = 1;
else
alpha = 0;
float outline;
if (noise.r >= _Cut * _Thickness) {
outline = 0*_Color;
}
else {
outline = 1;
}
o.Emission = outline*_Color.rgb;
o.Alpha = alpha;
}
ENDCG
}
FallBack "Diffuse"
}