get renderpass mask from material

This commit is contained in:
Adam Jensen 2022-11-07 17:58:22 +00:00
parent 603640a7f2
commit 0c10c75b6e
6 changed files with 44 additions and 23 deletions

View File

@ -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;
}
}

View File

@ -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();
};
}

View File

@ -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;
};

View File

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

View File

@ -42,7 +42,7 @@ public:
{}
void load(MaterialBlob *) override;
void method_08() override;
void Release() override;
~PCDX11Material() = default;
void method_18() override;

View File

@ -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<CommonMaterial*>(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(),