Created
May 28, 2016 09:52
-
-
Save sagarpatel/9394f8b1697f522f3b8319020ff4ba7a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 UnityEngine; | |
using System.Collections; | |
[ExecuteInEditMode] | |
public class FullscreenEffetScript : MonoBehaviour | |
{ | |
//public Shader m_fullscreenEffectShader; | |
Material m_shaderMaterial; | |
public float m_effectLerp_Amplitude = 2; | |
public float m_effectLerp_Frequency = 1; | |
public float m_effectRangeMultiplier = 42.0f; | |
[Range(-1, 1)] | |
public float m_effectScaler = 1; | |
[Range(0,1)] | |
public float m_cameraBackgroundWhite = 0.027f; | |
Camera m_camera; | |
void Awake() | |
{ | |
m_shaderMaterial = new Material(Shader.Find("Hidden/NewImageEffectShader")); | |
m_camera = GetComponent<Camera>(); | |
m_camera.depthTextureMode = DepthTextureMode.Depth; | |
m_camera.backgroundColor = new Color(m_cameraBackgroundWhite, m_cameraBackgroundWhite, m_cameraBackgroundWhite); | |
} | |
void OnRenderImage(RenderTexture source, RenderTexture destination) | |
{ | |
m_camera.backgroundColor = new Color(m_cameraBackgroundWhite, m_cameraBackgroundWhite, m_cameraBackgroundWhite); | |
// set variables here | |
m_shaderMaterial.SetFloat("_EffectLerp", m_effectLerp_Amplitude* Mathf.Sin(m_effectLerp_Frequency * Time.time)); | |
m_shaderMaterial.SetFloat("_EffectScaler", m_effectRangeMultiplier * m_effectScaler); | |
if (m_shaderMaterial != null) | |
Graphics.Blit(source, destination, m_shaderMaterial); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment