Here is the code for the shader itself:
Shader "Hidden/WhiteFlash"
{
Properties{
_MainTex("Base (RGB)", 2D) = "white" {}
_flash("Flash intensity", Range(0, 1)) = 0
}
SubShader{
Pass{
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
uniform float _flash;
float4 frag(v2f_img i) : COLOR{
float4 c = tex2D(_MainTex, i.uv);
//float lum = c.r*.3 + c.g*.59 + c.b*.11;
float3 fl = float3(1, 1, 1);
float4 result = c;
result.rgb = lerp(c.rgb, fl, _flash);
return result;
}
ENDCG
}
}
}
And here is the script that controls its values:
public class WhiteFlash : MonoBehaviour
{
public float intensity;
private Material material;
// Creates a private material used to the effect
void Awake()
{
material = new Material(Shader.Find("Hidden/WhiteFlash"));
}
// Postprocess the image
void OnRenderImage(RenderTexture source, RenderTexture destination)
{
if (intensity == 0)
{
Graphics.Blit(source, destination);
return;
}
material.SetFloat("_flash", intensity);
Graphics.Blit(source, destination, material);
}
}
Please understand that shaders are black magic to me, and the answer to my question is likely something extremely simple I’m just missing. The code itself is about 98% recycled from a tutorial I found online.
The code works find in the Unity editor, in normal and emulated (OpenGL es 2.0) mode. However, come build time, the flashes just don’t materialize. Can anyone point me in the right direction with this? My Google-fu was of no help.