diff --git a/rendering/CommonMaterial.cpp b/rendering/CommonMaterial.cpp index 620674f..f29a517 100644 --- a/rendering/CommonMaterial.cpp +++ b/rendering/CommonMaterial.cpp @@ -1,21 +1,41 @@ #include "CommonMaterial.h" +#include "MaterialData.h" namespace cdc { -void CommonMaterial::method_04() { - // TODO +MaterialBlob *CommonMaterial::GetMaterialData() { + return materialBlob; } -void CommonMaterial::method_0C() { - // TODO +void CommonMaterial::SetRenderPassMask(uint32_t mask, bool fading) { + if (materialBlob->blendStateC & 1) { + if (fading) + m_renderPassesMaskFading = mask; + else + m_renderPassesMask = mask; + } else { + m_renderPassesMaskFading = mask; + m_renderPassesMask = mask; + } } -void CommonMaterial::method_10() { - // TODO +uint32_t CommonMaterial::GetRenderPassMask(bool fading) { + return fading ? m_renderPassesMaskFading : m_renderPassesMask; } void CommonMaterial::method_18() { // TODO } +void CommonMaterial::SetRenderPasses() { // HACK + uint32_t mask; + + if (materialBlob->blendStateC & 1) + mask = 0x0008; // translucent + else + mask = 0x1002; // normals & composite + + m_renderPassesMaskFading = m_renderPassesMask = mask; +} + } diff --git a/rendering/CommonMaterial.h b/rendering/CommonMaterial.h index 5ffe70b..aa961e8 100644 --- a/rendering/CommonMaterial.h +++ b/rendering/CommonMaterial.h @@ -7,16 +7,19 @@ namespace cdc { struct MaterialBlob; class CommonMaterial : public IMaterial { - uint32_t dword4; - uint32_t dword8; + uint32_t m_renderPassesMask; // 4 + uint32_t m_renderPassesMaskFading; // 8 public: MaterialBlob *materialBlob = nullptr; public: - void method_04() override; - void method_0C() override; - void method_10() override; + MaterialBlob *GetMaterialData() override; + void Release() override = 0; + void SetRenderPassMask(uint32_t mask, bool fading) override; + uint32_t GetRenderPassMask(bool fading) override; ~CommonMaterial() = default; virtual void method_18() = 0; + + void SetRenderPasses(); }; } diff --git a/rendering/IMaterial.h b/rendering/IMaterial.h index 7793111..75434a0 100644 --- a/rendering/IMaterial.h +++ b/rendering/IMaterial.h @@ -7,10 +7,10 @@ struct MaterialBlob; class IMaterial { public: virtual void load(MaterialBlob*) = 0; - virtual void method_04() = 0; - virtual void method_08() = 0; - virtual void method_0C() = 0; - virtual void method_10() = 0; + virtual MaterialBlob *GetMaterialData() = 0; + virtual void Release() = 0; + virtual void SetRenderPassMask(uint32_t mask, bool fading) = 0; + virtual uint32_t GetRenderPassMask(bool fading) = 0; virtual ~IMaterial() = default; }; diff --git a/rendering/PCDX11Material.cpp b/rendering/PCDX11Material.cpp index 8fd3215..6412dc6 100644 --- a/rendering/PCDX11Material.cpp +++ b/rendering/PCDX11Material.cpp @@ -25,6 +25,8 @@ void PCDX11Material::load(MaterialBlob *newBlob) { // TODO materialBlob = newBlob; // TODO + SetRenderPasses(); + // TODO for (uint32_t i = 0; i < 16; i++) { MaterialBlobSub *sub = materialBlob->subMat4C[i]; @@ -48,7 +50,7 @@ void PCDX11Material::load(MaterialBlob *newBlob) { } } -void PCDX11Material::method_08() { +void PCDX11Material::Release() { // TODO } diff --git a/rendering/PCDX11Material.h b/rendering/PCDX11Material.h index 1cff2b5..4c957e9 100644 --- a/rendering/PCDX11Material.h +++ b/rendering/PCDX11Material.h @@ -42,7 +42,7 @@ public: {} void load(MaterialBlob *) override; - void method_08() override; + void Release() override; ~PCDX11Material() = default; void method_18() override; diff --git a/rendering/PCDX11RenderModelInstance.cpp b/rendering/PCDX11RenderModelInstance.cpp index e6e5009..0fe34c5 100644 --- a/rendering/PCDX11RenderModelInstance.cpp +++ b/rendering/PCDX11RenderModelInstance.cpp @@ -68,12 +68,8 @@ void PCDX11RenderModelInstance::recordDrawables(IMatrixState *matrixState) { // NonPersistentPGData *tab0ext16 = &this->tab0Ext16[tab0index]; PersistentPGData *tab0ext128 = &this->tab0Ext128[tab0index]; - uint32_t mask = baseMask; // & tab0ext16->mask8; - - if (static_cast(primGroup->material)->materialBlob->blendStateC & 1) - mask &= 0x0008; // translucent - else - mask &= 0x1002; // normals & composite + bool isFading = fade < 1.0f; + uint32_t mask = baseMask & primGroup->material->GetRenderPassMask(isFading); // & tab0ext16->mask8; auto drawable = new (renderDevice->getLinear(), 6, true) PCDX11ModelDrawable( getRenderModel(),