0503 쉐이더 UV
2021. 5. 3. 16:50ㆍunity/쉐이더
가로는 U, 세로는 V
둘을 시각적으로 나타내기
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
o.Albedo = IN.uv_MainTex.x;
}
ENDCG
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
o.Albedo = IN.uv_MainTex.y;
}
ENDCG
Shader "Custom/Test"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_V("v value",Range(-1,1)) = 0
_U("u value",Range(-1,1)) = 0
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Standard fullforwardshadows
sampler2D _MainTex;
struct Input
{
float2 uv_MainTex;
};
float _V;
float _U;
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D(_MainTex, float2(IN.uv_MainTex.x+_U, IN.uv_MainTex.y+_V));
o.Albedo = c.rgb;
}
ENDCG
}
FallBack "Diffuse"
}
x축으로만 흘러가도록 할 때
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D(_MainTex, float2(IN.uv_MainTex.x + _Time.y, IN.uv_MainTex.y));
o.Albedo = c.rgb;
}
ENDCG
y축으로만 흘러가도록 할때
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D(_MainTex, float2(IN.uv_MainTex.x, IN.uv_MainTex.y + _Time.y));
o.Albedo = c.rgb;
}
ENDCG
xy축 동시에 흘러가도록 할 때
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D(_MainTex, float2(IN.uv_MainTex.x, IN.uv_MainTex.y)+_Time.y);
o.Albedo = c.rgb;
}
ENDCG
흘러가는 속도를 조절하는 슬라이더 만들기
Properties
{
_MainTex("Albedo (RGB)", 2D) = "white" {}
_Speed("Speed",Range(0,1)) = 0
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Standard fullforwardshadows
sampler2D _MainTex;
struct Input
{
float2 uv_MainTex;
};
float _Speed;
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D(_MainTex, float2(IN.uv_MainTex.x, IN.uv_MainTex.y)+_Time.y*_Speed);
o.Albedo = c.rgb;
}
ENDCG
}
FallBack "Diffuse"
}
'unity > 쉐이더' 카테고리의 다른 글
0504 쉐이더 커스텀 라이트 Lambert, BlinnPhong, Standard (0) | 2021.05.04 |
---|---|
0504 쉐이더 특정 부분만 반짝거리게 하기 (0) | 2021.05.04 |
0504 버텍스에 컬러 입히고 다중 텍스쳐 반영하기 (0) | 2021.05.04 |
0503 쉐이더를 이용해서 불 이펙트 만들기 (0) | 2021.05.03 |
0503 쉐이더 기본 (0) | 2021.05.03 |