Skip to content

Instantly share code, notes, and snippets.

@baobao
Last active December 7, 2018 03:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baobao/c89362f9469cf9bd6fe784038bf36793 to your computer and use it in GitHub Desktop.
Save baobao/c89362f9469cf9bd6fe784038bf36793 to your computer and use it in GitHub Desktop.
Shader "Hidden/VerticalScroll"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
CGINCLUDE
#include "UnityCG.cginc"
sampler2D _MainTex;
float _ScrollValue;
fixed4 frag (v2f_img i) : SV_Target
{
float u = i.uv.x;
float v = i.uv.y;
// 小数点部分だけをオフセットする
// fracは小数点だけを残す関数
v = frac(v + _ScrollValue);
return tex2D(_MainTex, float2(u, v));
}
ENDCG
SubShader
{
Pass
{
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
ENDCG
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment