From 1727a337c6d688f5711fc94af874d748a5c10953 Mon Sep 17 00:00:00 2001 From: parax0 Date: Wed, 17 Feb 2016 03:43:15 -0700 Subject: [PATCH] Added support for "white ambient" flag in DKCR to fix black world geometry --- src/Core/Resource/CMaterial.h | 3 ++- src/Core/Resource/Factory/CMaterialLoader.cpp | 5 +++-- src/Core/Resource/Factory/CScriptLoader.h | 2 -- src/Core/Scene/CStaticNode.cpp | 5 +++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Core/Resource/CMaterial.h b/src/Core/Resource/CMaterial.h index 68b1623f..c46b5865 100644 --- a/src/Core/Resource/CMaterial.h +++ b/src/Core/Resource/CMaterial.h @@ -36,7 +36,8 @@ public: eIndStage = 0x400, eLightmap = 0x800, eShortTexCoord = 0x2000, - eAllSettings = 0x2FF8 + eDrawWhiteAmbient = 0x80000, // this flag is possibly incorrect! attempted fix for black world models in DKCR + eAllSettings = 0x82FF8 }; DECLARE_FLAGS(EMaterialOption, FMaterialOptions) diff --git a/src/Core/Resource/Factory/CMaterialLoader.cpp b/src/Core/Resource/Factory/CMaterialLoader.cpp index f7afc084..1076e33d 100644 --- a/src/Core/Resource/Factory/CMaterialLoader.cpp +++ b/src/Core/Resource/Factory/CMaterialLoader.cpp @@ -261,8 +261,9 @@ CMaterial* CMaterialLoader::ReadCorruptionMaterial() pMat->mOptions |= CMaterial::eTransparent; } - if (Flags & 0x10) pMat->mOptions |= CMaterial::ePunchthrough; - if (Flags & 0x100) pMat->mOptions |= CMaterial::eOccluder; + if (Flags & 0x10) pMat->mOptions |= CMaterial::ePunchthrough; + if (Flags & 0x100) pMat->mOptions |= CMaterial::eOccluder; + if (Flags & 0x80000) pMat->mOptions |= CMaterial::eDrawWhiteAmbient; mHas0x400 = ((Flags & 0x400) != 0); mpFile->Seek(0x8, SEEK_CUR); // Don't know what any of this is diff --git a/src/Core/Resource/Factory/CScriptLoader.h b/src/Core/Resource/Factory/CScriptLoader.h index 0946197d..61545c07 100644 --- a/src/Core/Resource/Factory/CScriptLoader.h +++ b/src/Core/Resource/Factory/CScriptLoader.h @@ -26,8 +26,6 @@ class CScriptLoader CScriptObject* LoadObjectMP2(IInputStream& SCLY); CScriptLayer* LoadLayerMP2(IInputStream& SCLY); - void SetupAttribs(); - public: static CScriptLayer* LoadLayer(IInputStream& SCLY, CGameArea *pArea, EGame version); }; diff --git a/src/Core/Scene/CStaticNode.cpp b/src/Core/Scene/CStaticNode.cpp index 581d21f1..22157f35 100644 --- a/src/Core/Scene/CStaticNode.cpp +++ b/src/Core/Scene/CStaticNode.cpp @@ -58,11 +58,12 @@ void CStaticNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewIn if (!mpModel) return; bool IsLightingEnabled = CGraphics::sLightMode == CGraphics::eWorldLighting || ViewInfo.GameMode; + bool UseWhiteAmbient = (mpModel->GetMaterial()->Options() & CMaterial::eDrawWhiteAmbient) != 0; if (IsLightingEnabled) { CGraphics::sNumLights = 0; - CGraphics::sVertexBlock.COLOR0_Amb = CColor::skBlack; + CGraphics::sVertexBlock.COLOR0_Amb = UseWhiteAmbient ? CColor::skWhite : CColor::skBlack; CGraphics::sPixelBlock.LightmapMultiplier = 1.0f; CGraphics::UpdateLightBlock(); } @@ -70,7 +71,7 @@ void CStaticNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewIn else { LoadLights(ViewInfo); - if (CGraphics::sLightMode == CGraphics::eNoLighting) + if (CGraphics::sLightMode == CGraphics::eNoLighting || UseWhiteAmbient) CGraphics::sVertexBlock.COLOR0_Amb = CColor::skWhite; }