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

43 lines
1.3 KiB
PostScript

/**
* @ Version: SCREEN SPACE SHADERS - UPDATE 22
* @ Description: Bloom - Upsample
* @ Modified time: 2024-10-26 10:26
* @ Author: https://www.moddb.com/members/ascii1457
* @ Mod: https://www.moddb.com/mods/stalker-anomaly/addons/screen-space-shaders
*/
//#include "common.h"
#include "screenspace_common.h"
Texture2D s_downsample;
uniform float4 blur_setup; // Buffer Res [ x:width | y:height | z:scale | w:offset size ]
float4 main ( p_screen I ) : SV_Target
{
float2 PixelSize = (1.0f / blur_setup.xy) * blur_setup.w;
const float2 Coords[9] = {
float2( -PixelSize.x, PixelSize.y ), float2( 0.0f, PixelSize.y ),
float2( PixelSize.x, PixelSize.y ), float2( -PixelSize.x, 0.0f ),
float2( 0.0f, 0.0f ), float2( PixelSize.x, 0.0f ),
float2( -PixelSize.x, -PixelSize.y ), float2( 0.0f, -PixelSize.y ),
float2( PixelSize.x, -PixelSize.y )
};
float4 Color = 0;
for( int i = 0; i < 9; i++ )
{
Color += s_bloom.Sample(smp_rtlinear, I.tc0 + Coords[i]);
}
Color += s_downsample.Sample(smp_rtlinear, I.tc0 + Coords[1]);
Color += s_downsample.Sample(smp_rtlinear, I.tc0 + Coords[3]);
Color += s_downsample.Sample(smp_rtlinear, I.tc0 + Coords[5]);
Color += s_downsample.Sample(smp_rtlinear, I.tc0 + Coords[7]);
Color /= 13;
return saturate(Color);
}