Last active
December 7, 2018 03:22
-
-
Save baobao/eb052a2f952a25db14004f2728ac0371 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
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
// このコンポーネントをCameraコンポーネントがアタッチされているGameObjectにくっつけます | |
public class VerticalScroll : MonoBehaviour | |
{ | |
[SerializeField] Shader m_shader; | |
[SerializeField] float m_speed = 0.005f; | |
Material m_mat; | |
// イメージエフェクトはOnRenderImage関数内で処理を書きます | |
void OnRenderImage (RenderTexture src, RenderTexture dest) | |
{ | |
if (m_mat == null) | |
{ | |
m_mat = new Material(m_shader); | |
// Materialが再生が終了したら破棄されるようにHideFlagsを設定する | |
m_mat.hideFlags = HideFlags.DontSave; | |
} | |
// Shaderの_ScrollValue変数に値を渡す | |
m_mat.SetFloat("_ScrollValue", (float)Time.frameCount * m_speed); | |
Graphics.Blit(src, dest, m_mat); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment