Skip to content

Commit 1c7893d

Browse files
committed
Апдейт шейдеров [skip ci]
1 parent 0c6d7b9 commit 1c7893d

Some content is hidden

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

43 files changed

+102
-149
lines changed

Game/Resources_SoC_1.0006/gamedata/shaders/r3/Gauss.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#ifndef GAUSSBLUR_H_INCLUDED
22
#define GAUSSBLUR_H_INCLUDED
33

4-
uniform float4 screen_res; // Screen resolution (x-Width,y-Height, zw - 1/resolution)
5-
64
float4 Gauss(Texture2D t2d, float2 texCoord, int factor, bool optimize)
75
{
86
float4 outColor = 0.f;
Binary file not shown.
Binary file not shown.
Binary file not shown.

Game/Resources_SoC_1.0006/gamedata/shaders/r3/common.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "common_cbuffers.h"
1111
#include "common_functions.h"
1212

13-
// #define USE_SUPER_SPECULAR
1413
#define USE_SUNMASK
1514

1615
#ifdef USE_R2_STATIC_SUN
@@ -29,7 +28,6 @@
2928
// #define DBG_TEST_LIGHT
3029
// #define DBG_TEST_LIGHT_SPEC
3130
32-
// #define USE_GAMMA_22
3331
// #define USE_SJITTER
3432
// #define USE_SUNFILTER
3533
// #define USE_FETCH4
@@ -48,7 +46,6 @@
4846
// #define USE_LM_HEMI //- shader defined
4947
// #define USE_DISTORT //- shader defined
5048
// #define USE_SUNMASK //- shader defined
51-
// #define DBG_TMAPPING
5249
//////////////////////////////////////////////////////////////////////////////////////////
5350
5451
uniform float4 J_direct [6];

Game/Resources_SoC_1.0006/gamedata/shaders/r3/common_functions.h

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -91,50 +91,20 @@ float3 calc_reflection(float3 pos_w, float3 norm_w) { return reflect(normalize(p
9191
#define USABLE_BIT_15 uint(0x80000000)
9292
#define MUST_BE_SET uint(0x40000000) // This flag *must* be stored in the floating-point representation of the bit flag to store
9393

94-
/*
95-
float2 gbuf_pack_normal( float3 norm )
94+
// RainbowZerg: use spheremap transform (Crytek's implementation) for normals packing
95+
float2 gbuf_pack_normal(float3 N)
9696
{
97-
float2 res;
98-
99-
res = 0.5 * ( norm.xy + float2( 1, 1 ) ) ;
100-
res.x *= ( norm.z < 0 ? -1.0 : 1.0 );
101-
102-
return res;
103-
}
104-
105-
float3 gbuf_unpack_normal( float2 norm )
106-
{
107-
float3 res;
108-
109-
res.xy = ( 2.0 * abs( norm ) ) - float2(1,1);
110-
111-
res.z = ( norm.x < 0 ? -1.0 : 1.0 ) * sqrt( abs( 1 - res.x * res.x - res.y * res.y ) );
112-
113-
return res;
97+
return normalize(N.xy) * sqrt(N.z * 0.5 + 0.5);
98+
;
11499
}
115-
*/
116100

117-
// Holger Gruen AMD - I change normal packing and unpacking to make sure N.z is accessible without ALU cost
118-
// this help the HDAO compute shader to run more efficiently
119-
float2 gbuf_pack_normal(float3 norm)
120-
{
121-
float2 res;
122-
123-
res.x = norm.z;
124-
res.y = 0.5f * (norm.x + 1.0f);
125-
res.y *= (norm.y < 0.0f ? -1.0f : 1.0f);
126-
127-
return res;
128-
}
129-
130-
float3 gbuf_unpack_normal(float2 norm)
101+
float3 gbuf_unpack_normal(float2 enc)
131102
{
103+
// Spheremap transform
132104
float3 res;
133-
134-
res.z = norm.x;
135-
res.x = (2.0f * abs(norm.y)) - 1.0f;
136-
res.y = (norm.y < 0 ? -1.0 : 1.0) * sqrt(abs(1 - res.x * res.x - res.z * res.z));
137-
105+
float l = length(enc.xy);
106+
res.z = l * l * 2.0 - 1.0;
107+
res.xy = normalize(enc.xy) * sqrt(1.0 - res.z * res.z);
138108
return res;
139109
}
140110

Game/Resources_SoC_1.0006/gamedata/shaders/r3/effects_water.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function normal (shader, t_base, t_second, t_detail)
2626
shader:dx10texture ("s_env0", tex_env0)
2727
shader:dx10texture ("s_env1", tex_env1)
2828
shader:dx10texture ("s_position", "$user$position")
29-
shader:dx10texture ("s_image", "$user$generic0_temp")
29+
shader:dx10texture ("s_last_frame", "$user$generic0_temp")
3030
shader:dx10texture ("s_leaves", tex_leaves)
3131

3232
shader:dx10sampler ("smp_base")

Game/Resources_SoC_1.0006/gamedata/shaders/r3/effects_waterryaska.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function normal (shader, t_base, t_second, t_detail)
2626
shader:dx10texture ("s_env0", tex_env0)
2727
shader:dx10texture ("s_env1", tex_env1)
2828
shader:dx10texture ("s_position", "$user$position")
29-
shader:dx10texture ("s_image", "$user$generic0_temp")
29+
shader:dx10texture ("s_last_frame", "$user$generic0_temp")
3030
shader:dx10texture ("s_leaves", tex_leaves)
3131

3232
shader:dx10sampler ("smp_base")

Game/Resources_SoC_1.0006/gamedata/shaders/r3/effects_waterstuden.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function normal (shader, t_base, t_second, t_detail)
2626
shader:dx10texture ("s_env0", tex_env0)
2727
shader:dx10texture ("s_env1", tex_env1)
2828
shader:dx10texture ("s_position", "$user$position")
29-
shader:dx10texture ("s_image", "$user$generic0_temp")
29+
shader:dx10texture ("s_last_frame", "$user$generic0_temp")
3030
shader:dx10texture ("s_leaves", tex_leaves)
3131

3232
shader:dx10sampler ("smp_base")

Game/Resources_SoC_1.0006/gamedata/shaders/r3/hud_crosshair.vs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
#include "common_iostructs.h"
2-
//#include "common.h"
3-
4-
uniform float4 screen_res; // Screen resolution (x-Width,y-Height, zw - 1/resolution)
1+
#include "common.h"
52

63
//////////////////////////////////////////////////////////////////////////////////////////
74
// Vertex

Game/Resources_SoC_1.0006/gamedata/shaders/r3/hud_scope.vs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#include "common.h"
22

3-
uniform float4 screen_res; // x - width, y - height, z - 1/width, w - 1/height
4-
53
v2p_TL main(v_TL_positiont v)
64
{
75
v2p_TL O;
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Game/Resources_SoC_1.0006/gamedata/shaders/r3/ogse_functions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ float normalize_depth(float depth) { return (saturate(depth / FARPLANE)); }
1111
// global constants
1212
uniform float4 ogse_c_screen; // x - fFOV, y - fAspect, z - Zf/(Zf-Zn), w - Zn*tan(fFov/2)
1313

14-
half is_sky(float depth) { return step(abs(depth - SKY_DEPTH), SKY_EPS); }
14+
float is_sky(float depth) { return step(depth, SKY_EPS); }
1515
half is_not_sky(float depth) { return step(SKY_EPS, abs(depth - SKY_DEPTH)); }
1616

1717
float4 proj_to_screen(float4 proj)

Game/Resources_SoC_1.0006/gamedata/shaders/r3/ogsr_sslr.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
uniform float4 SSLR_params; // x - L
99
uniform float4x4 m_inv_v;
10-
uniform float4 screen_res;
1110

1211

1312
float3 calc_envmap(float3 vreflect)
Binary file not shown.

Game/Resources_SoC_1.0006/gamedata/shaders/r3/reflections.h

Lines changed: 53 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ By LVutner for X-Ray Oxygen project (2020)
2525
#define SSR_SAMPLES int(20) // Extreme
2626
#define SSR_DISTANCE float(400.0)
2727

28-
uniform float4 screen_res; // Screen resolution (x-Width,y-Height, zw - 1/resolution)
28+
#if defined(USE_MSAA)
29+
TEXTURE2DMS(float4, MSAA_SAMPLES) s_last_frame;
30+
#else
31+
Texture2D s_last_frame;
32+
#endif
2933

3034
/*Helper functions*/
3135
float RayAttenBorder(float2 pos, float value)
@@ -108,7 +112,11 @@ float4 compute_ssr(float3 position, float3 normal)
108112
float edge = RayAttenBorder(refl_tc.xy, SSR_EDGE_ATTENUATION);
109113

110114
/*Sample image with reflected TC*/
111-
float3 img = s_image.Load(int3(refl_tc.xy * screen_res.xy,0),0);
115+
#if defined(USE_MSAA)
116+
float3 img = s_last_frame.Load(refl_tc.xy * screen_res.xy, 0);
117+
#else
118+
float3 img = s_last_frame.Sample(smp_nofilter, refl_tc.xy);
119+
#endif
112120

113121
/*Image.rgb, Reflcontrol.a*/
114122
return float4(img.xyz, reflection*edge);
@@ -145,57 +153,61 @@ float3 specular_phong(float3 pnt, float3 normal, float3 light_direction)
145153
//*******************************************************************************************************************
146154
uniform float4 rain_params; //x = raindensity
147155

156+
#define WATER_SPLASHES_MAX_RADIUS 1.5 // Maximum number of cells a ripple can cross.
157+
//#define WATER_SPLASHES_DOUBLE_HASH // дополнительный шум
158+
148159
float hash12(float2 p)
149160
{
150-
float3 p3 = frac(float3(p.xyx) * .1031);
151-
p3 += dot(p3, p3.yzx + 19.19);
152-
return frac((p3.x + p3.y) * p3.z);
161+
float3 p3 = frac(float3(p.xyx) * .1031);
162+
p3 += dot(p3, p3.yzx + 19.19);
163+
return frac((p3.x + p3.y) * p3.z);
153164
}
154165

155166
float2 hash22(float2 p)
156167
{
157168
float3 p3 = frac(float3(p.xyx) * float3(.1031, .1030, .0973));
158-
p3 += dot(p3, p3.yzx+19.19);
159-
return frac((p3.xx+p3.yz)*p3.zy);
169+
p3 += dot(p3, p3.yzx + 19.19);
170+
return frac((p3.xx + p3.yz) * p3.zy);
160171
}
161172

162-
float ripples(float2 tc, float size)
173+
float3 calc_rain_splashes(float2 tc)
163174
{
164-
float2 uv = tc * size;
165-
float2 p0 = floor(uv);
166-
167-
float2 circles;
168-
for (int j = -2; j <= 2; ++j)
169-
{
170-
for (int i = -2; i <= 2; ++i)
171-
{
175+
float2 p0 = floor(tc * 35);
176+
177+
float circles = 0;
178+
179+
for (int j = -WATER_SPLASHES_MAX_RADIUS; j <= WATER_SPLASHES_MAX_RADIUS; ++j)
180+
{
181+
for (int i = -WATER_SPLASHES_MAX_RADIUS; i <= WATER_SPLASHES_MAX_RADIUS; ++i)
182+
{
172183
float2 pi = p0 + float2(i, j);
173-
float2 hsh = hash22(pi);
174-
float2 p = pi + hash22(hsh);
175-
176-
float t = frac(0.35f*timers.x + hash12(hsh));
177-
float2 v = p - uv;
178-
float d = length(v) - (float(2.f) + 1.)*t;
179-
180-
float h = 1e-3;
181-
182-
//1st pass
183-
float d1 = d - h;
184-
float p1 = sin(31.*d1) * smoothstep(-0.6, -0.3, d1) * smoothstep(0., -0.3, d1);
185-
//sec pass
186-
float d2 = d + h;
187-
float p2 = sin(31.*d2) * smoothstep(-0.6, -0.3, d2) * smoothstep(0., -0.3, d2);
188-
circles += 0.5 * normalize(v) * ((p2 - p1) / (2. * h) * (1. - t) * (1. - t));
189-
}
190-
}
191-
circles /= float((2*3+1)*(2*2+1));
192-
193-
float intensity = lerp(0.025f, 0.15, smoothstep(0.1, 0.6, frac(0.05 + 0.05)*2.-1.));
194-
float3 n = float3(circles, sqrt(1. - dot(circles, circles)));
195-
196-
float final = 10.*pow(clamp(dot(n, normalize(float3(1., 0.7, 0.5))), 0., 1.), 6.);
197-
return final;
184+
#ifdef WATER_SPLASHES_DOUBLE_HASH
185+
float2 hsh = hash22(pi);
186+
#else
187+
float2 hsh = pi;
188+
#endif
189+
float2 p = pi + hash22(hsh);
190+
191+
float t = frac(1.45f * timers.x + hash12(hsh));
192+
float2 v = p - tc * 35;
193+
194+
float d = (length(v) * 2.0f) - (float(WATER_SPLASHES_MAX_RADIUS) + 1.0) * t;
195+
196+
const float h = 1e-3;
197+
float d1 = d - h;
198+
float d2 = d + h;
199+
float p1 = sin(31. * d1) * smoothstep(-0.6, -0.3, d1) * smoothstep(0., -0.3, d1);
200+
float p2 = sin(31. * d2) * smoothstep(-0.6, -0.3, d2) * smoothstep(0., -0.3, d2);
201+
circles += 0.5 * normalize(v) * ((p2 - p1) / (2. * h) * (1. - t) * (1. - t));
202+
}
203+
}
204+
205+
float c = float(WATER_SPLASHES_MAX_RADIUS * 2 + 1);
206+
circles /= c * c;
207+
208+
return float3(circles.xx, sqrt(1.0f - dot(circles, circles)));
198209
}
210+
199211
//*******************************************************************************************************************
200212

201213
#endif

Game/Resources_SoC_1.0006/gamedata/shaders/r3/shared/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ cbuffer static_globals
4343
uniform float4 pos_decompression_params2;
4444

4545
uniform float4 parallax;
46-
// uniform float4 screen_res; // Screen resolution (x-Width,y-Height, zw - 1/resolution)
46+
uniform float4 screen_res; // Screen resolution (x-Width,y-Height, zw - 1/resolution)
4747
}
4848

4949
/*
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Game/Resources_SoC_1.0006/gamedata/shaders/r3/stub_notransform_aa_aa.vs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#include "common_iostructs.h"
2-
3-
uniform float4 screen_res; // Screen resolution (x-Width,y-Height, zw - 1/resolution)
1+
#include "common.h"
42

53
//////////////////////////////////////////////////////////////////////////////////////////
64
// Vertex

Game/Resources_SoC_1.0006/gamedata/shaders/r3/stub_notransform_build.vs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#include "common_iostructs.h"
2-
3-
float4 screen_res; // Screen resolution (x-Width,y-Height, zw - 1/resolution)
1+
#include "common.h"
42

53
//////////////////////////////////////////////////////////////////////////////////////////
64
// Vertex

Game/Resources_SoC_1.0006/gamedata/shaders/r3/stub_notransform_filter.vs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#include "common_iostructs.h"
2-
3-
float4 screen_res; // Screen resolution (x-Width,y-Height, zw - 1/resolution)
1+
#include "common.h"
42

53
//////////////////////////////////////////////////////////////////////////////////////////
64
// Vertex

Game/Resources_SoC_1.0006/gamedata/shaders/r3/stub_notransform_postpr.vs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#include "common_iostructs.h"
2-
3-
uniform float4 screen_res; // Screen resolution (x-Width,y-Height, zw - 1/resolution)
1+
#include "common.h"
42

53
//////////////////////////////////////////////////////////////////////////////////////////
64
// Vertex

Game/Resources_SoC_1.0006/gamedata/shaders/r3/stub_notransform_t.vs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#include "common_iostructs.h"
2-
3-
uniform float4 screen_res; // Screen resolution (x-Width,y-Height, zw - 1/resolution)
1+
#include "common.h"
42

53
//////////////////////////////////////////////////////////////////////////////////////////
64
// Vertex

Game/Resources_SoC_1.0006/gamedata/shaders/r3/stub_notransform_t_m2.vs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#include "common_iostructs.h"
2-
3-
uniform float4 screen_res; // Screen resolution (x-Width,y-Height, zw - 1/resolution)
1+
#include "common.h"
42

53
//////////////////////////////////////////////////////////////////////////////////////////
64
// Vertex

Game/Resources_SoC_1.0006/gamedata/shaders/r3/stub_notransform_t_m4.vs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#include "common_iostructs.h"
2-
3-
uniform float4 screen_res; // Screen resolution (x-Width,y-Height, zw - 1/resolution)
1+
#include "common.h"
42

53
//////////////////////////////////////////////////////////////////////////////////////////
64
// Vertex

Game/Resources_SoC_1.0006/gamedata/shaders/r3/stub_screen_space.vs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#include "common.h"
22

3-
uniform float4 screen_res; // Screen resolution (x-Width,y-Height, zw - 1/resolution)
4-
53
//////////////////////////////////////////////////////////////////////////////////////////
64
// Vertex
75
p_screen main(v2p_screen I)

0 commit comments

Comments
 (0)