float4 gaussianBlurDirection(ShaderContext context, float2 direction)
{
	float2 texel = 1.0 / max(context.inputResolution, float2(1.0, 1.0));
	float blurRadius = max(radius, 0.0) * saturate(strength);
	float2 sampleStep = texel * blurRadius * direction;
	int sampleRadius = int(clamp(samples, 0.0, 8.0) + 0.5);

	float4 center = sampleVideo(context.uv);
	float4 blur = float4(0.0, 0.0, 0.0, 0.0);
	float totalWeight = 0.0;

	for (int x = -sampleRadius; x <= sampleRadius; ++x)
	{
		float distanceSquared = float(x * x);
		float sigma = max(float(sampleRadius) * 0.5, 0.5);
		float weight = exp(-distanceSquared / (2.0 * sigma * sigma));
		float2 offset = float(x) * sampleStep;
		blur += sampleVideo(context.uv + offset) * weight;
		totalWeight += weight;
	}

	if (sampleRadius == 0)
	{
		blur = center;
		totalWeight = 1.0;
	}

	blur /= max(totalWeight, 0.0001);
	return blur;
}

float4 blurHorizontal(ShaderContext context)
{
	return gaussianBlurDirection(context, float2(1.0, 0.0));
}

float4 blurVertical(ShaderContext context)
{
	return gaussianBlurDirection(context, float2(0.0, 1.0));
}

float4 shadeVideo(ShaderContext context)
{
	return blurVertical(context);
}
