uv
2차원텍스처좌표, Float2 =xy =정규화: 0~1
곱한다 > 어두워진다
매쉬를 해체 - 텍스쳐 만들기 - 메테리얼로 적용
Warp Mode에서 repeat / 올웨이즈리플레쉬
> 텍스쳐 좌표 이동
Shader "Custom/nemo"
{
Properties
{
_MainTex("MainTex", 2D) ="white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Standard
#pragma target 3.0
sampler2D _MainTex;
struct Input
{
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
float2 uv = IN.uv_MainTex;
fixed4 c = tex2D (_MainTex, float2(uv.x +0.5 , uv.y + 0.5)); //uv에 0.5 / 텍스쳐 리피트
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
>좌측으로 흐르기
Shader "Custom/nemo"
{
Properties
{
_MainTex("MainTex", 2D) ="white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Standard
#pragma target 3.0
sampler2D _MainTex;
struct Input
{
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
float dir = -1;
float2 uv = IN.uv_MainTex;
fixed4 c = tex2D (_MainTex, float2(uv.x + _Time.y, uv.y)); // 좌측으로 흐르기
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
> Speed 슬라이더 만들어서 위, 아래와 흐르기 속도 조절
Shader "Custom/nemo"
{
Properties
{
_MainTex("MainTex", 2D) ="white" {}
_Speed("Speed", float) = 1
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Standard
#pragma target 3.0
sampler2D _MainTex;
float _Speed;
struct Input
{
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
float dir = -1;
float2 uv = float2(IN.uv_MainTex.x, IN.uv_MainTex.y +(dir *_Time.y *_Speed));
// -1는 아래로 // +는 위로
fixed4 c = tex2D(_MainTex, uv);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
'게임 그래픽 프로그래밍' 카테고리의 다른 글
셰이더6: 버택스 (1) | 2024.09.04 |
---|---|
셰이더5: 불! 타올라라 (0) | 2024.09.04 |
셰이더3: 색 반전 및 밝기 조정 (0) | 2024.09.03 |
셰이더3:lerp함수로 텍스쳐 섞기 (0) | 2024.09.03 |
셰이더3: 텍스쳐 입력 (0) | 2024.09.03 |