Skip to content

Commit

Permalink
xrRender_R1: ability to disable lightmaps with FFP enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed May 1, 2023
1 parent 025120a commit 1863fe8
Show file tree
Hide file tree
Showing 18 changed files with 112 additions and 87 deletions.
2 changes: 1 addition & 1 deletion src/Layers/xrRender/Blender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void IBlender::Compile(CBlender_Compile& C)
// 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)
if (!ps_r1_flags.is_any(R1FLAG_FFP_LIGHTMAPS | R1FLAG_DLIGHTS))
C.SetParams(oPriority.value, oStrictSorting.value ? true : false);
else
C.SetParams(oPriority.value, oStrictSorting.value ? true : false);
Expand Down
5 changes: 4 additions & 1 deletion src/Layers/xrRender/Light_DB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ void CLight_DB::add_light(light* L)
L->frame_render = Device.dwFrame;
#if RENDER == R_R1
if (L->flags.bStatic)
return; // skip static lighting, 'cause they are in lmaps
{
if (!RImplementation.o.ffp || ps_r1_flags.test(R1FLAG_FFP_LIGHTMAPS))
return; // skip static lighting, 'cause they are in lmaps
}
if (ps_r1_flags.test(R1FLAG_DLIGHTS))
RImplementation.L_Dynamic->add(L);
#else
Expand Down
20 changes: 13 additions & 7 deletions 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 (ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT)
if (!ps_r1_flags.is_any(R1FLAG_FFP_LIGHTMAPS | R1FLAG_DLIGHTS))
{
C.PassBegin();
{
Expand Down Expand Up @@ -103,9 +103,12 @@ void CBlender_default::CompileFFP(CBlender_Compile& C) const
C.PassSET_LightFog(false, true);

// Stage0 - Lightmap
C.StageBegin();
C.StageTemplate_LMAP0();
C.StageEnd();
if (ps_r1_flags.test(R1FLAG_FFP_LIGHTMAPS))
{
C.StageBegin();
C.StageTemplate_LMAP0();
C.StageEnd();
}

// Stage1 - Base texture
C.StageBegin();
Expand All @@ -128,9 +131,12 @@ void CBlender_default::CompileFFP(CBlender_Compile& C) const
C.PassSET_LightFog(false, false);

// Stage0 - Lightmap
C.StageBegin();
C.StageTemplate_LMAP0();
C.StageEnd();
if (ps_r1_flags.test(R1FLAG_FFP_LIGHTMAPS))
{
C.StageBegin();
C.StageTemplate_LMAP0();
C.StageEnd();
}
}
C.PassEnd();
break;
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 (ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT)
if (!ps_r1_flags.is_any(R1FLAG_FFP_LIGHTMAPS | R1FLAG_DLIGHTS))
{
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 (ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT)
if (!ps_r1_flags.is_any(R1FLAG_FFP_LIGHTMAPS | R1FLAG_DLIGHTS))
{
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 (ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT)
if (!ps_r1_flags.is_any(R1FLAG_FFP_LIGHTMAPS | R1FLAG_DLIGHTS))
{
CompileForEditor(C);
return;
Expand Down
68 changes: 43 additions & 25 deletions 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 (ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT)
if (!ps_r1_flags.is_any(R1FLAG_FFP_LIGHTMAPS | R1FLAG_DLIGHTS))
{
if (bConstant)
compile_EDc(C);
Expand Down Expand Up @@ -174,9 +174,12 @@ void CBlender_LaEmB::compile_2(CBlender_Compile& C)
C.PassSET_LightFog(FALSE, TRUE);

// Stage0 - Lightmap
C.StageBegin();
C.StageTemplate_LMAP0();
C.StageEnd();
if (ps_r1_flags.test(R1FLAG_FFP_LIGHTMAPS))
{
C.StageBegin();
C.StageTemplate_LMAP0();
C.StageEnd();
}

// Stage1 - Environment map
C.StageBegin();
Expand Down Expand Up @@ -220,11 +223,14 @@ void CBlender_LaEmB::compile_2c(CBlender_Compile& C)
C.StageEnd();

// Stage1 - [+] Lightmap
C.StageBegin();
C.StageSET_Color(D3DTA_TEXTURE, D3DTOP_ADD, D3DTA_CURRENT);
C.StageSET_Alpha(D3DTA_TEXTURE, D3DTOP_ADD, D3DTA_CURRENT);
C.StageSET_TMC("$base1", "$null", "$null", 1);
C.StageEnd();
if (ps_r1_flags.test(R1FLAG_FFP_LIGHTMAPS))
{
C.StageBegin();
C.StageSET_Color(D3DTA_TEXTURE, D3DTOP_ADD, D3DTA_CURRENT);
C.StageSET_Alpha(D3DTA_TEXTURE, D3DTOP_ADD, D3DTA_CURRENT);
C.StageSET_TMC("$base1", "$null", "$null", 1);
C.StageEnd();
}
}
C.PassEnd();

Expand Down Expand Up @@ -255,9 +261,12 @@ void CBlender_LaEmB::compile_3(CBlender_Compile& C)
C.PassSET_LightFog(FALSE, TRUE);

// Stage0 - [=] Lightmap
C.StageBegin();
C.StageTemplate_LMAP0();
C.StageEnd();
if (ps_r1_flags.test(R1FLAG_FFP_LIGHTMAPS))
{
C.StageBegin();
C.StageTemplate_LMAP0();
C.StageEnd();
}

// Stage1 - [+] Env-map
C.StageBegin();
Expand Down Expand Up @@ -293,11 +302,14 @@ void CBlender_LaEmB::compile_3c(CBlender_Compile& C)
C.StageEnd();

// Stage0 - [+] Lightmap
C.StageBegin();
C.StageSET_Color(D3DTA_TEXTURE, D3DTOP_ADD, D3DTA_CURRENT);
C.StageSET_Alpha(D3DTA_TEXTURE, D3DTOP_ADD, D3DTA_CURRENT);
C.StageSET_TMC("$base1", "$null", "$null", 1);
C.StageEnd();
if (ps_r1_flags.test(R1FLAG_FFP_LIGHTMAPS))
{
C.StageBegin();
C.StageSET_Color(D3DTA_TEXTURE, D3DTOP_ADD, D3DTA_CURRENT);
C.StageSET_Alpha(D3DTA_TEXTURE, D3DTOP_ADD, D3DTA_CURRENT);
C.StageSET_TMC("$base1", "$null", "$null", 1);
C.StageEnd();
}

// Stage2 - [*] Base
C.StageBegin();
Expand All @@ -320,9 +332,12 @@ void CBlender_LaEmB::compile_L(CBlender_Compile& C)
C.PassSET_LightFog(FALSE, FALSE);

// Stage0 - Lightmap
C.StageBegin();
C.StageTemplate_LMAP0();
C.StageEnd();
if (ps_r1_flags.test(R1FLAG_FFP_LIGHTMAPS))
{
C.StageBegin();
C.StageTemplate_LMAP0();
C.StageEnd();
}

// Stage1 - Environment map
C.StageBegin();
Expand Down Expand Up @@ -350,11 +365,14 @@ void CBlender_LaEmB::compile_Lc(CBlender_Compile& C)
C.StageEnd();

// Stage1 - [+] Lightmap
C.StageBegin();
C.StageSET_Color(D3DTA_TEXTURE, D3DTOP_ADD, D3DTA_CURRENT);
C.StageSET_Alpha(D3DTA_TEXTURE, D3DTOP_ADD, D3DTA_CURRENT);
C.StageSET_TMC("$base1", "$null", "$null", 1);
C.StageEnd();
if (ps_r1_flags.test(R1FLAG_FFP_LIGHTMAPS))
{
C.StageBegin();
C.StageSET_Color(D3DTA_TEXTURE, D3DTOP_ADD, D3DTA_CURRENT);
C.StageSET_Alpha(D3DTA_TEXTURE, D3DTOP_ADD, D3DTA_CURRENT);
C.StageSET_TMC("$base1", "$null", "$null", 1);
C.StageEnd();
}
}
C.PassEnd();
}
39 changes: 24 additions & 15 deletions 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 (ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT)
if (!ps_r1_flags.is_any(R1FLAG_FFP_LIGHTMAPS | R1FLAG_DLIGHTS))
compile_ED(C);
else
{
Expand Down Expand Up @@ -125,9 +125,12 @@ void CBlender_LmEbB::compile_2(CBlender_Compile& C) const
C.PassSET_LightFog(FALSE, TRUE);

// Stage0 - Detail
C.StageBegin();
C.StageTemplate_LMAP0();
C.StageEnd();
if (ps_r1_flags.test(R1FLAG_FFP_LIGHTMAPS))
{
C.StageBegin();
C.StageTemplate_LMAP0();
C.StageEnd();
}
}
C.PassEnd();

Expand Down Expand Up @@ -178,14 +181,17 @@ void CBlender_LmEbB::compile_3(CBlender_Compile& C) const
C.StageEnd();

// Stage2 - [*] Lightmap
C.StageBegin();
C.StageSET_Address(D3DTADDRESS_CLAMP);
C.StageSET_Color(D3DTA_TEXTURE, D3DTOP_MODULATE2X, D3DTA_CURRENT);
C.StageSET_Alpha(D3DTA_TEXTURE, D3DTOP_SELECTARG2, D3DTA_CURRENT);
C.Stage_Texture("$base1");
C.Stage_Matrix("$null", 1);
C.Stage_Constant("$null");
C.StageEnd();
if (ps_r1_flags.test(R1FLAG_FFP_LIGHTMAPS))
{
C.StageBegin();
C.StageSET_Address(D3DTADDRESS_CLAMP);
C.StageSET_Color(D3DTA_TEXTURE, D3DTOP_MODULATE2X, D3DTA_CURRENT);
C.StageSET_Alpha(D3DTA_TEXTURE, D3DTOP_SELECTARG2, D3DTA_CURRENT);
C.Stage_Texture("$base1");
C.Stage_Matrix("$null", 1);
C.Stage_Constant("$null");
C.StageEnd();
}
}
C.PassEnd();
}
Expand All @@ -200,9 +206,12 @@ void CBlender_LmEbB::compile_L(CBlender_Compile& C) const
C.PassSET_LightFog(FALSE, FALSE);

// Stage0 - Detail
C.StageBegin();
C.StageTemplate_LMAP0();
C.StageEnd();
if (ps_r1_flags.test(R1FLAG_FFP_LIGHTMAPS))
{
C.StageBegin();
C.StageTemplate_LMAP0();
C.StageEnd();
}
}
C.PassEnd();
}
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 (ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT)
if (!ps_r1_flags.is_any(R1FLAG_FFP_LIGHTMAPS | R1FLAG_DLIGHTS))
{
C.PassBegin();
{
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/blenders/Blender_Model_EbB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void CBlender_Model_EbB::Compile(CBlender_Compile& C)

void CBlender_Model_EbB::CompileFFP(CBlender_Compile& C) const
{
const bool constant_lighting = ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT;
const bool constant_lighting = !ps_r1_flags.is_any(R1FLAG_FFP_LIGHTMAPS | R1FLAG_DLIGHTS);
const size_t element = constant_lighting ? SE_R1_NORMAL_LQ : C.iElement;
const auto modulate = constant_lighting ? D3DTOP_MODULATE : D3DTOP_MODULATE2X;

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 (ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT)
if (!ps_r1_flags.is_any(R1FLAG_FFP_LIGHTMAPS | R1FLAG_DLIGHTS))
{
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(ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT, TRUE);
C.PassSET_LightFog(FALSE, 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 (ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT)
if (!ps_r1_flags.is_any(R1FLAG_FFP_LIGHTMAPS | R1FLAG_DLIGHTS))
{
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(ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT, TRUE);
C.PassSET_LightFog(FALSE, TRUE);

// Stage1 - Base texture
C.StageBegin();
Expand Down
20 changes: 13 additions & 7 deletions 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 (ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT)
if (!ps_r1_flags.is_any(R1FLAG_FFP_LIGHTMAPS | R1FLAG_DLIGHTS))
{
C.PassBegin();
{
Expand Down Expand Up @@ -105,9 +105,12 @@ void CBlender_default_aref::CompileFFP(CBlender_Compile& C) const
C.PassSET_LightFog(false, true);

// Stage0 - Lightmap
C.StageBegin();
C.StageTemplate_LMAP0();
C.StageEnd();
if (ps_r1_flags.test(R1FLAG_FFP_LIGHTMAPS))
{
C.StageBegin();
C.StageTemplate_LMAP0();
C.StageEnd();
}

// Stage1 - Base texture
C.StageBegin();
Expand All @@ -128,9 +131,12 @@ void CBlender_default_aref::CompileFFP(CBlender_Compile& C) const
C.PassSET_LightFog(false, true);

// Stage0 - Lightmap
C.StageBegin();
C.StageTemplate_LMAP0();
C.StageEnd();
if (ps_r1_flags.test(R1FLAG_FFP_LIGHTMAPS))
{
C.StageBegin();
C.StageTemplate_LMAP0();
C.StageEnd();
}
}
C.PassEnd();
break;
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 @@ -46,7 +46,7 @@ void CBlender_Detail_Still::CompileFFP(CBlender_Compile& C) const
else
C.PassSET_Blend_SET(TRUE, 200);

if (ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT)
if (!ps_r1_flags.is_any(R1FLAG_FFP_LIGHTMAPS | R1FLAG_DLIGHTS))
{
C.PassSET_LightFog(TRUE, TRUE);

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 @@ -58,7 +58,7 @@ void CBlender_Tree::CompileFFP(CBlender_Compile& C) const
else
C.PassSET_Blend_SET(TRUE, 200);

/*if (ps_r1_ffp_lighting_mode == R1_FFP_LIGHTING_CONSTANT)
/*if (!ps_r1_flags.is_any(R1FLAG_FFP_LIGHTMAPS | R1FLAG_DLIGHTS))
{
C.PassSET_LightFog(TRUE, TRUE);
Expand Down
Loading

1 comment on commit 1863fe8

@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.