/**
 * @ Version: SCREEN SPACE SHADERS - UPDATE 22
 * @ Description: Volumetric Blur Phase
 * @ Modified time: 2024-11-19 00:06
 * @ Author: https://www.moddb.com/members/ascii1457
 * @ Mod: https://www.moddb.com/mods/stalker-anomaly/addons/screen-space-shaders
 */

#include "common.h"

Texture2D vol_buffer;

uniform float4 blur_setup; // Buffer Res [ x:width | y:height | z:scale | w:offset size ]

float4 main ( p_screen I ) : SV_Target
{
	float4 Blur = 0;

	// Scale sample to use the linear filtering
	float2 tc = I.tc0.xy * blur_setup.ww;
	float2 offset = ((blur_setup.zz + 0.5f) / (blur_setup.xy / blur_setup.ww));

	Blur += vol_buffer.SampleLevel(smp_rtlinear, tc + offset, 0);
	Blur += vol_buffer.SampleLevel(smp_rtlinear, tc - offset, 0);
	offset = float2(-offset.x, offset.x);
	Blur += vol_buffer.SampleLevel(smp_rtlinear, tc + offset, 0);
	Blur += vol_buffer.SampleLevel(smp_rtlinear, tc - offset, 0);

	return Blur / 4.0f;
}