| | |
| | | _HorizontalAmount("Horizontal Amount",Float) = 8 |
| | | _VerticalAmount("Vertical Amount",Float) = 8 |
| | | _Speed("Speed",Range(1,150)) = 30 |
| | | _ChangeTime("ChangeTime",Float) = 0 |
| | | |
| | | } |
| | | SubShader |
| | | { |
| | |
| | | Blend SrcAlpha OneMinusSrcAlpha |
| | | |
| | | CGPROGRAM |
| | | |
| | | #pragma vertex vert |
| | | #pragma fragment frag |
| | | // 两条非常重要的编译指令 |
| | | #pragma vertex vert// 定点着色器 |
| | | #pragma fragment frag// 片元着色器 |
| | | #include "Lighting.cginc" |
| | | |
| | | fixed4 _Color; |
| | |
| | | float _HorizontalAmount; |
| | | float _VerticalAmount; |
| | | float _Speed; |
| | | float _ChangeTime; |
| | | |
| | | |
| | | struct a2v |
| | | { |
| | |
| | | |
| | | fixed4 frag(v2f i) :SV_Target |
| | | { |
| | | float time = floor(_Time.y * _Speed); |
| | | float row = floor(time / _HorizontalAmount); |
| | | float column = time - row * _HorizontalAmount; |
| | | //_Time float4 Time (t/20, t, t*2, t*3), use to animate things inside the shaders. |
| | | //_SinTime float4 Sine of time: (t/8, t/4, t/2, t). |
| | | //_CosTime float4 Cosine of time: (t/8, t/4, t/2, t). |
| | | //unity_DeltaTime float4 Delta time: (dt, 1/dt, smoothDt, 1/smoothDt). |
| | | //_ProjectionParams float4 x is 1.0 (or –1.0 if currently rendering with a flipped projection matrix), y is the camera’s near plane, z is the camera’s far plane and w is 1/FarPlane. |
| | | //_ScreenParams float4 x is the current render target width in pixels, y is the current render target height in pixels, z is 1.0 + 1.0/width and w is 1.0 + 1.0/height. |
| | | //这里的 t 得到的时间单位是——秒 |
| | | |
| | | float time = floor((_Time.y - _ChangeTime) * _Speed);//对输入参数向下取整。例如 floor(float(1.3)) 返回的值为 1.0;但是 floor(float(-1.3))返回的值为-2.0。 |
| | | float row = floor(time / _HorizontalAmount);//行 |
| | | float column = time - row * _HorizontalAmount;//列 |
| | | //-- |
| | | //half2 uv = float2(i.uv.x / _HorizontalAmount, i.uv.y / _VerticalAmount); |
| | | //uv.x += column / _HorizontalAmount; |