Skip to content

Commit bc0e9e4

Browse files
committed
SSS 18.1 -> 21 engine update
1 parent ec2263a commit bc0e9e4

Some content is hidden

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

50 files changed

+2273
-105
lines changed

src/Layers/xrRender/Blender_Recorder_StandartBinding.cpp

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,24 @@ extern ENGINE_API Fvector4 ps_ssfx_wetsurfaces_2;
378378
extern ENGINE_API int ps_ssfx_is_underground;
379379
extern ENGINE_API Fvector4 ps_ssfx_lightsetup_1;
380380

381+
extern ENGINE_API float ps_ssfx_hud_hemi;
382+
extern ENGINE_API Fvector4 ps_ssfx_il;
383+
extern ENGINE_API Fvector4 ps_ssfx_il_setup1;
384+
extern ENGINE_API Fvector4 ps_ssfx_ao;
385+
extern ENGINE_API Fvector4 ps_ssfx_ao_setup1;
386+
extern ENGINE_API Fvector4 ps_ssfx_water;
387+
extern ENGINE_API Fvector4 ps_ssfx_water_setup1;
388+
extern ENGINE_API Fvector4 ps_ssfx_water_setup2;
389+
390+
extern ENGINE_API Fvector4 ps_ssfx_volumetric;
391+
extern ENGINE_API Fvector4 ps_ssfx_ssr_2;
392+
extern ENGINE_API Fvector4 ps_ssfx_terrain_offset;
393+
394+
extern ENGINE_API Fvector3 ps_ssfx_shadow_bias;
395+
extern ENGINE_API Fvector4 ps_ssfx_lut;
396+
extern ENGINE_API Fvector4 ps_ssfx_wind_grass;
397+
extern ENGINE_API Fvector4 ps_ssfx_wind_trees;
398+
381399
class cl_inv_v : public R_constant_setup
382400
{
383401
Fmatrix result;
@@ -617,6 +635,159 @@ class ssfx_florafixes_2 : public R_constant_setup
617635
};
618636
static ssfx_florafixes_2 binder_ssfx_florafixes_2;
619637

638+
class ssfx_wind_grass : public R_constant_setup
639+
{
640+
void setup(CBackend& cmd_list, R_constant* C) override
641+
{
642+
cmd_list.set_c(C, ps_ssfx_wind_grass);
643+
}
644+
};
645+
static ssfx_wind_grass binder_ssfx_wind_grass;
646+
647+
class ssfx_wind_trees : public R_constant_setup
648+
{
649+
void setup(CBackend& cmd_list, R_constant* C) override
650+
{
651+
cmd_list.set_c(C, ps_ssfx_wind_trees);
652+
}
653+
};
654+
static ssfx_wind_trees binder_ssfx_wind_trees;
655+
656+
class ssfx_wind_anim : public R_constant_setup
657+
{
658+
void setup(CBackend& cmd_list, R_constant* C) override
659+
{
660+
cmd_list.set_c(C, g_pGamePersistent->Environment().wind_anim);
661+
}
662+
};
663+
static ssfx_wind_anim binder_ssfx_wind_anim;
664+
665+
class ssfx_lut : public R_constant_setup
666+
{
667+
void setup(CBackend& cmd_list, R_constant* C) override
668+
{
669+
cmd_list.set_c(C, ps_ssfx_lut);
670+
}
671+
};
672+
static ssfx_lut binder_ssfx_lut;
673+
674+
class ssfx_shadow_bias : public R_constant_setup
675+
{
676+
void setup(CBackend& cmd_list, R_constant* C) override
677+
{
678+
cmd_list.set_c(C, ps_ssfx_shadow_bias.x, ps_ssfx_shadow_bias.y, 0.f, 0.f);
679+
}
680+
};
681+
static ssfx_shadow_bias binder_ssfx_shadow_bias;
682+
683+
class ssfx_terrain_offset : public R_constant_setup
684+
{
685+
void setup(CBackend& cmd_list, R_constant* C) override
686+
{
687+
cmd_list.set_c(C, ps_ssfx_terrain_offset);
688+
}
689+
};
690+
static ssfx_terrain_offset binder_ssfx_terrain_offset;
691+
692+
class ssfx_ssr_2 : public R_constant_setup
693+
{
694+
void setup(CBackend& cmd_list, R_constant* C) override
695+
{
696+
cmd_list.set_c(C, ps_ssfx_ssr_2);
697+
}
698+
};
699+
static ssfx_ssr_2 binder_ssfx_ssr_2;
700+
701+
class ssfx_volumetric : public R_constant_setup
702+
{
703+
void setup(CBackend& cmd_list, R_constant* C) override
704+
{
705+
cmd_list.set_c(C, ps_ssfx_volumetric);
706+
}
707+
};
708+
static ssfx_volumetric binder_ssfx_volumetric;
709+
710+
class ssfx_water : public R_constant_setup
711+
{
712+
void setup(CBackend& cmd_list, R_constant* C) override
713+
{
714+
cmd_list.set_c(C, ps_ssfx_water);
715+
}
716+
};
717+
static ssfx_water binder_ssfx_water;
718+
719+
class ssfx_water_setup1 : public R_constant_setup
720+
{
721+
void setup(CBackend& cmd_list, R_constant* C) override
722+
{
723+
cmd_list.set_c(C, ps_ssfx_water_setup1);
724+
}
725+
};
726+
static ssfx_water_setup1 binder_ssfx_water_setup1;
727+
728+
class ssfx_water_setup2 : public R_constant_setup
729+
{
730+
void setup(CBackend& cmd_list, R_constant* C) override
731+
{
732+
cmd_list.set_c(C, ps_ssfx_water_setup2);
733+
}
734+
};
735+
static ssfx_water_setup2 binder_ssfx_water_setup2;
736+
737+
class ssfx_ao : public R_constant_setup
738+
{
739+
void setup(CBackend& cmd_list, R_constant* C) override
740+
{
741+
cmd_list.set_c(C, ps_ssfx_ao);
742+
}
743+
};
744+
static ssfx_ao binder_ssfx_ao;
745+
746+
class ssfx_ao_setup1 : public R_constant_setup
747+
{
748+
void setup(CBackend& cmd_list, R_constant* C) override
749+
{
750+
cmd_list.set_c(C, ps_ssfx_ao_setup1);
751+
}
752+
};
753+
static ssfx_ao_setup1 binder_ssfx_ao_setup1;
754+
755+
class ssfx_il : public R_constant_setup
756+
{
757+
void setup(CBackend& cmd_list, R_constant* C) override
758+
{
759+
cmd_list.set_c(C, ps_ssfx_il);
760+
}
761+
};
762+
static ssfx_il binder_ssfx_il;
763+
764+
class ssfx_il_setup1 : public R_constant_setup
765+
{
766+
void setup(CBackend& cmd_list, R_constant* C) override
767+
{
768+
cmd_list.set_c(C, ps_ssfx_il_setup1);
769+
}
770+
};
771+
static ssfx_il_setup1 binder_ssfx_il_setup1;
772+
773+
class ssfx_hud_hemi : public R_constant_setup
774+
{
775+
void setup(CBackend& cmd_list, R_constant* C) override
776+
{
777+
cmd_list.set_c(C, ps_ssfx_hud_hemi, 0.f, 0.f, 0.f);
778+
}
779+
};
780+
static ssfx_hud_hemi binder_ssfx_hud_hemi;
781+
782+
class ssfx_issvp : public R_constant_setup
783+
{
784+
void setup(CBackend& cmd_list, R_constant* C) override
785+
{
786+
cmd_list.set_c(C, Device.m_SecondViewport.IsSVPFrame() ? 1.f : 0.f, 0.f, 0.f, 0.f);
787+
}
788+
};
789+
static ssfx_issvp binder_ssfx_issvp;
790+
620791
// Standart constant-binding
621792
void CBlender_Compile::SetMapping()
622793
{
@@ -726,4 +897,21 @@ void CBlender_Compile::SetMapping()
726897
r_Constant("ssfx_gloss", &binder_ssfx_gloss);
727898
r_Constant("ssfx_florafixes_1", &binder_ssfx_florafixes_1);
728899
r_Constant("ssfx_florafixes_2", &binder_ssfx_florafixes_2);
900+
r_Constant("ssfx_issvp", &binder_ssfx_issvp);
901+
r_Constant("ssfx_hud_hemi", &binder_ssfx_hud_hemi);
902+
r_Constant("ssfx_il_setup", &binder_ssfx_il);
903+
r_Constant("ssfx_il_setup2", &binder_ssfx_il_setup1);
904+
r_Constant("ssfx_ao_setup", &binder_ssfx_ao);
905+
r_Constant("ssfx_ao_setup2", &binder_ssfx_ao_setup1);
906+
r_Constant("ssfx_water", &binder_ssfx_water);
907+
r_Constant("ssfx_water_setup1", &binder_ssfx_water_setup1);
908+
r_Constant("ssfx_water_setup2", &binder_ssfx_water_setup2);
909+
r_Constant("ssfx_volumetric", &binder_ssfx_volumetric);
910+
r_Constant("ssfx_ssr_2", &binder_ssfx_ssr_2);
911+
r_Constant("ssfx_terrain_offset", &binder_ssfx_terrain_offset);
912+
r_Constant("ssfx_shadow_bias", &binder_ssfx_shadow_bias);
913+
r_Constant("ssfx_wind_anim", &binder_ssfx_wind_anim);
914+
r_Constant("ssfx_wsetup_grass", &binder_ssfx_wind_grass);
915+
r_Constant("ssfx_wsetup_trees", &binder_ssfx_wind_trees);
916+
r_Constant("ssfx_lut", &binder_ssfx_lut);
729917
}

src/Layers/xrRender/Light_Render_Direct_ComputeXFS.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ void CLight_Compute_XFORM_and_VIS::compute_xf_spot(light* L)
5151
float intensity1 = (L->color.r * 0.2125f + L->color.g * 0.7154f + L->color.b * 0.0721f);
5252
float intensity = (intensity0 + intensity1) / 2.f; // intensity1 tends to underestimate...
5353

54+
// [SSS 19] Improve this code later?
5455
// compute how much duelling frusta occurs [-1..1]-> 1 + [-0.5 .. +0.5]
55-
float duel_dot = 1.f - 0.5f * Device.vCameraDirection.dotproduct(L_dir);
56+
//float duel_dot = 1.f - 0.5f * Device.vCameraDirection.dotproduct(L_dir);
5657

5758
// compute how large the light is - give more texels to larger lights, assume 8m as being optimal radius
5859
float sizefactor = L->range / 8.f; // 4m = .5, 8m=1.f, 16m=2.f, 32m=4.f
@@ -63,17 +64,20 @@ void CLight_Compute_XFORM_and_VIS::compute_xf_spot(light* L)
6364
// factors
6465
float factor0 = powf(ssa, 1.f / 2.f); // ssa is quadratic
6566
float factor1 = powf(intensity, 1.f / 16.f); // less perceptually important?
66-
float factor2 = powf(duel_dot, 1.f / 4.f); // difficult to fast-change this -> visible
67+
//float factor2 = powf(duel_dot, 1.f / 4.f); // difficult to fast-change this -> visible
6768
float factor3 = powf(sizefactor, 1.f / 4.f); // this shouldn't make much difference
6869
float factor4 = powf(widefactor, 1.f / 2.f); // make it linear ???
69-
float factor = ps_r2_ls_squality * factor0 * factor1 * factor2 * factor3 * factor4;
70+
//float factor = ps_r2_ls_squality * factor0 * factor1 * factor2 * factor3 * factor4;
71+
float factor = ps_r2_ls_squality * factor0 * factor1 * factor3 * factor4;
7072

7173
// final size calc
74+
extern ENGINE_API Fvector3 ps_ssfx_shadows;
75+
u32 max_size = (u32)(RImplementation.o.smapsize <= ps_ssfx_shadows.y ? RImplementation.o.smapsize : ps_ssfx_shadows.y);
7276
u32 _size = iFloor(factor * SMAP_adapt_optimal);
73-
if (_size < SMAP_adapt_min)
74-
_size = SMAP_adapt_min;
75-
if (_size > SMAP_adapt_max)
76-
_size = SMAP_adapt_max;
77+
if (_size < ps_ssfx_shadows.x)
78+
_size = (u32)ps_ssfx_shadows.x;
79+
if (_size > max_size)
80+
_size = max_size;
7781
int _epsilon = iCeil(float(_size) * 0.01f);
7882
int _diff = _abs(int(_size) - int(_cached_size));
7983
L->X.S.size = (_diff >= _epsilon) ? _size : _cached_size;
@@ -91,10 +95,12 @@ void CLight_Compute_XFORM_and_VIS::compute_xf_spot(light* L)
9195
// _min(L->cone + deg2rad(4.5f), PI*0.98f) - Here, it is needed to enlarge the shadow map frustum to include also
9296
// displaced pixels and the pixels neighbor to the examining one.
9397
float tan_shift;
94-
if (L->flags.type == IRender_Light::POINT)
95-
tan_shift = deg2rad(11.5f);
98+
if (L->flags.type == IRender_Light::OMNIPART) // [ SSS ] 0.3f fix almost all frustum problems... 0.5f was the old value ( SSS 19 ) but was causing issues?
99+
tan_shift = 0.3f;
100+
else if (L->flags.type == IRender_Light::POINT)
101+
tan_shift = 0.2007129f; // deg2rad(11.5f);
96102
else
97-
tan_shift = deg2rad(3.5f);
103+
tan_shift = 0.0610865f; //deg2rad(3.5f);
98104

99105
L->X.S.project.build_projection(L->cone + tan_shift, 1.f, L->virtual_size, L->range + EPS_S);
100106
L->X.S.combine.mul(L->X.S.project, L->X.S.view);

src/Layers/xrRender/ResourceManager.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,13 @@ Shader* CResourceManager::_cpp_Create(
233233
S.E[5] = _CreateElement(std::move(E));
234234
}
235235

236+
// Hacky way to remove from the HUD mask transparent stuff. ( Let's try something better later... )
237+
if (GEnv.Render->hud_loading)
238+
{
239+
if (strstr(s_shader, "lens"))
240+
S.E[0]->passes[0]->ps->hud_disabled = TRUE;
241+
}
242+
236243
// Search equal in shaders array
237244
for (u32 it = 0; it < v_shaders.size(); it++)
238245
if (S.equal(v_shaders[it]))

src/Layers/xrRender/Shader.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ ShaderElement::ShaderElement()
8383
flags.bEmissive = FALSE;
8484
flags.bDistort = FALSE;
8585
flags.bWmark = FALSE;
86+
87+
// SSS Custom rendering
88+
flags.isLandscape = FALSE;
89+
flags.isWater = FALSE;
8690
}
8791

8892
BOOL ShaderElement::equal(ShaderElement& S)

src/Layers/xrRender/Shader.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ struct ECORE_API ShaderElement : public xr_resource_flagged
121121
u32 bEmissive : 1;
122122
u32 bDistort : 1;
123123
u32 bWmark : 1;
124+
u32 isLandscape : 1;
125+
u32 isWater : 1;
124126
};
125127

126128
Sflags flags;

src/Layers/xrRender/SkeletonCustom.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ class CKinematics : public FHierrarhyVisual, public IKinematics
134134
protected:
135135
SkeletonWMVec wallmarks;
136136
u32 wm_frame;
137+
u32 CurrentFrame;
137138

138139
xr_vector<dxRender_Visual*> children_invisible;
139140

src/Layers/xrRender/SkeletonX.cpp

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "xrCore/FMesh.hpp"
1111

1212
shared_str s_bones_array_const;
13+
shared_str s_bones_array_prev_const;
1314

1415
//////////////////////////////////////////////////////////////////////
1516
// Body Part
@@ -40,6 +41,33 @@ void CSkeletonX::_Copy(CSkeletonX* B)
4041
//////////////////////////////////////////////////////////////////////
4142
void CSkeletonX::_Render(CBackend& cmd_list, ref_geom& hGeom, u32 vCount, u32 iOffset, u32 pCount)
4243
{
44+
bool CalcVelocity = false;
45+
46+
#ifdef USE_DX11
47+
48+
CalcVelocity = RImplementation.Target->RVelocity;
49+
50+
if (CalcVelocity)
51+
{
52+
// Previous WVP
53+
RCache.set_c("m_WVP_prev", RImplementation.Target->Matrix_HUD_previous);
54+
55+
if (RenderMode > 1 && Device.dwFrame > Parent->CurrentFrame)
56+
{
57+
Parent->CurrentFrame = Device.dwFrame;
58+
59+
// Save bone matrix to use next frame
60+
for (u16 b = 0; b < Parent->LL_BoneCount(); b++)
61+
{
62+
CBoneInstance& Bone = Parent->LL_GetBoneInstance(b);
63+
Bone.mRenderTransform_prev.set(Bone.mRenderTransform_temp);
64+
Bone.mRenderTransform_temp.set(Bone.mRenderTransform);
65+
}
66+
}
67+
}
68+
69+
#endif
70+
4371
cmd_list.stat.r.s_dynamic.add(vCount);
4472
switch (RenderMode)
4573
{
@@ -53,6 +81,11 @@ void CSkeletonX::_Render(CBackend& cmd_list, ref_geom& hGeom, u32 vCount, u32 iO
5381
Fmatrix W;
5482
W.mul_43(cmd_list.xforms.m_w, Parent->LL_GetTransform_R(u16(RMS_boneid)));
5583
cmd_list.set_xform_world(W);
84+
85+
// Add the bone transform
86+
if (CalcVelocity)
87+
cmd_list.set_c("m_bone", Parent->LL_GetTransform_R(u16(RMS_boneid)));
88+
5689
cmd_list.set_Geometry(hGeom);
5790
cmd_list.Render(D3DPT_TRIANGLELIST, 0, 0, vCount, iOffset, pCount);
5891
cmd_list.stat.r.s_dynamic_inst.add(vCount);
@@ -67,8 +100,10 @@ void CSkeletonX::_Render(CBackend& cmd_list, ref_geom& hGeom, u32 vCount, u32 iO
67100
case RM_SKINNING_4B:
68101
case RM_SKINNING_4B_HQ:
69102
{
70-
// transfer matrices
103+
// transfer matrices ( current and previous )
71104
ref_constant array = cmd_list.get_c(s_bones_array_const);
105+
ref_constant array_prev = cmd_list.get_c(s_bones_array_prev_const);
106+
72107
u32 count = RMS_bonecount;
73108
for (u32 mid = 0; mid < count; mid++)
74109
{
@@ -77,6 +112,15 @@ void CSkeletonX::_Render(CBackend& cmd_list, ref_geom& hGeom, u32 vCount, u32 iO
77112
cmd_list.set_ca(&*array, id + 0, M._11, M._21, M._31, M._41);
78113
cmd_list.set_ca(&*array, id + 1, M._12, M._22, M._32, M._42);
79114
cmd_list.set_ca(&*array, id + 2, M._13, M._23, M._33, M._43);
115+
116+
if (CalcVelocity)
117+
{
118+
// Previus transform
119+
Fmatrix& Mprev = Parent->LL_GetBoneInstance(u16(mid)).mRenderTransform_prev;
120+
cmd_list.set_ca(&*array_prev, id + 0, Mprev._11, Mprev._21, Mprev._31, Mprev._41);
121+
cmd_list.set_ca(&*array_prev, id + 1, Mprev._12, Mprev._22, Mprev._32, Mprev._42);
122+
cmd_list.set_ca(&*array_prev, id + 2, Mprev._13, Mprev._23, Mprev._33, Mprev._43);
123+
}
80124
}
81125

82126
// render
@@ -153,6 +197,7 @@ void CSkeletonX::_Render_soft(CBackend& cmd_list, ref_geom& hGeom, u32 vCount, u
153197
void CSkeletonX::_Load(const char* N, IReader* data, u32& dwVertCount)
154198
{
155199
s_bones_array_const = "sbones_array";
200+
s_bones_array_prev_const = "sbones_array_prev";
156201
xr_vector<u16> bids;
157202

158203
// Load vertices

0 commit comments

Comments
 (0)