/** * @ Version: SCREEN SPACE SHADERS - UPDATE 22 * @ Description: Bloom - Lens Flare * @ Modified time: 2024-10-26 13:10 * @ Author: https://www.moddb.com/members/ascii1457 * @ Mod: https://www.moddb.com/mods/stalker-anomaly/addons/screen-space-shaders */ #include "screenspace_common.h" static float FlaresScales[4] = { -0.5f, -1.0f, 1.0f, 0.5f }; static float Fisheye_FOV = 5.0f; // Internal -- static float Fisheye_Tan = tan(Fisheye_FOV / 2.0); Texture2D s_emissive; Texture2D s_lenscolors; float4 main ( p_screen I ) : SV_Target { // Fisheye UV float2 uv = I.tc0.xy * 2.0f - 1.0f; uv.y /= screen_res.x / screen_res.y; float xy_len = length(uv); float k = 2.0 * atan2(xy_len, 1.0 / Fisheye_Tan) / (xy_len * Fisheye_FOV); float2 Fisheye_UV = (uv.xy / k + 1.0f) / 2.0f; // Lens flare float3 Flares = 0; for( int i = 0; i < 4; i++ ) { float2 OffsetUV = (Fisheye_UV - 0.5f) * FlaresScales[i]; // Fade float Distance = distance( float2(0.0f, 0.0f), OffsetUV ); float Fade = smoothstep( -0.02f, 0.15f, Distance ); Flares = max( Flares, s_emissive.Sample(smp_rtlinear, OffsetUV + 0.5f).rgb ) * Fade; } // Add base color Flares *= s_lenscolors.Sample(smp_linear, I.tc0.xy).rgb; return float4(Flares, 1); }