Divergent/mods/Shaders Look Better/gamedata/shaders/r3/accum_sun_near.ps

89 lines
1.9 KiB
PostScript
Raw Permalink Normal View History

#include "common.h"
#include "lmodel.h"
#ifdef USE_MINMAX_SM
#define SM_MINMAX
#endif
#if SUN_QUALITY>2
#define ULTRA_SHADOWS_ON
#endif // SUN_QUALITY>2
#ifdef ULTRA_SHADOWS_ON
#define USE_ULTRA_SHADOWS
#endif
#define SLB_SHADOW_SUN_NEAR
#include "shadow.h"
// Check Screen Space Shaders modules & addons
#include "check_screenspace.h"
#ifdef SSFX_SSS
#include "screenspace_shadows.h"
#endif
#ifdef USE_SUNFILTER
#ifdef MSAA_OPTIMIZATION
float4 main ( v2p_volume I, uint iSample : SV_SAMPLEINDEX ) : SV_Target
#else
float4 main ( v2p_volume I ) : SV_Target
#endif
{
gbuffer_data gbd = gbuffer_load_data( GLD_P(I.tc, I.hpos, ISAMPLE) );
float4 _P = float4( gbd.P, 1.0);
float4 PS = mul( m_shadow, _P );
float s = shadowtest_sun( PS, I.tcJ ) * sunmask( _P );
return s;
}
#else
#ifdef MSAA_OPTIMIZATION
float4 main ( v2p_volume I, uint iSample : SV_SAMPLEINDEX ) : SV_Target
#else
float4 main ( v2p_volume I ) : SV_Target
#endif
{
gbuffer_data gbd = gbuffer_load_data( GLD_P(I.tc.xy/I.tc.w, I.hpos, ISAMPLE) );
float4 _P = float4( gbd.P, gbd.mtl );
float4 _N = float4( gbd.N, gbd.hemi );
float4 _C = float4( gbd.C, gbd.gloss );
// ----- light-model
float m = xmaterial;
#ifndef USE_R2_STATIC_SUN
m = _P.w;
#endif
float4 light = plight_infinity ( m, _P, _N, _C, Ldynamic_dir );
// ----- shadow
// SHADOWS FIXES - SSS Update 19
// Normal Offset for biasing
float3 NormalOffset = 0;
#ifdef SSFX_SHADOWS
// NormalOffset = _N * ssfx_shadow_bias.y;
#endif
float4 P4 = float4( _P.xyz + NormalOffset, 1.0);
float4 PS = mul( m_shadow, P4 );
float s = sunmask( P4 );
s *= shadow( PS, I.hpos.xy );
#ifdef SSFX_SSS
s *= SSFX_ScreenSpaceShadows(_P, I.hpos, ISAMPLE);
#endif
#ifdef SSFX_ENHANCED_SHADERS // We have Enhanced Shaders installed
return float4( SRGBToLinear(Ldynamic_color.rgb * s.xxx),1) * light;
#else
return float4( Ldynamic_color * light * s);
#endif
}
#endif