Skip to content

Commit f697fe0

Browse files
committed
SSS 18.1 -> 21 add new shaders
1 parent bc0e9e4 commit f697fe0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+965
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#define SSFX_LUT_INUSE
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#define SSFX_PUDDLES
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#define SSFX_SHADOWS
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#define SSFX_SSS
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#define SSFX_WIND
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#define USE_TDETAIL
2+
3+
#include "common.h"
4+
5+
#if defined(USE_R2_STATIC_SUN) && !defined(USE_LM_HEMI)
6+
#define v_in v_static_color
7+
#else
8+
#define v_in v_static
9+
#endif
10+
11+
12+
v2p_bumped main( v_in I )
13+
{
14+
float4 w_pos = I.P ;
15+
float2 tc = unpack_tc_base (I.tc,I.T.w,I.B.w); // copy tc
16+
float hemi = I.Nh.w ;
17+
18+
// Eye-space pos/normal
19+
v2p_bumped O;
20+
float3 Pe = mul (m_WV, w_pos );
21+
O.hpos = mul (m_WVP, w_pos );
22+
O.tcdh = float4 (tc.xyyy );
23+
O.position = float4 (Pe, hemi );
24+
25+
#if defined(USE_R2_STATIC_SUN) && !defined(USE_LM_HEMI)
26+
O.tcdh.w = I.color.w; // (r,g,b,dir-occlusion)
27+
#endif
28+
29+
// Calculate the 3x3 transform from tangent space to eye-space
30+
// TangentToEyeSpace = object2eye * tangent2object
31+
// = object2eye * transpose(object2tangent) (since the inverse of a rotation is its transpose)
32+
I.Nh = unpack_D3DCOLOR(I.Nh);
33+
I.T = unpack_D3DCOLOR(I.T);
34+
I.B = unpack_D3DCOLOR(I.B);
35+
float3 N = unpack_bx4(I.Nh); // just scale (assume normal in the -.5f, .5f)
36+
float3 T = unpack_bx4(I.T); //
37+
float3 B = unpack_bx4(I.B); //
38+
float3x3 xform = mul ((float3x3)m_WV, float3x3(
39+
T.x,B.x,N.x,
40+
T.y,B.y,N.y,
41+
T.z,B.z,N.z
42+
));
43+
// The pixel shader operates on the bump-map in [0..1] range
44+
// Remap this range in the matrix, anyway we are pixel-shader limited :)
45+
// ...... [ 2 0 0 0]
46+
// ...... [ 0 2 0 0]
47+
// ...... [ 0 0 2 0]
48+
// ...... [-1 -1 -1 1]
49+
// issue: strange, but it's slower :(
50+
// issue: interpolators? dp4? VS limited? black magic?
51+
52+
// Feed this transform to pixel shader
53+
O.M1 = xform[0];
54+
O.M2 = xform[1];
55+
O.M3 = xform[2];
56+
57+
#ifdef USE_TDETAIL
58+
O.tcdbump = O.tcdh * dt_params; // dt tc
59+
#endif
60+
61+
#ifdef USE_LM_HEMI
62+
O.lmh = unpack_tc_lmap (I.lmh);
63+
#endif
64+
return O;
65+
}
66+
67+
FXVS;
Binary file not shown.
660 Bytes
Binary file not shown.
Binary file not shown.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* @ Version: SCREEN SPACE SHADERS - UPDATE 20
3+
* @ Description: LUT shader
4+
* @ Modified time: 2024-01-22 04:12
5+
* @ Author: https://www.moddb.com/members/ascii1457
6+
* @ Mod: https://www.moddb.com/mods/stalker-anomaly/addons/screen-space-shaders
7+
*/
8+
9+
// Settings
10+
#include "settings_screenspace_LUT.h"
11+
12+
// Internal --
13+
#define LUT_GROUPS max(1, G_CELLS_GROUPS)
14+
#define TEXEL_SIZE float2(1.0f / G_LUT_SIZE_W, 1.0f / (G_CELLS_SIZE * LUT_GROUPS))
15+
#define TEXEL_HALF float2(TEXEL_SIZE.xy / 2.0f)
16+
#define TEXEL_FIX TEXEL_SIZE.y * LUT_GROUPS
17+
18+
uniform float4 ssfx_lut;
19+
20+
float3 ssfx_lut_pp(float3 base_col)
21+
{
22+
// Prepare LUT UVs
23+
float3 cells = base_col * G_CELLS_SIZE - base_col;
24+
float lut_frac = frac(cells.b);
25+
cells.rg = TEXEL_HALF + cells.rg * TEXEL_SIZE;
26+
cells.r += (cells.b - lut_frac) * TEXEL_FIX;
27+
28+
// Final LUT UVs
29+
float4 uvs = float4(cells.rg, cells.r + TEXEL_FIX, cells.g);
30+
31+
// Group offset
32+
float2 grp_offset = float2(0.0, ssfx_lut.y / LUT_GROUPS);
33+
34+
// Sample LUTs
35+
float3 lut_col = lerp( s_lut_atlas.Sample(smp_linear, uvs.xy + grp_offset).rgb,
36+
s_lut_atlas.Sample(smp_linear, uvs.zw + grp_offset).rgb,
37+
lut_frac);
38+
39+
#ifdef G_ADVANCE_TRANSITION
40+
41+
// Group2 offset
42+
grp_offset = float2(0.0, ssfx_lut.z / LUT_GROUPS);
43+
44+
// Sample transition LUTs
45+
float3 SecondLUT = lerp(s_lut_atlas.Sample(smp_linear, uvs.xy + grp_offset).rgb,
46+
s_lut_atlas.Sample(smp_linear, uvs.zw + grp_offset).rgb,
47+
lut_frac);
48+
49+
lut_col = lerp(lut_col, SecondLUT, ssfx_lut.w);
50+
#endif
51+
52+
return lerp(base_col.rgb, lut_col.rgb, ssfx_lut.x);
53+
54+
}
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
/**
2+
* @ Version: SCREEN SPACE SHADERS - UPDATE 19
3+
* @ Description: Wind Main File
4+
* @ Modified time: 2023-12-23 16:05
5+
* @ Author: https://www.moddb.com/members/ascii1457
6+
* @ Mod: https://www.moddb.com/mods/stalker-anomaly/addons/screen-space-shaders
7+
*/
8+
9+
uniform float4 wind_params;
10+
11+
uniform float4 ssfx_wsetup_grass; // Anim Speed - Turbulence - Push - Wave
12+
uniform float4 ssfx_wsetup_trees; // Branches Speed - Trunk Speed - Bending - Min Wind Speed
13+
uniform float4 ssfx_wind_anim;
14+
15+
Texture2D s_waves;
16+
sampler smp_linear2;
17+
18+
struct wind_setup
19+
{
20+
float2 direction;
21+
float speed;
22+
float sqrt_speed;
23+
24+
float trees_animspeed;
25+
float trees_trunk_animspeed;
26+
float trees_bend;
27+
28+
float grass_animspeed;
29+
float grass_turbulence;
30+
float grass_push;
31+
float grass_wave;
32+
};
33+
34+
wind_setup ssfx_wind_setup()
35+
{
36+
wind_setup wsetup;
37+
38+
// Direction. Radians to Vector
39+
float r = -wind_params.x + 1.57079f;
40+
wsetup.direction = float2(cos(r),sin(r));
41+
42+
// Wind Speed
43+
wsetup.speed = max(ssfx_wsetup_trees.w, saturate(wind_params.y * 0.001));
44+
wsetup.sqrt_speed = saturate(sqrt(wsetup.speed * 1.66f));
45+
46+
// Setup
47+
wsetup.grass_animspeed = ssfx_wsetup_grass.x;
48+
wsetup.grass_turbulence = ssfx_wsetup_grass.y;
49+
wsetup.grass_push = ssfx_wsetup_grass.z;
50+
wsetup.grass_wave = ssfx_wsetup_grass.w;
51+
52+
wsetup.trees_animspeed = ssfx_wsetup_trees.x;
53+
wsetup.trees_trunk_animspeed = ssfx_wsetup_trees.y;
54+
wsetup.trees_bend = ssfx_wsetup_trees.z;
55+
56+
return wsetup;
57+
}
58+
59+
#ifdef SSFX_WIND_ISGRASS
60+
61+
// Flow Map - X: X-Anim | Y: Z-Anim | Z: Wind Wave | W : Detail
62+
63+
float3 ssfx_wind_grass(float3 pos, float H, wind_setup W)
64+
{
65+
// Height Limit. ( Add stiffness to tall grass )
66+
float HLimit = saturate(H * H - 0.01f) * saturate(1.0f - H * 0.1f);
67+
68+
// Offset animation
69+
float2 Offset = -ssfx_wind_anim.xy * W.grass_animspeed;
70+
71+
// Sample ( The scale defines the detail of the motion )
72+
float3 Flow = s_waves.SampleLevel( smp_linear2, (pos.xz + Offset) * 0.018f, 0);
73+
74+
// Grass Motion ( -1.0 ~ 1.0 ). Turbulence.
75+
float2 GrassMotion = (Flow.xy * 2.0f - 1.0f) * W.grass_turbulence;
76+
77+
// Apply wind direction and flow. Wind push.
78+
float2 WindDir = Flow.z * W.direction * W.grass_push;
79+
80+
// Add everything and apply height limit
81+
float3 Final = float3(GrassMotion.x + WindDir.x, Flow.z * W.grass_wave, GrassMotion.y + WindDir.y) * W.speed * HLimit;
82+
83+
return Final;
84+
}
85+
86+
#else // Non Grass
87+
88+
float3 ssfx_wind_tree_trunk(float3 pos, float Tree_H, wind_setup W)
89+
{
90+
// Phase ( from matrix ) + Offset
91+
float Phase = m_xform._24 + ssfx_wind_anim.z * W.trees_trunk_animspeed;
92+
93+
// Trunk wave
94+
float TWave = (cos(Phase) * sin(Phase * 5.0f) + 0.5f) * W.trees_bend;
95+
96+
// Wind speed
97+
float WSpeed = saturate(W.sqrt_speed * 1.5f);
98+
99+
// Base wind speed displacement
100+
float Base_Bend = WSpeed * 0.006f * saturate(1.0f - Tree_H * 0.005f);
101+
102+
// Intensity ( Squared height )
103+
Base_Bend *= Tree_H * Tree_H * TWave * WSpeed;
104+
105+
// Apply direction
106+
float2 Final = Base_Bend.xx * W.direction;
107+
108+
return float3(Final, saturate((TWave + 1.0f) * 0.5));
109+
}
110+
111+
float3 ssfx_wind_tree_branches(float3 pos, float Tree_H, float tc_y, wind_setup W)
112+
{
113+
// UV Offset
114+
float2 Offset = -ssfx_wind_anim.xy * W.trees_animspeed;
115+
116+
// Sample flow map
117+
float3 Flow = s_waves.SampleLevel( smp_linear2, (pos.xz + Offset) * 0.02f, 0);
118+
119+
// Sample 2, slower and detailed
120+
float3 Flow2 = s_waves.SampleLevel( smp_linear2, (pos.xz + Offset * 0.2f) * 0.1f, 0);
121+
122+
// Branch motion [ -1.0 ~ 1.0 ]
123+
float3 branchMotion = float3(Flow.x, Flow2.y, Flow.y) * 2.0f - 1.0f;
124+
125+
// Trunk position
126+
float3 Trunk = ssfx_wind_tree_trunk(pos, Tree_H, W);
127+
128+
// Gust from trunk data.
129+
branchMotion.xz *= Trunk.z * clamp(Tree_H * 0.1f, 1.0f, 2.5f);
130+
131+
// Add wind direction
132+
branchMotion.xz += Flow2.z * W.direction;
133+
134+
// Add wind gust
135+
branchMotion.y *= saturate(Tree_H * 0.1f);
136+
137+
// Everything is limited by the UV and wind speed
138+
branchMotion *= (1.0f - tc_y) * W.speed;
139+
140+
// Add trunk animation
141+
branchMotion.xz += Trunk.xy;
142+
143+
return branchMotion;
144+
}
145+
146+
#endif
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// [ SETTINGS ] [ LUT ]
2+
3+
#define G_LUT_SIZE_W 1024.0 // Width of your LUT texture
4+
5+
#define G_CELLS_SIZE 32 // Width/Height of your cell
6+
#define G_CELLS_GROUPS 4 // Quantity of tables in your texture
7+
8+
//#define G_ADVANCE_TRANSITION // Note for Modders: You can enable this option to do smooth transitions between tables in realtime. Check the script
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// [ SETTINGS ] [ Terrain ]
2+
3+
#define TERRAIN_WATER_LEVEL 1.0 // Max water level
4+
5+
#define TERRAIN_POM_STEPS_MAX 12 // More samples generate smoother results. You can lower this value to improve performance.
6+
#define TERRAIN_POM_STEPS_MIN 3 // Minimum quantity of steps
7+
8+
#define TERRAIN_POM_AO 0.125f // Basic ambient occlusion strength
9+
#define TERRAIN_POM_PLANE 0.5 // [ 0.5f ~ 1.0f ]
10+
#define TERRAIN_POM_RANGE 20 // Max distance of the parallax rendering
11+
12+
//#define TERRAIN_GTR_COMPATIBILITY // Read the height from the alpha channel of the color texture.
13+
14+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* @ Version: SCREEN SPACE SHADERS - UPDATE 20
3+
* @ Description: Terrain Shader ( Shadows )
4+
* @ Modified time: 2024-01-13 22:30
5+
* @ Author: https://www.moddb.com/members/ascii1457
6+
* @ Mod: https://www.moddb.com/mods/stalker-anomaly/addons/screen-space-shaders
7+
*/
8+
9+
#include "common.h"
10+
11+
struct a2v
12+
{
13+
float4 P : POSITION; // Object-space position
14+
};
15+
16+
//////////////////////////////////////////////////////////////////////////////////////////
17+
// Vertex
18+
v2p_shadow_direct main ( a2v I )
19+
{
20+
v2p_shadow_direct O;
21+
22+
// Apply a small offset to avoid the Parallax depth offset.
23+
float4 pos = I.P;
24+
pos.y -= 0.1f;
25+
26+
O.hpos = mul (m_WVP, pos );
27+
28+
29+
#ifndef USE_HWSMAP
30+
O.depth = O.hpos.z;
31+
#endif
32+
return O;
33+
}
34+
FXVS;

res/gamedata/shaders/r5/ssfx_ao.ps

5 KB
Binary file not shown.
1.86 KB
Binary file not shown.
487 Bytes
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function normal (shader, t_base, t_second, t_detail)
2+
shader:begin ("ssfx_hud_skin0","ssfx_hud_motion")
3+
: fog (false)
4+
: emissive (false)
5+
: zb (true, true)
6+
end
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* @ Version: SCREEN SPACE SHADERS - UPDATE 21
3+
* @ Description: HUD Motion Vectors ( RM_SINGLE )
4+
* @ Modified time: 2024-07-18 07:26
5+
* @ Author: https://www.moddb.com/members/ascii1457
6+
* @ Mod: https://www.moddb.com/mods/stalker-anomaly/addons/screen-space-shaders
7+
*/
8+
9+
#include "ssfx_skin_hud.h"
10+
11+
float4x4 m_bone; // Bone matrix
12+
float4x4 m_WVP_prev;
13+
14+
v2p_hud _main( v_model_hud I, float3 psp )
15+
{
16+
v2p_hud O;
17+
18+
O.HPos = mul( m_WVP, I.P );
19+
20+
// Apply bone matrix
21+
float3 Pbone = mul( m_bone, I.P );
22+
23+
O.PC = O.HPos; // Current
24+
O.PP = mul(m_WVP_prev, float4(Pbone, 1.0f)); // Previous
25+
26+
return O;
27+
}
28+
29+
v2p_hud main(v_model_hud v) { return _main(v, 0); }
30+
31+
FXVS;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function normal (shader, t_base, t_second, t_detail)
2+
shader:begin ("ssfx_hud_skin1","ssfx_hud_motion")
3+
: fog (false)
4+
: emissive (false)
5+
: zb (true, true)
6+
end

0 commit comments

Comments
 (0)