Created
July 12, 2017 07:00
-
-
Save mewlist/d08e70585c685abc346a6d12c598ce0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "Custom/UVScroll" { | |
Properties { | |
_Color ("Color", Color) = (1,1,1,1) | |
_MainTex ("Albedo (RGB)", 2D) = "white" {} | |
_Velocity ("Velocity", Range(0, 100)) = 0 | |
_Rotation ("Rotation", Range(0, 360)) = 0 | |
} | |
SubShader { | |
Tags { "RenderType"="Opaque" } | |
CGPROGRAM | |
#pragma surface surf Standard vertex:vert | |
sampler2D _MainTex; | |
struct Input { | |
float2 uv_MainTex; | |
}; | |
fixed4 _Color; | |
float _Rotation; | |
float _Velocity; | |
void vert(inout appdata_full v) | |
{ | |
const float PI = 3.141592; | |
// 回転行列を作る | |
float c = cos(PI * _Rotation / 180); | |
float s = sin(PI * _Rotation / 180); | |
float2x2 rotationMatrix = float2x2( c, -s, s, c); | |
// 移動方向を求める | |
float2 dir = mul(rotationMatrix, float2(1, 0)); | |
// ずらす | |
v.texcoord.x = v.texcoord.x + _Time.x * dir.x * _Velocity; | |
v.texcoord.y = v.texcoord.y + _Time.x * dir.y * _Velocity; | |
} | |
void surf (Input IN, inout SurfaceOutputStandard o) { | |
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; | |
o.Albedo = c.rgb; | |
o.Alpha = c.a; | |
} | |
ENDCG | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
処理の効率面でこんなツッコミをもらいました