| . | |
| using System; |
| |
| using UnityEngine; |
| |
| |
| |
| [ExecuteAlways] |
| |
| public class HeatDistortImageEffect : MonoBehaviour |
| |
| { |
| |
| private void OnRenderImage(RenderTexture source, RenderTexture destination) |
| |
| { |
| |
| if (!this.m_initalized) |
| |
| { |
| |
| this.m_initalized = true; |
| |
| this.m_material = new Material(Shader.Find("Hidden/CameraHeatDistort")); |
| |
| } |
| |
| this.m_material.SetFloat(HeatDistortImageEffect.s_intensity, this.m_intensity); |
| |
| this.m_material.SetFloat(HeatDistortImageEffect.s_vignetteSmoothness, this.m_vignetteSmoothness); |
| |
| this.m_material.SetFloat(HeatDistortImageEffect.s_vignetteStrength, this.m_vignetteStrength); |
| |
| this.m_material.SetTexture(HeatDistortImageEffect.s_noiseTexture, this.m_noiseTexture); |
| |
| this.m_material.SetFloat(HeatDistortImageEffect.s_distortionStrength, this.m_distortionStrength); |
| |
| this.m_material.SetInt(HeatDistortImageEffect.s_segments, this.m_segments); |
| |
| this.m_material.SetFloat(HeatDistortImageEffect.s_stretch, this.m_stretch); |
| |
| this.m_material.SetFloat(HeatDistortImageEffect.s_scrollspeed, this.m_scrollSpeed); |
| |
| this.m_material.SetColor(HeatDistortImageEffect.s_color, this.m_color); |
| |
| Graphics.Blit(source, destination, this.m_material); |
| |
| } |
| |
| |
| |
| private static readonly int s_intensity = Shader.PropertyToID("_Intensity"); |
| |
| |
| |
| private static readonly int s_vignetteStrength = Shader.PropertyToID("_VignetteStrength"); |
| |
| |
| |
| private static readonly int s_vignetteSmoothness = Shader.PropertyToID("_VignetteSmoothness"); |
| |
| |
| |
| private static readonly int s_noiseTexture = Shader.PropertyToID("_NoiseTexture"); |
| |
| |
| |
| private static readonly int s_distortionStrength = Shader.PropertyToID("_DistortionStrength"); |
| |
| |
| |
| private static readonly int s_segments = Shader.PropertyToID("_Segments"); |
| |
| |
| |
| private static readonly int s_stretch = Shader.PropertyToID("_Stretch"); |
| |
| |
| |
| private static readonly int s_scrollspeed = Shader.PropertyToID("_ScrollSpeed"); |
| |
| |
| |
| private static readonly int s_color = Shader.PropertyToID("_Color"); |
| |
| |
| |
| private Material m_material; |
| |
| |
| |
| private bool m_initalized; |
| |
| |
| |
| [SerializeField] |
| |
| private Color m_color; |
| |
| |
| |
| [SerializeField] |
| |
| [Range(0f, 1f)] |
| |
| public float m_intensity; |
| |
| |
| |
| [SerializeField] |
| |
| [Range(-0.25f, 0.25f)] |
| |
| private float m_distortionStrength = 0.15f; |
| |
| |
| |
| [SerializeField] |
| |
| [Range(0f, 15f)] |
| |
| private float m_vignetteStrength = 1f; |
| |
| |
| |
| [SerializeField] |
| |
| [Range(0f, 1f)] |
| |
| private float m_vignetteSmoothness = 0.5f; |
| |
| |
| |
| [SerializeField] |
| |
| private Texture2D m_noiseTexture; |
| |
| |
| |
| [SerializeField] |
| |
| [Range(1f, 8f)] |
| |
| private int m_segments = 3; |
| |
| |
| |
| [SerializeField] |
| |
| [Range(0f, 8f)] |
| |
| private float m_stretch = 1f; |
| |
| |
| |
| [SerializeField] |
| |
| [Range(-1f, 1f)] |
| |
| private float m_scrollSpeed; |
| |
| } |
| |
| |