I have a Grayscale shader that works when applied to material. I would like to apply it to what the camera does.
I found a tutorial talking about void OnRenderImage (source RenderTexture, destination RenderTexture)
but I could not get him to work with mine.
Shader:
Shader "Custom/Grayscale" { SubShader { Pass{ CGPROGRAM #pragma exclude_renderers gles #pragma fragment frag #include "UnityCG.cginc" uniform sampler2D _MainTex; fixed4 frag(v2f_img i) : COLOR{ fixed4 currentPixel = tex2D(_MainTex, i.uv); fixed grayscale = Luminance(currentPixel.rgb); fixed4 output = currentPixel; output.rgb = grayscale; output.a = currentPixel.a;
And the script attached to the camera:
using UnityEngine; using System.Collections; public class Grayscale : ImageEffectBase { void OnRenderImage (RenderTexture source, RenderTexture destination) { Graphics.Blit (source, destination, material); } }
Any suggestions? Thank you very much!
source share