float3 falseColorRamp(float luma)
{
	if (luma < 0.05)
		return float3(0.0, 0.0, 0.0);
	if (luma < 0.15)
		return lerp(float3(0.04, 0.02, 0.24), float3(0.05, 0.18, 0.95), smoothstep(0.05, 0.15, luma));
	if (luma < 0.35)
		return lerp(float3(0.05, 0.18, 0.95), float3(0.0, 0.85, 1.0), smoothstep(0.15, 0.35, luma));
	if (luma < 0.55)
		return lerp(float3(0.0, 0.85, 1.0), float3(0.18, 0.95, 0.18), smoothstep(0.35, 0.55, luma));
	if (luma < 0.75)
		return lerp(float3(0.18, 0.95, 0.18), float3(1.0, 0.92, 0.08), smoothstep(0.55, 0.75, luma));
	if (luma < 0.9)
		return lerp(float3(1.0, 0.92, 0.08), float3(1.0, 0.35, 0.02), smoothstep(0.75, 0.9, luma));
	return lerp(float3(1.0, 0.35, 0.02), float3(1.0, 0.0, 0.0), smoothstep(0.9, 1.0, luma));
}

float4 shadeVideo(ShaderContext context)
{
	float3 source = context.sourceColor.rgb;
	float luma = saturate((dot(source, float3(0.2126, 0.7152, 0.0722)) + lift) * max(gain, 0.001));
	float3 mapped = falseColorRamp(luma);
	if (showLuma)
		mapped = lerp(mapped, float3(luma, luma, luma), 0.45);
	return float4(lerp(source, mapped, saturate(blendAmount)), context.sourceColor.a);
}
