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

64 lines
1.5 KiB
PostScript
Raw Normal View History

2024-03-17 20:18:03 -04:00
#include "common.h"
#include "sload.h"
#include "screenspace_hud_raindrops.h"
f_deffer main ( p_bumped I )
{
f_deffer O;
// HUD Rain drops - SSS Update 17
// https://www.moddb.com/mods/stalker-anomaly/addons/screen-space-shaders/
float4 drops = 0; // xy = Normal | z = Overall str | w = reflection str
if (ssfx_hud_drops_1.y > 0)
{
// Calc droplets
drops.xyz = ssfx_hud_raindrops(s_hud_rain, I.RDrops.xyz, 1.0f);
// Only apply to facing up surfaces [ World Y+ ]
drops.xyz *= saturate(I.RDrops.w);
// Intensity from script ( Cover + Rain intensity )
drops.xyz *= ssfx_hud_drops_1.y;
// Refraction
I.tcdh.xy = I.tcdh.xy + drops.xy * ssfx_hud_drops_1.w;
// Reflection adjustments
drops.w = ssfx_hud_drops_1.z * dot(L_hemi_color, SSFX_HUD_LIGHTVECTOR);
drops.w = max(drops.w, 3.0f);
}
surface_bumped S = sload(I);
// Add sampled normal and droplets
float3 Ne = mul(float3x3(I.M1, I.M2, I.M3), S.normal + float3(drops.xy * drops.w, 1.0f));
Ne = normalize (Ne);
// hemi,sun,material
float ms = xmaterial;
S.gloss += (ssfx_hud_drops_1.y * ssfx_hud_drops_2.z) + drops.z * ssfx_hud_drops_2.w;
#ifdef USE_LM_HEMI
float4 lm = s_hemi.Sample( smp_rtlinear, I.lmh);
float h = get_hemi(lm);
# ifdef USE_R2_STATIC_SUN
ms = get_sun(lm);
# endif
#else
float h = I.position.w ;
# ifdef USE_R2_STATIC_SUN
ms = I.tcdh.w ;
# endif
#endif
O = pack_gbuffer(
float4 (Ne, h ),
float4 (I.position.xyz + Ne*S.height*def_virtualh, ms ),
float4 (S.base.xyz, S.gloss ) );
return O;
}