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

45 lines
1.2 KiB
PostScript
Raw Normal View History

2024-03-17 20:18:03 -04:00
/**
* @ Version: SCREEN SPACE SHADERS - UPDATE 20
* @ Description: SSR - Blur Phase
* @ Modified time: 2024-02-09 07:25
* @ Author: https://www.moddb.com/members/ascii1457
* @ Mod: https://www.moddb.com/mods/stalker-anomaly/addons/screen-space-shaders
*/
#include "screenspace_common.h"
uniform float4 blur_params; // x: | y: | z: Buffer width | w: Buffer Height
uniform float4 ssr_setup; // x: SSR Resolution | y: Blur Intensity | z: Temporal Intensity
Texture2D ssr_image;
float4 main(p_screen I) : SV_Target
{
// Sample SSR result
float4 base_image = ssr_image.SampleLevel(smp_nofilter, I.tc0, 0);
float4 blur = 0;
float2 buffer_pixel_size = 1.0 / blur_params.zw;
float radius = SSFX_gradient_noise_IGN(I.tc0 * screen_res.xy) * 2.0f;
float2 offset = float2(radius, radius);
float r = 0.9f;
for (int i = 0; i < 12; i++)
{
r += 1.0f / r;
offset = mul(offset, pp_rotation_matrix);
blur += ssr_image.SampleLevel(smp_nofilter, I.tc0 + (offset * (r - 1.0f) * buffer_pixel_size), 0);
}
blur /= 12;
blur = lerp(base_image, blur, ssr_setup.y);
// Adjust Gloss data
float ref = lerp(base_image.a, blur.a, smoothstep(1.0f, 3.0f, ssr_setup.x) );
return float4(blur.rgb, ref);
}