本文转载自Unity论坛看到的
相机特效来调整亮度和对比度 , 做了一些修改。
using System; using UnityEngine; using UnityStandardAssets.ImageEffects; [ExecuteInEditMode] [AddComponentMenu("Image Effects/GL/Brightness Effect")] ///add by lpj.thinbug 用于亮度调整20166.12.26publicclass BrightnessEffect : ImageEffectBase { [Range(0.5f,2f)]publicfloat _Brightness =1f; [Range(0.5f,2f)]publicfloat _Contrast =1f; Material curMaterial;protectedoverridevoidStart() { shader = Shader.Find("Hidden/GL/Brightness Effect");base.Start(); }// Called by camera to apply image effectvoid OnRenderImage(RenderTexture source, RenderTexture destination) { material.SetFloat("_Brightness", _Brightness); material.SetFloat("_Contrast", _Contrast); Graphics.Blit(source, destination, material); }publicvoidSetBrightness(floatvalue) { _Brightness =value; }publicvoidSetContrast(floatvalue) { _Contrast =value; } }///add by lpj.thinbug 用于亮度调整20166.12.26 Shader"Hidden/GL/Brightness Effect" { Properties { _MainTex ("Base (RGB)",2D) ="white" {} _Brightness ("B