Skip to content

Commit

Permalink
Added console command to switch FFP lighting modes
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed Apr 27, 2023
1 parent 8f1b7ee commit 96f920a
Show file tree
Hide file tree
Showing 21 changed files with 46 additions and 24 deletions.
7 changes: 6 additions & 1 deletion src/Layers/xrRender/Blender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ void IBlender::Load(IReader& fs, u16)

void IBlender::Compile(CBlender_Compile& C)
{
if (C.bEditor)
// XXX: there was a bLighting variable
// which was set to false in 'if' path
// and set to true in 'else' path
// but it was ignored anyway in the SetParams ¯\_(ツ)_/¯.
// Need to research commits from 2003 in xray-soc-history more
if (ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT)
C.SetParams(oPriority.value, oStrictSorting.value ? true : false);
else
C.SetParams(oPriority.value, oStrictSorting.value ? true : false);
Expand Down
1 change: 0 additions & 1 deletion src/Layers/xrRender/Blender_Recorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class CBlender_Compile
R_constant_setup* detail_scaler;

bool bFFP;
bool bEditor;
bool bDetail;
bool bDetail_Diffuse;
bool bDetail_Bump;
Expand Down
2 changes: 0 additions & 2 deletions src/Layers/xrRender/ResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ Shader* CResourceManager::_cpp_Create(
// Access to template
C.BT = B;
C.bFFP = RImplementation.o.ffp;
C.bEditor = false;
C.bDetail = FALSE;
#ifdef _EDITOR
if (!C.BT)
Expand All @@ -162,7 +161,6 @@ Shader* CResourceManager::_cpp_Create(
return 0;
}
C.bFFP = true;
C.bEditor = true;
#else
UNUSED(s_shader);
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/ResourceManager_Scripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ Shader* CResourceManager::_lua_Create(LPCSTR d_shader, LPCSTR s_textures)

// Access to template
C.BT = nullptr;
C.bEditor = FALSE;
C.bFFP = FALSE;
C.bDetail = FALSE;

// Prepare
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/blenders/BlenderDefault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void CBlender_default::Compile(CBlender_Compile& C)

void CBlender_default::CompileFFP(CBlender_Compile& C) const
{
if (C.bEditor)
if (ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT)
{
C.PassBegin();
{
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/blenders/Blender_BmmD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void CBlender_BmmD::Compile(CBlender_Compile& C)

void CBlender_BmmD::CompileFFP(CBlender_Compile& C) const
{
if (C.bEditor)
if (ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT)
{
C.PassBegin();
{
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/blenders/Blender_Editor_Selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void CBlender_Editor_Selection::Compile(CBlender_Compile& C)
{
IBlender::Compile(C);

if (C.bEditor)
if (ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT)
{
CompileForEditor(C);
return;
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/blenders/Blender_Editor_Wire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void CBlender_Editor_Wire::Compile(CBlender_Compile& C)
{
IBlender::Compile(C);

if (C.bEditor)
if (ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT)
{
CompileForEditor(C);
return;
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/blenders/Blender_LaEmB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void CBlender_LaEmB::Compile(CBlender_Compile& C)

const bool bConstant = (0 != xr_stricmp(oT2_const, "$null"));

if (C.bEditor)
if (ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT)
{
if (bConstant)
compile_EDc(C);
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/blenders/Blender_Lm(EbB).cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void CBlender_LmEbB::Compile(CBlender_Compile& C)

void CBlender_LmEbB::CompileFFP(CBlender_Compile& C) const
{
if (C.bEditor)
if (ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT)
compile_ED(C);
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/blenders/Blender_Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void CBlender_Model::Compile(CBlender_Compile& C)

void CBlender_Model::CompileFFP(CBlender_Compile& C) const
{
if (C.bEditor)
if (ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT)
{
C.PassBegin();
{
Expand Down
7 changes: 4 additions & 3 deletions src/Layers/xrRender/blenders/Blender_Model_EbB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ void CBlender_Model_EbB::Compile(CBlender_Compile& C)

void CBlender_Model_EbB::CompileFFP(CBlender_Compile& C) const
{
const size_t element = C.bEditor ? SE_R1_NORMAL_LQ : C.iElement;
const auto modulate = C.bEditor ? D3DTOP_MODULATE : D3DTOP_MODULATE2X;
const bool constant_lighting = ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT;
const size_t element = constant_lighting ? SE_R1_NORMAL_LQ : C.iElement;
const auto modulate = constant_lighting ? D3DTOP_MODULATE : D3DTOP_MODULATE2X;

C.PassBegin();
{
if (C.bEditor && oBlend.value)
if (constant_lighting && oBlend.value)
{
C.PassSET_ZB(TRUE, FALSE);
C.PassSET_Blend_BLEND();
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRender/blenders/Blender_Vertex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void CBlender_Vertex::Compile(CBlender_Compile& C)

void CBlender_Vertex::CompileFFP(CBlender_Compile& C) const
{
if (C.bEditor)
if (ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT)
{
C.PassBegin();
{
Expand Down Expand Up @@ -97,7 +97,7 @@ void CBlender_Vertex::CompileFFP(CBlender_Compile& C) const
{
C.PassSET_ZB(TRUE, TRUE);
C.PassSET_Blend(FALSE, D3DBLEND_ONE, D3DBLEND_ZERO, FALSE, 0);
C.PassSET_LightFog(C.bEditor, TRUE);
C.PassSET_LightFog(ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT, TRUE);

// Stage0 - Base texture
C.StageBegin();
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRender/blenders/Blender_Vertex_aref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void CBlender_Vertex_aref::Compile(CBlender_Compile& C)

void CBlender_Vertex_aref::CompileFFP(CBlender_Compile& C) const
{
if (C.bEditor)
if (ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT)
{
C.PassBegin();
{
Expand Down Expand Up @@ -96,7 +96,7 @@ void CBlender_Vertex_aref::CompileFFP(CBlender_Compile& C) const
C.PassSET_Blend(TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA, TRUE, oAREF.value);
else
C.PassSET_Blend(TRUE, D3DBLEND_ONE, D3DBLEND_ZERO, TRUE, oAREF.value);
C.PassSET_LightFog(C.bEditor, TRUE);
C.PassSET_LightFog(ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT, TRUE);

// Stage1 - Base texture
C.StageBegin();
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/blenders/Blender_default_aref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void CBlender_default_aref::Compile(CBlender_Compile& C)

void CBlender_default_aref::CompileFFP(CBlender_Compile& C) const
{
if (C.bEditor)
if (ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT)
{
C.PassBegin();
{
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/blenders/Blender_detail_still.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void CBlender_Detail_Still::Compile(CBlender_Compile& C)

void CBlender_Detail_Still::CompileFFP(CBlender_Compile& C) const
{
if (C.bEditor)
if (ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT)
{
C.PassBegin();
{
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/blenders/Blender_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void CBlender_Tree::Compile(CBlender_Compile& C)

void CBlender_Tree::CompileFFP(CBlender_Compile& C) const
{
if (C.bEditor)
if (ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT)
{
C.PassBegin();
{
Expand Down
10 changes: 10 additions & 0 deletions src/Layers/xrRender/xrRender_console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ int ps_r1_GlowsPerFrame = 16; // r1-only
float ps_r1_fog_luminance = 1.1f; // r1-only
int ps_r1_SoftwareSkinning = 0; // r1-only

u32 ps_r1_ffp_lighting_mode = R1_FFP_LIGHTING_LIGHTMAP; // r1-only
const xr_token qffp_lighting_token[] =
{
{ "st_opt_ffp_constant", R1_FFP_LIGHTING_CONSTANT },
{ "st_opt_ffp_lightmap", R1_FFP_LIGHTING_LIGHTMAP },
{ "st_opt_ffp_dynamic", R1_FFP_LIGHTING_LIGHTS },
{ nullptr, -1 }
};

// R2
bool ps_r2_sun_static = false;
bool ps_r2_advanced_pp = true; // advanced post process and effects
Expand Down Expand Up @@ -802,6 +811,7 @@ void xrRender_initconsole()
CMD4(CCC_Integer, "r1_software_skinning", &ps_r1_SoftwareSkinning, 0, 2);

CMD3(CCC_Mask, "r1_ffp", &ps_r1_flags, R1FLAG_FFP);
CMD3(CCC_Token, "r1_ffp_lighting", &ps_r1_ffp_lighting_mode, qffp_lighting_token);

// R2
CMD4(CCC_Float, "r2_ssa_lod_a", &ps_r2_ssaLOD_A, 16, 96);
Expand Down
9 changes: 9 additions & 0 deletions src/Layers/xrRender/xrRender_console.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ extern ECORE_API Flags32 ps_r1_flags; // r1-only
extern ECORE_API float ps_r1_fog_luminance; // 1.f r1-only
extern ECORE_API int ps_r1_SoftwareSkinning; // r1-only

extern ECORE_API u32 ps_r1_ffp_lighting_mode;

enum R1_FFP_LIGHTING_MODE
{
R1_FFP_LIGHTING_CONSTANT, // SDK lighting – just constant lighting, not even lightmaps
R1_FFP_LIGHTING_LIGHTMAP,
R1_FFP_LIGHTING_LIGHTS,
};

enum
{
R1FLAG_DLIGHTS = (1 << 0),
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderDX11/dx11ResourceManager_Scripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ Shader* CResourceManager::_lua_Create(LPCSTR d_shader, LPCSTR s_textures)

// Access to template
C.BT = NULL;
C.bEditor = FALSE;
C.bFFP = FALSE;
C.bDetail = FALSE;

// Prepare
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderGL/glResourceManager_Scripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ Shader* CResourceManager::_lua_Create(LPCSTR d_shader, LPCSTR s_textures)

// Access to template
C.BT = nullptr;
C.bEditor = false;
C.bFFP = false;
C.bDetail = false;

// Prepare
Expand Down

1 comment on commit 96f920a

@Xottab-DUTY
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.