float4 shadeVideo(ShaderContext context)
{
	int stride = int(clamp(frameStride, 1.0, 6.0) + 0.5);
	float3 echo = float3(0.0, 0.0, 0.0);
	float total = 0.0;
	float weight = 1.0;

	for (int i = 1; i <= 6; ++i)
	{
		int frame = i * stride;
		float3 sampleColor = sampleTemporalHistory(frame, context.uv).rgb * echoTint.rgb;
		echo += sampleColor * weight;
		total += weight;
		weight *= saturate(decay);
	}

	float3 echoColor = echo / max(total, 0.0001);
	float amount = saturate(echoAmount) * echoTint.a;
	return float4(lerp(context.sourceColor.rgb, echoColor, amount), context.sourceColor.a);
}
