Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor of custom shader flags and removed of redundant code
  • Loading branch information
Redotix committed Aug 24, 2024
commit eb5a63f39f2854772d76ee35ec458cef39747c52
2 changes: 0 additions & 2 deletions src/Layers/xrRender/HW.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ class CHW
ID3D11RenderTargetView* pBaseRT; // combine with DX9 pBaseRT via typedef
ID3D11DepthStencilView* pBaseZB;

ID3D11Texture2D* pBaseTEXZB;

CHWCaps Caps;

D3D_DRIVER_TYPE m_DriverType; // DevT equivalent
Expand Down
14 changes: 8 additions & 6 deletions src/Layers/xrRender/Shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,21 @@ ShaderElement::ShaderElement()
flags.isLandscape = FALSE;
flags.isWater = FALSE;

flags.isScope = FALSE; // Redotix99: for 3D Shader Based Scopes
flags.isScope2 = FALSE;
flags.isScope3 = FALSE;
flags.iScopeLense = 0; // Redotix99: for 3D Shader Based Scopes
// 0 = eNoLense,
// 1 = eBackLense,
// 2 = eZwriteLense,
// 3 = eReticleLense
}

BOOL ShaderElement::equal(ShaderElement& S)
{
if (flags.iPriority != S.flags.iPriority) return FALSE;
if (flags.bStrictB2F != S.flags.bStrictB2F) return FALSE;
if (flags.bEmissive != S.flags.bEmissive) return FALSE;
if (flags.isScope != S.flags.isScope) return FALSE; // Redotix99: for 3D Shader Based Scopes
if (flags.isScope2 != S.flags.isScope2) return FALSE;
if (flags.isScope3 != S.flags.isScope3) return FALSE;

if (flags.iScopeLense != S.flags.iScopeLense) return FALSE; // Redotix99: for 3D Shader Based Scopes

if (flags.bLandscape != S.flags.bLandscape) return FALSE;
if (flags.bWmark != S.flags.bWmark) return FALSE;
if (flags.bDistort != S.flags.bDistort) return FALSE;
Expand Down
4 changes: 1 addition & 3 deletions src/Layers/xrRender/Shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ struct ECORE_API ShaderElement : public xr_resource_flagged
u32 isLandscape : 1;
u32 isWater : 1;

u32 isScope : 1; // Redotix99: for 3D Shader Based Scopes
u32 isScope2 : 1;
u32 isScope3 : 1;
u32 iScopeLense : 2; // Redotix99: for 3D Shader Based Scopes
};

public:
Expand Down
75 changes: 43 additions & 32 deletions src/Layers/xrRender/r__dsgraph_build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,38 +73,49 @@ void R_dsgraph_structure::r_dsgraph_insert_dynamic(dxRender_Visual* pVisual, Fve
// NOTE: Invisible elements exist only in R1
_MatrixItem item = {SSA, RI.val_pObject, pVisual, *RI.val_pTransform};

// Redotix99: for 3D Shader Based Scopes
if (sh->flags.isScope)
{
mapHUD_Node* N = mapHUD.insertInAnyWay(EPS);
N->val.ssa = SSA;
N->val.pObject = RI.val_pObject;
N->val.pVisual = pVisual;
N->val.Matrix = *RI.val_pTransform;
N->val.se = sh;
return;
}
// Redotix99: for 3D Shader Based Scopes
if (sh->flags.isScope2)
{
mapHUD_Node* N = mapScopeHUD.insertInAnyWay(distSQ);
N->val.ssa = SSA;
N->val.pObject = RI.val_pObject;
N->val.pVisual = pVisual;
N->val.Matrix = *RI.val_pTransform;
N->val.se = sh;
return;
}
// Redotix99: for 3D Shader Based Scopes
if (sh->flags.isScope3)
{
mapSorted_Node* N = mapScopeHUDSorted.insertInAnyWay(distSQ);
N->val.ssa = SSA;
N->val.pObject = RI.val_pObject;
N->val.pVisual = pVisual;
N->val.Matrix = *RI.val_pTransform;
N->val.se = sh;
return;
switch (sh->flags.iScopeLense) {
case 0:
break;

case 1: {
mapHUD_Node* N = mapHUD.insertInAnyWay(EPS);
N->val.ssa = SSA;
N->val.pObject = RI.val_pObject;
N->val.pVisual = pVisual;
N->val.Matrix = *RI.val_pTransform;
N->val.se = sh;

if (!sh->passes[0]->ps->hud_disabled)
{
HUDMask_Node* N2 = HUDMask.insertInAnyWay(EPS);
N2->val.ssa = SSA;
N2->val.pObject = RI.val_pObject;
N2->val.pVisual = pVisual;
N2->val.Matrix = *RI.val_pTransform;
N2->val.se = sh;
}
return;
}

case 2: {
mapHUD_Node * N = mapScopeHUD.insertInAnyWay(distSQ);
N->val.ssa = SSA;
N->val.pObject = RI.val_pObject;
N->val.pVisual = pVisual;
N->val.Matrix = *RI.val_pTransform;
N->val.se = sh;
return;
}

case 3: {
mapSorted_Node * N = mapScopeHUDSorted.insertInAnyWay(distSQ);
N->val.ssa = SSA;
N->val.pObject = RI.val_pObject;
N->val.pVisual = pVisual;
N->val.Matrix = *RI.val_pTransform;
N->val.se = sh;
return;
}
}

// HUD rendering
Expand Down
16 changes: 9 additions & 7 deletions src/Layers/xrRender/r__dsgraph_render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,20 +600,22 @@ void R_dsgraph_structure::r_dsgraph_render_hud(bool NoPS)
{
mapHUD.traverseLR(sorted_L1);
mapHUD.clear();

rmNormal();

if (scope_3D_fake_enabled)
{
mapScopeHUD.traverseLR(sorted_L1);
}
mapScopeHUD.clear();
}
else
{
HUDMask.traverseLR(hud_node);
HUDMask.clear();
}

rmNormal();

if (scope_3D_fake_enabled)
{
mapScopeHUD.traverseLR(sorted_L1);
rmNormal();
}
mapScopeHUD.clear();

// Restore projection
Device.mProject = Pold;
Expand Down
20 changes: 3 additions & 17 deletions src/Layers/xrRenderDX10/dx10ResourceManager_Scripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,9 @@ class adopt_compiler
}

// Redotix99: for 3D Shader Based Scopes
adopt_compiler& _o_scope(bool E)
adopt_compiler& _o_scopelense(u32 lenseType)
{
C->SH->flags.isScope = E;
return *this;
}

adopt_compiler& _o_scope2(bool E)
{
C->SH->flags.isScope2 = E;
return *this;
}

adopt_compiler& _o_scope3(bool E)
{
C->SH->flags.isScope3 = E;
C->SH->flags.iScopeLense = lenseType;
return *this;
}

Expand Down Expand Up @@ -416,9 +404,7 @@ void CResourceManager::LS_Load()
.def("blend", &adopt_compiler::_blend, return_reference_to(_1))
.def("aref", &adopt_compiler::_aref, return_reference_to(_1))

.def("scope", &adopt_compiler::_o_scope, return_reference_to(_1)) // Redotix99: for 3D Shader Based Scopes
.def("scope2", &adopt_compiler::_o_scope2, return_reference_to(_1))
.def("scope3", &adopt_compiler::_o_scope3, return_reference_to(_1))
.def("scopelense", &adopt_compiler::_o_scopelense, return_reference_to(_1)) // Redotix99: for 3D Shader Based Scopes

// For compatibility only
.def("dx10color_write_enable", &adopt_compiler::_dx10color_write_enable, return_reference_to(_1))
Expand Down