Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SSS 18.1 -> 21 #1715

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified res/gamedata/shaders/r5/accum_base.ps
Binary file not shown.
Binary file modified res/gamedata/shaders/r5/accum_sun_far.ps
Binary file not shown.
Binary file modified res/gamedata/shaders/r5/accum_sun_near.ps
Binary file not shown.
Binary file modified res/gamedata/shaders/r5/accum_volumetric.ps
Binary file not shown.
10 changes: 2 additions & 8 deletions res/gamedata/shaders/r5/accum_volumetric.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,13 @@ function normal (shader, t_base, t_second, t_detail)
: fog (false)
: zb (true,false)
: blend (true,blend.one,blend.one)
-- : aref (true,0)
: sorting (2, false)
-- TODO: Implement sampler states
-- shader:sampler ("s_lmap") :texture (t_base): clamp()
-- shader:sampler ("s_smap") :texture ("null")
-- shader:sampler ("s_noise") :texture("fx\\fx_noise") : f_linear ()

shader:dx10texture ("s_lmap", t_base)
shader:dx10texture ("s_smap", "null")
shader:dx10texture ("s_noise", "fx\\fx_noise")
shader:dx10texture ("s_position", "$user$position")

shader:dx10sampler ("smp_rtlinear")
shader:dx10sampler ("smp_linear")
-- shader:dx10sampler ("smp_jitter")
shader:dx10sampler ("smp_smap")
shader:dx10sampler ("smp_jitter")
end
12 changes: 5 additions & 7 deletions res/gamedata/shaders/r5/accum_volumetric.vs
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,25 @@ struct v2p
float3 lightToPos : TEXCOORD0; // light center to plane vector
float3 vPos : TEXCOORD1; // position in camera space
float fDensity : TEXCOORD2; // plane density alon Z axis
// float2 tNoise : TEXCOORD3; // projective noise
float3 clip0 : SV_ClipDistance0;
float3 clip1 : SV_ClipDistance1;
float4 hpos : SV_Position;
};

//float4x4 m_texgen;

v2p main ( float3 P : POSITION )
{
v2p o;
float4 vPos;
vPos.xyz = lerp( vMinBounds, vMaxBounds, P); // Position in camera space
vPos.w = 1;
o.hpos = mul (m_P, vPos); // xform, input in camera coordinates
vPos.w = 1.0;
o.hpos = mul(m_P, vPos); // xform, input in camera coordinates

o.lightToPos = vPos.xyz - Ldynamic_pos.xyz;
o.vPos = vPos;

// o.fDensity = (vMaxBounds.z-vMinBounds.z)/2000.0h;
// o.fDensity = (vMaxBounds.z-vMinBounds.z)/2000.0h*2;
o.fDensity = 1.0h/40.0h;
// o.fDensity = 1.0h/20.0h;
o.fDensity = 1.0 / 40.0;

for (int i=0; i<3; ++i)
{
Expand Down
10 changes: 2 additions & 8 deletions res/gamedata/shaders/r5/accum_volumetric_nomsaa.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,13 @@ function normal (shader, t_base, t_second, t_detail)
: fog (false)
: zb (true,false)
: blend (true,blend.one,blend.one)
-- : aref (true,0)
: sorting (2, false)
-- TODO: Implement sampler states
-- shader:sampler ("s_lmap") :texture (t_base): clamp()
-- shader:sampler ("s_smap") :texture ("null")
-- shader:sampler ("s_noise") :texture("fx\\fx_noise") : f_linear ()

shader:dx10texture ("s_lmap", t_base)
shader:dx10texture ("s_smap", "null")
shader:dx10texture ("s_noise", "fx\\fx_noise")
shader:dx10texture ("s_position", "$user$position")

shader:dx10sampler ("smp_rtlinear")
shader:dx10sampler ("smp_linear")
-- shader:dx10sampler ("smp_jitter")
shader:dx10sampler ("smp_smap")
shader:dx10sampler ("smp_jitter")
end
Binary file modified res/gamedata/shaders/r5/accum_volumetric_sun.ps
Binary file not shown.
7 changes: 6 additions & 1 deletion res/gamedata/shaders/r5/check_screenspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@
#include "check_screenspace_IL.h"
#include "check_screenspace_FLORA.h"
#include "check_screenspace_INTER_GRASS.h"
#include "check_screenspace_NEWGLOSS.h"
#include "check_screenspace_NEWGLOSS.h"
#include "check_screenspace_WIND.h"
#include "check_screenspace_SHADOWS.h"
#include "check_screenspace_SSS.h"
#include "check_screenspace_LUT.h"
#include "check_screenspace_PUDDLES.h"
1 change: 1 addition & 0 deletions res/gamedata/shaders/r5/check_screenspace_LUT.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#define SSFX_LUT_INUSE
1 change: 1 addition & 0 deletions res/gamedata/shaders/r5/check_screenspace_PUDDLES.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#define SSFX_PUDDLES
1 change: 1 addition & 0 deletions res/gamedata/shaders/r5/check_screenspace_SHADOWS.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#define SSFX_SHADOWS
1 change: 1 addition & 0 deletions res/gamedata/shaders/r5/check_screenspace_SSS.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#define SSFX_SSS
1 change: 1 addition & 0 deletions res/gamedata/shaders/r5/check_screenspace_WIND.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#define SSFX_WIND
Binary file modified res/gamedata/shaders/r5/combine_1.ps
Binary file not shown.
Binary file modified res/gamedata/shaders/r5/combine_2_naa.ps
Binary file not shown.
Binary file modified res/gamedata/shaders/r5/combine_volumetric.ps
Binary file not shown.
6 changes: 5 additions & 1 deletion res/gamedata/shaders/r5/combine_volumetric.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ function normal (shader, t_base, t_second, t_detail)
shader:begin ("combine_1", "combine_volumetric")
: fog (false)
: zb (false,false)
: blend (true,blend.invdestcolor,blend.one)
: blend (true,blend.one,blend.one)
-- : aref (true,0) -- enable to save bandwith?
: sorting (2, false)

shader:dx10texture ("s_vollight", "$user$generic2")
shader:dx10texture ("s_tonemap", "$user$tonemap")
shader:dx10texture ("noise_tex", "fx\\blue_noise")

shader:dx10texture ("s_position", "$user$position")

shader:dx10sampler ("smp_linear")
shader:dx10sampler ("smp_nofilter")
end
Binary file modified res/gamedata/shaders/r5/deffer_base_hud_aref_bump.ps
Binary file not shown.
Binary file modified res/gamedata/shaders/r5/deffer_base_hud_flat.ps
Binary file not shown.
42 changes: 26 additions & 16 deletions res/gamedata/shaders/r5/deffer_grass.vs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#define SSFX_WIND_ISGRASS

#include "common.h"
#include "check_screenspace.h"

Expand All @@ -9,6 +11,12 @@ float4 wave; // cx,cy,cz,tm
float4 dir2D;
float4 array[61*4];

float4 wind;

#ifdef SSFX_WIND
#include "screenspace_wind.h"
#endif

v2p_bumped main (v_detail v)
{
v2p_bumped O;
Expand All @@ -20,23 +28,26 @@ v2p_bumped main (v_detail v)
float4 c0 = array[i+3];

// Transform pos to world coords
float4 pos;
pos.x = dot(m0, v.pos);
pos.y = dot(m1, v.pos);
pos.z = dot(m2, v.pos);
pos.w = 1;
//Wave effect
float base = m1.w;
float dp = calc_cyclic(dot(pos, wave));
float H = pos.y - base; // height of vertex (scaled)
float4 P;
P.x = dot(m0, v.pos);
P.y = dot(m1, v.pos);
P.z = dot(m2, v.pos);
P.w = 1;

float H = P.y - m1.w; // height of vertex (scaled)

#ifndef SSFX_WIND
float dp = calc_cyclic(dot(P, wave));
float frac = v.misc.z * consts.x; // fractional
float inten = H * dp;
float2 result = calc_xz_wave(dir2D.xz * inten, frac);

// Add wind
pos = float4(pos.x + result.x, pos.y, pos.z + result.y, 1);

float4 pos = float4(P.x + result.x, P.y, P.z + result.y, 1);
#else
float3 wind_result = ssfx_wind_grass(P.xyz, H, ssfx_wind_setup());
float4 pos = float4(P.xyz + wind_result.xyz, 1);
#endif

// INTERACTIVE GRASS - SSS Update 15.4
// https://www.moddb.com/mods/stalker-anomaly/addons/screen-space-shaders/
#ifdef SSFX_INTER_GRASS
Expand Down Expand Up @@ -71,10 +82,9 @@ v2p_bumped main (v_detail v)
#endif

// FLORA FIXES & IMPROVEMENTS - SSS Update 14.6
// https://www.moddb.com/mods/stalker-anomaly/addons/screen-space-shaders/

// https://www.moddb.com/mods/stalker-anomaly/addons/screen-space-shaders/
// Fake Normal, Bi-Normal and Tangent
float3 N = normalize(float3(pos.x - m0.w, pos.y - m1.w + 1.0f, pos.z - m2.w));
float3 N = normalize(float3(P.x - m0.w, P.y - m1.w + 1.0f, P.z - m2.w));

float3x3 xform = mul ((float3x3)m_WV, float3x3(
0,0,N.x,
Expand Down
Binary file modified res/gamedata/shaders/r5/deffer_impl_flat.ps
Binary file not shown.
67 changes: 67 additions & 0 deletions res/gamedata/shaders/r5/deffer_terrain_flat_d.vs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#define USE_TDETAIL

#include "common.h"

#if defined(USE_R2_STATIC_SUN) && !defined(USE_LM_HEMI)
#define v_in v_static_color
#else
#define v_in v_static
#endif


v2p_bumped main( v_in I )
{
float4 w_pos = I.P ;
float2 tc = unpack_tc_base (I.tc,I.T.w,I.B.w); // copy tc
float hemi = I.Nh.w ;

// Eye-space pos/normal
v2p_bumped O;
float3 Pe = mul (m_WV, w_pos );
O.hpos = mul (m_WVP, w_pos );
O.tcdh = float4 (tc.xyyy );
O.position = float4 (Pe, hemi );

#if defined(USE_R2_STATIC_SUN) && !defined(USE_LM_HEMI)
O.tcdh.w = I.color.w; // (r,g,b,dir-occlusion)
#endif

// Calculate the 3x3 transform from tangent space to eye-space
// TangentToEyeSpace = object2eye * tangent2object
// = object2eye * transpose(object2tangent) (since the inverse of a rotation is its transpose)
I.Nh = unpack_D3DCOLOR(I.Nh);
I.T = unpack_D3DCOLOR(I.T);
I.B = unpack_D3DCOLOR(I.B);
float3 N = unpack_bx4(I.Nh); // just scale (assume normal in the -.5f, .5f)
float3 T = unpack_bx4(I.T); //
float3 B = unpack_bx4(I.B); //
float3x3 xform = mul ((float3x3)m_WV, float3x3(
T.x,B.x,N.x,
T.y,B.y,N.y,
T.z,B.z,N.z
));
// The pixel shader operates on the bump-map in [0..1] range
// Remap this range in the matrix, anyway we are pixel-shader limited :)
// ...... [ 2 0 0 0]
// ...... [ 0 2 0 0]
// ...... [ 0 0 2 0]
// ...... [-1 -1 -1 1]
// issue: strange, but it's slower :(
// issue: interpolators? dp4? VS limited? black magic?

// Feed this transform to pixel shader
O.M1 = xform[0];
O.M2 = xform[1];
O.M3 = xform[2];

#ifdef USE_TDETAIL
O.tcdbump = O.tcdh * dt_params; // dt tc
#endif

#ifdef USE_LM_HEMI
O.lmh = unpack_tc_lmap (I.lmh);
#endif
return O;
}

FXVS;
Binary file not shown.
Binary file added res/gamedata/shaders/r5/deffer_terrain_low_flat.ps
Binary file not shown.
Binary file not shown.
33 changes: 27 additions & 6 deletions res/gamedata/shaders/r5/deffer_tree_branch_bump-hq.vs
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
/**
* @ Version: SCREEN SPACE SHADERS - UPDATE 19
* @ Description: Trees - Branches/Bushes
* @ Modified time: 2023-12-16 13:53
* @ Author: https://www.moddb.com/members/ascii1457
* @ Mod: https://www.moddb.com/mods/stalker-anomaly/addons/screen-space-shaders
*/

#include "common.h"
#include "check_screenspace.h"

float4 benders_pos[32];
float4 benders_setup;
Expand All @@ -9,27 +18,39 @@ uniform float4 consts; // {1/quant,1/quant,???,???}
uniform float4 c_scale,c_bias,wind,wave;
uniform float2 c_sun; // x=*, y=+

#ifdef SSFX_WIND
#include "screenspace_wind.h"
#endif

v2p_bumped main (v_tree I)
{
I.Nh = unpack_D3DCOLOR(I.Nh);
I.T = unpack_D3DCOLOR(I.T);
I.B = unpack_D3DCOLOR(I.B);

// Transform to world coords
float3 pos = mul (m_xform, I.P);

//
float3 pos = mul(m_xform, I.P);
float H = pos.y - m_xform._24; // height of vertex
float2 tc = (I.tc * consts).xy;

#ifndef SSFX_WIND
float base = m_xform._24 ; // take base height from matrix
float dp = calc_cyclic (wave.w+dot(pos,(float3)wave));
float H = pos.y - base ; // height of vertex (scaled, rotated, etc.)
float frac = I.tc.z*consts.x; // fractional (or rigidity)
float inten = H * dp; // intensity
float2 result = calc_xz_wave (wind.xz*inten*2.0f, frac);

float3 wind_result = float3(result.x, 0, result.y);
#else
float3 wind_result = ssfx_wind_tree_branches(pos, H, tc.y, ssfx_wind_setup());
#endif

#ifdef USE_TREEWAVE
result = 0;
wind_result = 0;
#endif
float4 w_pos = float4(pos.x+result.x, pos.y, pos.z+result.y, 1);
float2 tc = (I.tc * consts).xy;
float4 w_pos = float4(pos.xyz + wind_result.xyz, 1);


// INTERACTIVE GRASS ( Bushes ) - SSS Update 15.4
// https://www.moddb.com/mods/stalker-anomaly/addons/screen-space-shaders/
Expand Down
30 changes: 23 additions & 7 deletions res/gamedata/shaders/r5/deffer_tree_bump-hq.vs
Original file line number Diff line number Diff line change
@@ -1,31 +1,47 @@
/**
* @ Version: SCREEN SPACE SHADERS - UPDATE 19
* @ Description: Trees - Trunk
* @ Modified time: 2023-12-16 13:58
* @ Author: https://www.moddb.com/members/ascii1457
* @ Mod: https://www.moddb.com/mods/stalker-anomaly/addons/screen-space-shaders
*/

#include "common.h"
#include "check_screenspace.h"

uniform float3x4 m_xform ;
uniform float3x4 m_xform_v ;
uniform float4 consts; // {1/quant,1/quant,???,???}
uniform float4 c_scale,c_bias,wind,wave;
uniform float2 c_sun; // x=*, y=+

#ifdef SSFX_WIND
#include "screenspace_wind.h"
#endif

v2p_bumped main (v_tree I)
{
I.Nh = unpack_D3DCOLOR(I.Nh);
I.T = unpack_D3DCOLOR(I.T);
I.B = unpack_D3DCOLOR(I.B);

// Transform to world coords
float3 pos = mul (m_xform, I.P);
float3 pos = mul(m_xform, I.P);
float H = pos.y - m_xform._24; // height of vertex

//
float base = m_xform._24 ; // take base height from matrix
#ifndef SSFX_WIND
float dp = calc_cyclic (wave.w+dot(pos,(float3)wave));
float H = pos.y - base ; // height of vertex (scaled, rotated, etc.)
float frac = I.tc.z*consts.x; // fractional (or rigidity)
float inten = H * dp; // intensity
float2 result = calc_xz_wave (wind.xz*inten, frac);
float2 wind_result = calc_xz_wave (wind.xz*inten, frac);
#else
float2 wind_result = ssfx_wind_tree_trunk(pos, H, ssfx_wind_setup()).xy;
#endif

#ifdef USE_TREEWAVE
result = 0;
wind_result = 0;
#endif
float4 w_pos = float4(pos.x+result.x, pos.y, pos.z+result.y, 1);
float4 w_pos = float4(pos.x + wind_result.x, pos.y, pos.z + wind_result.y, 1);
float2 tc = (I.tc * consts).xy;
float hemi = clamp(I.Nh.w * c_scale.w + c_bias.w, 0.3f, 1.0f); // Limit hemi - SSS Update 14.5
// float hemi = I.Nh.w;
Expand Down
Loading
Loading