I have been trying, so far with no success, to create a modified version of the Grayscale camera effect so that I have a range in order to have a smooth transition from the original - coloured - scene to a grayscale one.
Shader "Hidden/GreyScale" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode off }
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
uniform float _Strength;
float4 frag (v2f_img i) : COLOR {
float4 c = tex2D(_MainTex, i.uv);
float4 g = (c.r+c.g+c.b)/3.0;
c.rgb = lerp(c, g, _Strength);
return c;
}
ENDCG
}
}
Fallback off
}
here is the c# for your camera
using UnityEngine;
[ExecuteInEditMode]
[AddComponentMenu("Image Effects/GreyScale")]
public class GreyScale : ImageEffectBase {
public float _Strength = 1.0f;
// Called by camera to apply image effect
void OnRenderImage (RenderTexture source, RenderTexture destination) {
Shader.SetGlobalFloat ("_Strength", _Strength);
Graphics.Blit (source, destination, material);
}
}