게임클라이언트 프로그래밍/Unity
Shader(UV 텍스쳐 합치기, VertexColor,Metallic, Smoothness_Time,_BumpMap,_Metallic,_Smoothness)
Game Client Lee Hwanguk
2023. 3. 16. 01:40
#UV
*두개의 텍스쳐 합치기
Shader "Custom/Fire2"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_MainTex2("Albedo (RGB)", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Trasparent" "Queue"="Trasparent"}
LOD 200
CGPROGRAM
#pragma surface surf Standard alpha:fade
#pragma target 3.0
sampler2D _MainTex;
sampler2D _MainTex2;
struct Input
{
float2 uv_MainTex;
float2 uv_MainTex2;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 d = tex2D (_MainTex2, IN.uv_MainTex2); //black
fixed4 c = tex2D(_MainTex, IN.uv_MainTex+d.r); //fire
o.Emission = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
*_Time과 텍스트를 이용해 이미지를 이동, 구겨지게 만들기
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 d = tex2D(_MainTex2, float2(IN.uv_MainTex2.x, IN.uv_MainTex2.y - _Time.y)); //texture2
fixed4 c = tex2D(_MainTex, IN.uv_MainTex+d.r); //texture
o.Emission = c.rgb;
o.Alpha = c.a;
}
#VertexColor
Shader "Custom/VertexColor2"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_MainTex2("Albedo (RGB)", 2D) = "white" {}
_MainTex3("Albedo (RGB)", 2D) = "white" {}
_MainTex4("Albedo (RGB)", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Standard noambient
#pragma target 3.0
sampler2D _MainTex;
sampler2D _MainTex2;
sampler2D _MainTex3;
sampler2D _MainTex4;
struct Input
{
float2 uv_MainTex;
float2 uv_MainTex2;
float2 uv_MainTex3;
float2 uv_MainTex4;
float4 color:COLOR;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
fixed4 d = tex2D(_MainTex2, IN.uv_MainTex2);
fixed4 e = tex2D(_MainTex3, IN.uv_MainTex3);
fixed4 f = tex2D(_MainTex4, IN.uv_MainTex4);
o.Albedo = lerp(c.rgb,d.rgb,IN.color.r);
o.Albedo = lerp(o.Albedo, e.rgb, IN.color.g);
o.Albedo = lerp(o.Albedo, f.rgb, IN.color.b);
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
*Metallic, Smoothness (금속 느낌)
Shader "Custom/Surface2"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Metallic("Metallic",Range(0,1))=0
_Smoothness("Smoothness",Range(0,1))=0.5
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Standard fullforwardshadows
#pragma target 3.0
sampler2D _MainTex;
float _Metallic;
float _Smoothness;
struct Input
{
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Metallic = _Metallic;
o.Smoothness = _Smoothness;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
#Normal map (질감)
Shader "Custom/Surface2"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Metallic("Metallic",Range(0,1))=0
_Smoothness("Smoothness",Range(0,1))=0.5
_BumpMap("Norlmap",2D) = "bump"{}
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Standard
#pragma target 3.0
sampler2D _MainTex;
sampler2D _BumpMap;
float _Metallic;
float _Smoothness;
struct Input
{
float2 uv_MainTex;
float2 uv_BumpMap;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
o.Albedo = c.rgb;
o.Metallic = _Metallic;
o.Smoothness = _Smoothness;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
*Occlusion (음영 효과)
Shader "Custom/Surface2"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Metallic("Metallic",Range(0,1))=0
_Smoothness("Smoothness",Range(0,1))=0.5
_BumpMap("Norlmap",2D) = "bump"{}
_Occlusion("Occulusion",2D) = "white"{}
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Standard
#pragma target 3.0
sampler2D _MainTex;
sampler2D _BumpMap;
sampler2D _Occlusion;
float _Metallic;
float _Smoothness;
struct Input
{
float2 uv_MainTex;
float2 uv_BumpMap;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Occlusion = tex2D(_Occlusion, IN.uv_MainTex);
o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
o.Albedo = c.rgb;
o.Metallic = _Metallic;
o.Smoothness = _Smoothness;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
#_BumpMap,_Metallic,_Smoothness 적용
Shader "Custom/VertexColor2"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_MainTex2("Albedo (RGB)", 2D) = "white" {}
_MainTex3("Albedo (RGB)", 2D) = "white" {}
_MainTex4("Albedo (RGB)", 2D) = "white" {}
_BumpMap("Normalmap",2D) = "bump"{}
_Metallic("Metallic",Range(0,1)) = 0
_Smoothness("Smoothness",Range(0,1))=1
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Standard noambient
#pragma target 3.0
sampler2D _MainTex;
sampler2D _MainTex2;
sampler2D _MainTex3;
sampler2D _MainTex4;
sampler2D _BumpMap;
float _Metallic;
float _Smoothness;
struct Input
{
float2 uv_MainTex;
float2 uv_MainTex2;
float2 uv_MainTex3;
float2 uv_MainTex4;
float2 uv_BumpMap;
float4 color:COLOR;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
fixed4 d = tex2D(_MainTex2, IN.uv_MainTex2);
fixed4 e = tex2D(_MainTex3, IN.uv_MainTex3);
fixed4 f = tex2D(_MainTex4, IN.uv_MainTex4);
o.Albedo = lerp(c.rgb,d.rgb,IN.color.r);
o.Albedo = lerp(o.Albedo, e.rgb, IN.color.g);
o.Albedo = lerp(o.Albedo, f.rgb, IN.color.b);
o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
o.Metallic = _Metallic;
o.Smoothness = (IN.color.b * 0.5) * _Smoothness + 0.3;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}