Divergent/mods/Screen Space Shaders/gamedata/shaders/r3/ssfx_volumetric_blur.ps

55 lines
1.5 KiB
PostScript
Raw Normal View History

2024-03-17 20:18:03 -04:00
/**
* @ Version: SCREEN SPACE SHADERS - UPDATE 20
* @ Description: Volumetric Blur Phase
* @ Modified time: 2024-02-21 13:02
* @ Author: https://www.moddb.com/members/ascii1457
* @ Mod: https://www.moddb.com/mods/stalker-anomaly/addons/screen-space-shaders
*/
#include "common.h"
#ifndef USE_MSAA
Texture2D vol_buffer;
#else
#ifndef SM_5
Texture2DMS<float4,MSAA_SAMPLES> vol_buffer;
#else
Texture2DMS<float4> vol_buffer;
#endif
#endif
uniform float4 blur_setup; // Buffer Res [ x:width | y:height | z:scale | w:offset size ]
//uniform float4 shader_param_6;
float4 main ( p_screen I ) : SV_Target
{
float4 Blur = 0;
#ifndef USE_MSAA
// 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));// * shader_param_6.x;
Blur += vol_buffer.SampleLevel(smp_linear, tc + offset, 0);
Blur += vol_buffer.SampleLevel(smp_linear, tc - offset, 0);
offset = float2(-offset.x, offset.x);
Blur += vol_buffer.SampleLevel(smp_linear, tc + offset, 0);
Blur += vol_buffer.SampleLevel(smp_linear, tc - offset, 0);
#else
float2 tc = I.tc0.xy;
float2 offset = ((blur_setup.zz + 0.5f) / blur_setup.xy);// * shader_param_6.x;
Blur += vol_buffer.Load(int3((tc + offset) * blur_setup.xy, 0), 0);
Blur += vol_buffer.Load(int3((tc - offset) * blur_setup.xy, 0), 0);
offset = float2(-offset.x, offset.x);
Blur += vol_buffer.Load(int3((tc + offset) * blur_setup.xy, 0), 0);
Blur += vol_buffer.Load(int3((tc - offset) * blur_setup.xy, 0), 0);
#endif
return Blur / 4.0f;
}