float4 shadeVideo(ShaderContext context)
{
	float clampedHoldFrames = clamp(holdFrames, 0.0, 7.0);
	int lowerHoldLength = int(floor(clampedHoldFrames)) + 1;
	int upperHoldLength = min(lowerHoldLength + 1, 8);
	float fractional = frac(clampedHoldFrames);

	int lowerPhase = int(context.frameCount) % lowerHoldLength;
	int upperPhase = int(context.frameCount) % upperHoldLength;

	float4 lowerHeld = lowerPhase == 0 ? context.sourceColor : sampleTemporalHistory(lowerPhase - 1, context.uv);
	float4 upperHeld = upperPhase == 0 ? context.sourceColor : sampleTemporalHistory(upperPhase - 1, context.uv);
	float4 held = lerp(lowerHeld, upperHeld, fractional);
	return lerp(context.sourceColor, held, clamp(blendAmount, 0.0, 1.0));
}
