Fixes & CArtifactDoll/CSamusDoll updates

This commit is contained in:
Luke Street 2022-03-08 17:21:15 -05:00
parent e88f831950
commit 3fd0b1f23a
14 changed files with 159 additions and 214 deletions

View File

@ -545,18 +545,18 @@ void CAnimData::RenderAuxiliary(const zeus::CFrustum& frustum) const { x120_part
void CAnimData::Render(CSkinnedModel& model, const CModelFlags& drawFlags, void CAnimData::Render(CSkinnedModel& model, const CModelFlags& drawFlags,
const std::optional<CVertexMorphEffect>& morphEffect, const float* morphMagnitudes) { const std::optional<CVertexMorphEffect>& morphEffect, const float* morphMagnitudes) {
SetupRender(model, drawFlags, morphEffect, morphMagnitudes); SetupRender(model, morphEffect, morphMagnitudes);
DrawSkinnedModel(model, drawFlags); DrawSkinnedModel(model, drawFlags);
} }
void CAnimData::SetupRender(CSkinnedModel& model, const CModelFlags& drawFlags, void CAnimData::SetupRender(CSkinnedModel& model, const std::optional<CVertexMorphEffect>& morphEffect,
const std::optional<CVertexMorphEffect>& morphEffect, const float* morphMagnitudes) { const float* morphMagnitudes) {
OPTICK_EVENT(); OPTICK_EVENT();
if (!x220_30_poseBuilt) { if (!x220_30_poseBuilt) {
x2fc_poseBuilder.BuildNoScale(x224_pose); x2fc_poseBuilder.BuildNoScale(x224_pose);
x220_30_poseBuilt = true; x220_30_poseBuilt = true;
} }
PoseSkinnedModel(model, x224_pose, drawFlags, morphEffect, morphMagnitudes); PoseSkinnedModel(model, x224_pose, morphEffect, morphMagnitudes);
} }
void CAnimData::DrawSkinnedModel(CSkinnedModel& model, const CModelFlags& flags) { void CAnimData::DrawSkinnedModel(CSkinnedModel& model, const CModelFlags& flags) {
@ -805,9 +805,9 @@ void CAnimData::SetInfraModel(const TLockedToken<CModel>& model, const TLockedTo
xf8_infraModel = std::make_shared<CSkinnedModel>(model, skinRules, xd8_modelData->GetLayoutInfo()); xf8_infraModel = std::make_shared<CSkinnedModel>(model, skinRules, xd8_modelData->GetLayoutInfo());
} }
void CAnimData::PoseSkinnedModel(CSkinnedModel& model, const CPoseAsTransforms& pose, const CModelFlags& drawFlags, void CAnimData::PoseSkinnedModel(CSkinnedModel& model, const CPoseAsTransforms& pose,
const std::optional<CVertexMorphEffect>& morphEffect, const float* morphMagnitudes) { const std::optional<CVertexMorphEffect>& morphEffect, const float* morphMagnitudes) {
model.Calculate(pose, drawFlags, morphEffect, morphMagnitudes); model.Calculate(pose, morphEffect, morphMagnitudes);
} }
void CAnimData::AdvanceParticles(const zeus::CTransform& xf, float dt, const zeus::CVector3f& vec, void CAnimData::AdvanceParticles(const zeus::CTransform& xf, float dt, const zeus::CVector3f& vec,

View File

@ -196,8 +196,8 @@ public:
void RenderAuxiliary(const zeus::CFrustum& frustum) const; void RenderAuxiliary(const zeus::CFrustum& frustum) const;
void Render(CSkinnedModel& model, const CModelFlags& drawFlags, const std::optional<CVertexMorphEffect>& morphEffect, void Render(CSkinnedModel& model, const CModelFlags& drawFlags, const std::optional<CVertexMorphEffect>& morphEffect,
const float* morphMagnitudes); const float* morphMagnitudes);
void SetupRender(CSkinnedModel& model, const CModelFlags& drawFlags, void SetupRender(CSkinnedModel& model, const std::optional<CVertexMorphEffect>& morphEffect,
const std::optional<CVertexMorphEffect>& morphEffect, const float* morphMagnitudes); const float* morphMagnitudes);
static void DrawSkinnedModel(CSkinnedModel& model, const CModelFlags& flags); static void DrawSkinnedModel(CSkinnedModel& model, const CModelFlags& flags);
void PreRender(); void PreRender();
void BuildPose(); void BuildPose();
@ -218,7 +218,7 @@ public:
TLockedToken<CSkinnedModel>& GetModelData() { return xd8_modelData; } TLockedToken<CSkinnedModel>& GetModelData() { return xd8_modelData; }
const TLockedToken<CSkinnedModel>& GetModelData() const { return xd8_modelData; } const TLockedToken<CSkinnedModel>& GetModelData() const { return xd8_modelData; }
static void PoseSkinnedModel(CSkinnedModel& model, const CPoseAsTransforms& pose, const CModelFlags& drawFlags, static void PoseSkinnedModel(CSkinnedModel& model, const CPoseAsTransforms& pose,
const std::optional<CVertexMorphEffect>& morphEffect, const float* morphMagnitudes); const std::optional<CVertexMorphEffect>& morphEffect, const float* morphMagnitudes);
void AdvanceParticles(const zeus::CTransform& xf, float dt, const zeus::CVector3f&, CStateManager& stateMgr); void AdvanceParticles(const zeus::CTransform& xf, float dt, const zeus::CVector3f&, CStateManager& stateMgr);
float GetAverageVelocity(int animIn) const; float GetAverageVelocity(int animIn) const;

View File

@ -293,7 +293,7 @@ void CModelData::RenderThermal(const zeus::CTransform& xf, const zeus::CColor& m
if (x10_animData) { if (x10_animData) {
CSkinnedModel& model = PickAnimatedModel(EWhichModel::ThermalHot); CSkinnedModel& model = PickAnimatedModel(EWhichModel::ThermalHot);
x10_animData->SetupRender(model, flags, {}, nullptr); x10_animData->SetupRender(model, {}, nullptr);
ThermalDraw(mulColor, addColor, flags); ThermalDraw(mulColor, addColor, flags);
} else { } else {
auto& model = PickStaticModel(EWhichModel::ThermalHot); auto& model = PickStaticModel(EWhichModel::ThermalHot);
@ -360,51 +360,66 @@ void CModelData::Render(EWhichModel which, const zeus::CTransform& xf, const CAc
x14_24_renderSorted = false; x14_24_renderSorted = false;
} }
void CModelData::InvSuitDraw(EWhichModel which, const zeus::CTransform& xf, const CActorLights* lights, void CModelData::MultiLightingDraw(EWhichModel which, const zeus::CTransform& xf, const CActorLights* lights,
const zeus::CColor& alphaColor, const zeus::CColor& additiveColor) { const zeus::CColor& alphaColor, const zeus::CColor& additiveColor) {
CModel* model = nullptr;
const auto callback = [&](auto positions, auto normals) {
CGraphics::DisableAllLights();
constexpr CModelFlags flags1{5, 0, 3, zeus::CColor{1.f, 0.f}};
const CModelFlags flags2{5, 0, 1, alphaColor};
const CModelFlags flags3{7, 0, 1, additiveColor};
if (positions == nullptr) {
model->Draw(flags1);
if (lights != nullptr) {
lights->ActivateLights();
}
model->Draw(flags2);
model->Draw(flags3);
} else {
model->Draw(positions, normals, flags1);
if (lights != nullptr) {
lights->ActivateLights();
}
model->Draw(positions, normals, flags2);
model->Draw(positions, normals, flags3);
}
};
CGraphics::SetModelMatrix(xf * zeus::CTransform::Scale(x0_scale)); CGraphics::SetModelMatrix(xf * zeus::CTransform::Scale(x0_scale));
// TODO where is this method? if (x10_animData) {
// if (x10_animData) { auto& skinnedModel = PickAnimatedModel(which);
// CSkinnedModel& model = PickAnimatedModel(which); x10_animData->SetupRender(skinnedModel, {}, nullptr);
// model.GetModelInst()->DisableAllLights(); model = skinnedModel.GetModel().GetObj();
// CModelFlags flags = {}; skinnedModel.DoDrawCallback(callback);
// } else {
// /* Z-prime */ model = PickStaticModel(which).GetObj();
// flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly; callback(nullptr, nullptr);
// flags.x4_color = zeus::skWhite; }
// x10_animData->Render(model, flags, std::nullopt, nullptr); }
//
// /* Normal Blended */ void CModelData::MultiPassDraw(EWhichModel which, const zeus::CTransform& xf, const CActorLights* lights,
// lights->ActivateLights(*model.GetModelInst()); const CModelFlags* flags, u32 count) {
// flags.m_extendedShader = EExtendedShader::ForcedAlpha; CGraphics::SetModelMatrix(xf * zeus::CTransform::Scale(x0_scale));
// flags.x4_color = alphaColor; if (lights == nullptr) {
// x10_animData->Render(model, flags, std::nullopt, nullptr); CGraphics::DisableAllLights();
// g_Renderer->SetAmbientColor(x18_ambientColor);
// /* Selection Additive */ } else {
// flags.m_extendedShader = EExtendedShader::ForcedAdditive; lights->ActivateLights();
// flags.x4_color = additiveColor; }
// x10_animData->Render(model, flags, std::nullopt, nullptr); if (x10_animData) {
// } else { auto& skinnedModel = PickAnimatedModel(which);
// CBooModel& model = *PickStaticModel(which); x10_animData->SetupRender(skinnedModel, {}, nullptr);
// model.DisableAllLights(); auto& model = *skinnedModel.GetModel();
// CModelFlags flags = {}; skinnedModel.DoDrawCallback([&](auto positions, auto normals) {
// for (int i = 0; i < count; ++i) {
// /* Z-prime */ model.Draw(positions, normals, flags[i]);
// flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly; }
// flags.x4_color = zeus::skWhite; });
// model.Draw(flags, nullptr, nullptr); } else {
// auto& model = *PickStaticModel(which);
// /* Normal Blended */ for (int i = 0; i < count; ++i) {
// lights->ActivateLights(model); model.Draw(flags[i]);
// flags.m_extendedShader = EExtendedShader::ForcedAlpha; }
// flags.x4_color = alphaColor; }
// model.Draw(flags, nullptr, nullptr);
//
// /* Selection Additive */
// flags.m_extendedShader = EExtendedShader::ForcedAdditive;
// flags.x4_color = additiveColor;
// model.Draw(flags, nullptr, nullptr);
// }
} }
void CModelData::DisintegrateDraw(const CStateManager& mgr, const zeus::CTransform& xf, const CTexture& tex, void CModelData::DisintegrateDraw(const CStateManager& mgr, const zeus::CTransform& xf, const CTexture& tex,
@ -442,8 +457,7 @@ void CModelData::DisintegrateDraw(EWhichModel which, const zeus::CTransform& xf,
// model.Draw(flags, nullptr, nullptr); // model.Draw(flags, nullptr, nullptr);
// } // }
} }
void CModelData::ThermalDraw(const zeus::CColor& mulColor, const zeus::CColor& addColor, const CModelFlags& flags) {
} void CModelData::ThermalDraw(const zeus::CColor& mulColor, const zeus::CColor& addColor, const CModelFlags& flags) {}
} // namespace metaforce } // namespace metaforce

View File

@ -122,8 +122,10 @@ public:
const CModelFlags& drawFlags); const CModelFlags& drawFlags);
void Render(EWhichModel, const zeus::CTransform& xf, const CActorLights* lights, const CModelFlags& drawFlags); void Render(EWhichModel, const zeus::CTransform& xf, const CActorLights* lights, const CModelFlags& drawFlags);
void InvSuitDraw(EWhichModel which, const zeus::CTransform& xf, const CActorLights* lights, void MultiLightingDraw(EWhichModel which, const zeus::CTransform& xf, const CActorLights* lights,
const zeus::CColor& color0, const zeus::CColor& color1); const zeus::CColor& alphaColor, const zeus::CColor& additiveColor);
void MultiPassDraw(EWhichModel which, const zeus::CTransform& xf, const CActorLights* lights,
const CModelFlags* flags, u32 count);
void DisintegrateDraw(const CStateManager& mgr, const zeus::CTransform& xf, const CTexture& tex, void DisintegrateDraw(const CStateManager& mgr, const zeus::CTransform& xf, const CTexture& tex,
const zeus::CColor& addColor, float t); const zeus::CColor& addColor, float t);
void DisintegrateDraw(EWhichModel which, const zeus::CTransform& xf, const CTexture& tex, void DisintegrateDraw(EWhichModel which, const zeus::CTransform& xf, const CTexture& tex,

View File

@ -65,7 +65,7 @@ CCubeMaterial CCubeModel::GetMaterialByIndex(u32 idx) {
bool CCubeModel::TryLockTextures() { bool CCubeModel::TryLockTextures() {
if (!x40_24_texturesLoaded) { if (!x40_24_texturesLoaded) {
bool texturesPumped = false; bool texturesLoading = false;
for (auto& texture : *x1c_textures) { for (auto& texture : *x1c_textures) {
texture.Lock(); texture.Lock();
bool loadTexture = true; bool loadTexture = true;
@ -77,11 +77,12 @@ bool CCubeModel::TryLockTextures() {
} }
} }
if (loadTexture) { if (loadTexture) {
// texture->LoadToMRAM(); // if (!texture->LoadToMRAM()) {
// texturesPumped = true; // texturesLoading = true;
// }
} }
} }
if (!texturesPumped) { if (!texturesLoading) {
x40_24_texturesLoaded = true; x40_24_texturesLoaded = true;
} }
} }

View File

@ -366,7 +366,7 @@ void CCubeRenderer::DrawStaticGeometry(s32 areaIdx, s32 mask, s32 targetMask) {
void CCubeRenderer::DrawAreaGeometry(s32 areaIdx, s32 mask, s32 targetMask) { void CCubeRenderer::DrawAreaGeometry(s32 areaIdx, s32 mask, s32 targetMask) {
x318_30_inAreaDraw = true; x318_30_inAreaDraw = true;
SetupRendererStates(true); SetupRendererStates(true);
CModelFlags flags; constexpr CModelFlags flags{0, 0, 3, zeus::skWhite};
for (CAreaListItem& item : x1c_areaListItems) { for (CAreaListItem& item : x1c_areaListItems) {
if (areaIdx != -1 || item.x18_areaIdx == areaIdx) { if (areaIdx != -1 || item.x18_areaIdx == areaIdx) {
@ -391,10 +391,10 @@ void CCubeRenderer::DrawAreaGeometry(s32 areaIdx, s32 mask, s32 targetMask) {
} }
for (const auto* surf = model->GetFirstUnsortedSurface(); surf != nullptr; surf = surf->GetNextSurface()) { for (const auto* surf = model->GetFirstUnsortedSurface(); surf != nullptr; surf = surf->GetNextSurface()) {
model->DrawSurface(*surf, CModelFlags(0, 0, 3, zeus::skWhite)); model->DrawSurface(*surf, flags);
} }
for (const auto* surf = model->GetFirstSortedSurface(); surf != nullptr; surf = surf->GetNextSurface()) { for (const auto* surf = model->GetFirstSortedSurface(); surf != nullptr; surf = surf->GetNextSurface()) {
model->DrawSurface(*surf, CModelFlags(0, 0, 3, zeus::skWhite)); model->DrawSurface(*surf, flags);
} }
} }
} }
@ -654,9 +654,14 @@ void CCubeRenderer::SetWorldLightFadeLevel(float level) { x2fc_tevReg1Color = ze
void CCubeRenderer::PrepareDynamicLights(const std::vector<CLight>& lights) {} void CCubeRenderer::PrepareDynamicLights(const std::vector<CLight>& lights) {}
void CCubeRenderer::AllocatePhazonSuitMaskTexture() {} void CCubeRenderer::AllocatePhazonSuitMaskTexture() {}
void CCubeRenderer::DrawPhazonSuitIndirectEffect(const zeus::CColor& nonIndirectMod, void CCubeRenderer::DrawPhazonSuitIndirectEffect(const zeus::CColor& nonIndirectMod,
const TLockedToken<CTexture>& indTex, const zeus::CColor& indirectMod, const TLockedToken<CTexture>& indTex, const zeus::CColor& indirectMod,
float blurRadius, float scale, float offX, float offY) {} float blurRadius, float scale, float offX, float offY) {
// TODO
aurora::gfx::set_dst_alpha(false, 0.f);
}
void CCubeRenderer::DrawXRayOutline(const zeus::CAABox& aabb) {} void CCubeRenderer::DrawXRayOutline(const zeus::CAABox& aabb) {}
std::list<CCubeRenderer::CAreaListItem>::iterator std::list<CCubeRenderer::CAreaListItem>::iterator

View File

@ -26,8 +26,8 @@ CSkinnedModel::CSkinnedModel(IObjectStore& store, CAssetId model, CAssetId skinR
: CSkinnedModel(store.GetObj(SObjectTag{FOURCC('CMDL'), model}), store.GetObj(SObjectTag{FOURCC('CSKR'), skinRules}), : CSkinnedModel(store.GetObj(SObjectTag{FOURCC('CMDL'), model}), store.GetObj(SObjectTag{FOURCC('CSKR'), skinRules}),
store.GetObj(SObjectTag{FOURCC('CINF'), layoutInfo})) {} store.GetObj(SObjectTag{FOURCC('CINF'), layoutInfo})) {}
void CSkinnedModel::Calculate(const CPoseAsTransforms& pose, const CModelFlags& drawFlags, void CSkinnedModel::Calculate(const CPoseAsTransforms& pose, const std::optional<CVertexMorphEffect>& morphEffect,
const std::optional<CVertexMorphEffect>& morphEffect, const float* morphMagnitudes) { const float* morphMagnitudes) {
// TODO // TODO
// if (morphEffect || g_PointGenFunc) { // if (morphEffect || g_PointGenFunc) {
// if (boo::ObjToken<boo::IGraphicsBufferD> vertBuf = m_modelInst->UpdateUniformData(drawFlags, nullptr, nullptr)) // if (boo::ObjToken<boo::IGraphicsBufferD> vertBuf = m_modelInst->UpdateUniformData(drawFlags, nullptr, nullptr))

View File

@ -42,8 +42,8 @@ public:
void SetLayoutInfo(const TLockedToken<CCharLayoutInfo>& inf) { x1c_layoutInfo = inf; } void SetLayoutInfo(const TLockedToken<CCharLayoutInfo>& inf) { x1c_layoutInfo = inf; }
const TLockedToken<CCharLayoutInfo>& GetLayoutInfo() const { return x1c_layoutInfo; } const TLockedToken<CCharLayoutInfo>& GetLayoutInfo() const { return x1c_layoutInfo; }
void Calculate(const CPoseAsTransforms& pose, const CModelFlags& drawFlags, void Calculate(const CPoseAsTransforms& pose, const std::optional<CVertexMorphEffect>& morphEffect,
const std::optional<CVertexMorphEffect>& morphEffect, const float* morphMagnitudes); const float* morphMagnitudes);
void Draw(TVectorRef verts, TVectorRef normals, const CModelFlags& drawFlags); void Draw(TVectorRef verts, TVectorRef normals, const CModelFlags& drawFlags);
void Draw(const CModelFlags& drawFlags); void Draw(const CModelFlags& drawFlags);
void DoDrawCallback(const FCustomDraw& func) const; void DoDrawCallback(const FCustomDraw& func) const;

View File

@ -126,13 +126,13 @@ void CArtifactDoll::Draw(float alpha, const CStateManager& mgr, bool inArtifactC
CModelFlags flags(7, 0, 3, zeus::CColor(1.f, 0.f)); CModelFlags flags(7, 0, 3, zeus::CColor(1.f, 0.f));
// flags.m_extendedShader = EExtendedShader::SolidColorFrontfaceCullLEqualAlphaOnly; // flags.m_extendedShader = EExtendedShader::SolidColorFrontfaceCullLEqualAlphaOnly;
// x20_actorLights->ActivateLights(model->GetInstance()); x20_actorLights->ActivateLights();
model->Draw(flags); model->Draw(flags);
flags.x4_color = color; flags.x4_color = color;
flags.x4_color.a() *= alpha; flags.x4_color.a() *= alpha;
// flags.m_extendedShader = EExtendedShader::ForcedAdditive; // flags.m_extendedShader = EExtendedShader::ForcedAdditive;
model->Draw(flags); model->Draw({8, 0, 1, flags.x4_color});
} }
} }

View File

@ -331,38 +331,29 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha) {
float bootsPulse = std::max(suitPulse, itemPulse * x64_bootsPulseFactor); float bootsPulse = std::max(suitPulse, itemPulse * x64_bootsPulseFactor);
bool phazonSuit = x44_suit == CPlayerState::EPlayerSuit::Phazon; bool phazonSuit = x44_suit == CPlayerState::EPlayerSuit::Phazon;
// Enable dst alpha 1.0 if (phazonSuit) {
aurora::gfx::set_dst_alpha(true, 1.f);
}
for (size_t i = 0; i <= x118_suitModel1and2.size(); ++i) { for (size_t i = 0; i <= x118_suitModel1and2.size(); ++i) {
TCachedToken<CSkinnedModel> backupModelData = xc8_suitModel0->GetAnimationData()->GetModelData(); TCachedToken<CSkinnedModel> backupModelData = xc8_suitModel0->GetAnimationData()->GetModelData();
if (i < x118_suitModel1and2.size()) if (i < x118_suitModel1and2.size())
xc8_suitModel0->GetAnimationData()->SubstituteModelData(x118_suitModel1and2[i]); xc8_suitModel0->GetAnimationData()->SubstituteModelData(x118_suitModel1and2[i]);
xc8_suitModel0->InvSuitDraw(CModelData::EWhichModel::Normal, zeus::CTransform(), x24c_actorLights.get(), xc8_suitModel0->MultiLightingDraw(CModelData::EWhichModel::Normal, zeus::CTransform(), x24c_actorLights.get(),
zeus::CColor(1.f, alpha), zeus::CColor(1.f, alpha * suitPulse)); zeus::CColor(1.f, alpha), zeus::CColor(1.f, alpha * suitPulse));
xc8_suitModel0->GetAnimationData()->SubstituteModelData(backupModelData); xc8_suitModel0->GetAnimationData()->SubstituteModelData(backupModelData);
} }
x134_suitModelBoots->InvSuitDraw(CModelData::EWhichModel::Normal, zeus::CTransform(), x24c_actorLights.get(), x134_suitModelBoots->MultiLightingDraw(CModelData::EWhichModel::Normal, zeus::CTransform(), x24c_actorLights.get(),
zeus::CColor(1.f, alpha), zeus::CColor(1.f, alpha * bootsPulse)); zeus::CColor(1.f, alpha), zeus::CColor(1.f, alpha * bootsPulse));
{ {
CGraphics::LoadLight(0, x23c_lights[0]);
CGraphics::EnableLight(0);
CGraphics::SetAmbientColor(zeus::skClear);
CGraphics::SetModelMatrix(gunXf); CGraphics::SetModelMatrix(gunXf);
// TODO x1f4_invBeam->Draw({5, 0, 3, zeus::CColor{1.f, alpha}});
// CGraphics::LoadLight(ERglLight::Zero, x248_); x1f4_invBeam->Draw({7, 0, 1, zeus::CColor(1.f, alpha * itemPulse * x5c_beamPulseFactor)});
// old: x1f4_invBeam->GetInstance().ActivateLights(x23c_lights);
CModelFlags flags = {};
// flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
flags.x4_color = zeus::skWhite;
x1f4_invBeam->Draw(flags);
// flags.m_extendedShader = EExtendedShader::ForcedAlpha;
flags.x4_color = zeus::CColor(1.f, alpha);
x1f4_invBeam->Draw(flags);
// flags.m_extendedShader = EExtendedShader::ForcedAdditive;
flags.x4_color = zeus::CColor(1.f, alpha * itemPulse * x5c_beamPulseFactor);
x1f4_invBeam->Draw(flags);
} }
{ {
@ -372,42 +363,21 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha) {
float alphaBlend = (visorT < 0.25f) ? 1.f - 2.f * visorT : (visorT < 0.5f) ? 2.f * (visorT - 0.25f) + 0.5f : 1.f; float alphaBlend = (visorT < 0.25f) ? 1.f - 2.f * visorT : (visorT < 0.5f) ? 2.f * (visorT - 0.25f) + 0.5f : 1.f;
float addBlend = (visorT > 0.75f) ? 1.f - 4.f * (visorT - 0.75f) : (visorT > 0.5f) ? 4.f * (visorT - 0.5f) : 0.f; float addBlend = (visorT > 0.75f) ? 1.f - 4.f * (visorT - 0.75f) : (visorT > 0.5f) ? 4.f * (visorT - 0.5f) : 0.f;
// x200_invVisor->GetInstance().ActivateLights(x23c_lights); const auto c1 =
CModelFlags flags = {}; zeus::CColor::lerp(zeus::CColor{1.f, alpha}, zeus::CColor{alphaBlend, alpha}, x68_visorPulseFactor);
// flags.m_extendedShader = EExtendedShader::Lighting; x200_invVisor->Draw({5, 0, 3, c1});
flags.x4_color = const zeus::CColor c2{1.f, alpha * addBlend * x68_visorPulseFactor};
zeus::CColor::lerp(zeus::CColor(1.f, alpha), zeus::CColor(alphaBlend, alpha), x68_visorPulseFactor); x200_invVisor->Draw({7, 0, 1, c2});
x200_invVisor->Draw(flags);
// flags.m_extendedShader = EExtendedShader::ForcedAdditive;
flags.x4_color = zeus::CColor(1.f, alpha * addBlend * x68_visorPulseFactor);
x200_invVisor->Draw(flags);
} }
if (x270_25_hasGrappleBeam) { if (x270_25_hasGrappleBeam) {
CGraphics::SetModelMatrix(grappleXf); CGraphics::SetModelMatrix(grappleXf);
x20c_invGrappleBeam->Draw({5, 0, 3, zeus::CColor(1.f, alpha)});
// x20c_invGrappleBeam->GetInstance().ActivateLights(x23c_lights); x20c_invGrappleBeam->Draw({7, 0, 1, zeus::CColor(1.f, alpha * itemPulse * x60_grapplePulseFactor)});
CModelFlags flags = {};
// flags.m_extendedShader = EExtendedShader::ForcedAlpha;
flags.x4_color = zeus::CColor(1.f, alpha);
x20c_invGrappleBeam->Draw(flags);
// flags.m_extendedShader = EExtendedShader::ForcedAdditive;
flags.x4_color = zeus::CColor(1.f, alpha * itemPulse * x60_grapplePulseFactor);
x20c_invGrappleBeam->Draw(flags);
} else if (x44_suit >= CPlayerState::EPlayerSuit::FusionPower) { } else if (x44_suit >= CPlayerState::EPlayerSuit::FusionPower) {
CGraphics::SetModelMatrix(grappleXf); CGraphics::SetModelMatrix(grappleXf);
x218_invFins->Draw({5, 0, 3, zeus::CColor(1.f, alpha)});
// x218_invFins->GetInstance().ActivateLights(x23c_lights); x218_invFins->Draw({7, 0, 1, zeus::CColor(1.f, alpha * suitPulse)});
CModelFlags flags = {};
// flags.m_extendedShader = EExtendedShader::ForcedAlpha;
flags.x4_color = zeus::CColor(1.f, alpha);
x218_invFins->Draw(flags);
// flags.m_extendedShader = EExtendedShader::ForcedAdditive;
flags.x4_color = zeus::CColor(1.f, alpha * suitPulse);
x218_invFins->Draw(flags);
} }
if (x54_remTransitionTime > 0.f) { if (x54_remTransitionTime > 0.f) {
@ -419,22 +389,18 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha) {
else if (x4c_completedMorphball) else if (x4c_completedMorphball)
ballAlpha = std::max(0.f, (x54_remTransitionTime - (x50_totalTransitionTime - 0.25f)) / 0.25f); ballAlpha = std::max(0.f, (x54_remTransitionTime - (x50_totalTransitionTime - 0.25f)) / 0.25f);
const auto ballMatIdx = static_cast<u8>(x1e0_ballMatIdx);
const float combinedBallAlpha = alpha * ballAlpha;
if (ballAlpha > 0.f) { if (ballAlpha > 0.f) {
CModelFlags flags = {}; const std::array flags{
flags.x1_matSetIdx = x1e0_ballMatIdx; CModelFlags{5, ballMatIdx, 3, zeus::CColor{1.f, 0.f}},
// flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly; CModelFlags{5, ballMatIdx, 3, zeus::CColor{1.f, combinedBallAlpha}},
flags.x4_color = zeus::skWhite; };
x184_ballModelData->Render(mgr, x10_ballXf, x24c_actorLights.get(), flags); x184_ballModelData->MultiPassDraw(CModelData::EWhichModel::Normal, x10_ballXf, x24c_actorLights.get(),
flags.data(), flags.size());
// flags.m_extendedShader = EExtendedShader::ForcedAlpha; x184_ballModelData->Render(
flags.x4_color = zeus::skWhite; mgr, x10_ballXf, x24c_actorLights.get(),
flags.x4_color.a() = alpha * ballAlpha; CModelFlags{7, ballMatIdx, 3, zeus::CColor{1.f, x6c_ballPulseFactor * combinedBallAlpha * itemPulse}});
x184_ballModelData->Render(mgr, x10_ballXf, x24c_actorLights.get(), flags);
// flags.m_extendedShader = EExtendedShader::ForcedAdditive;
flags.x4_color = zeus::skWhite;
flags.x4_color.a() = x6c_ballPulseFactor * alpha * ballAlpha * itemPulse;
x184_ballModelData->Render(mgr, x10_ballXf, x24c_actorLights.get(), flags);
} }
if (x4d_selectedMorphball && ballT > 0.5f) { if (x4d_selectedMorphball && ballT > 0.5f) {
@ -455,35 +421,20 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha) {
zeus::CRelAngle spinAngle = zeus::degToRad(360.f * oneMinusBallEndT); zeus::CRelAngle spinAngle = zeus::degToRad(360.f * oneMinusBallEndT);
spinAlpha *= 0.5f; spinAlpha *= 0.5f;
if (spinAlpha > 0.f) { if (spinAlpha > 0.f) {
CModelFlags flags = {}; const CModelFlags flags{7, ballMatIdx, 1, zeus::CColor{1.f, spinAlpha * alpha}};
// flags.m_extendedShader = EExtendedShader::ForcedAdditive;
flags.x1_matSetIdx = x1e0_ballMatIdx;
flags.x4_color = zeus::CColor(1.f, spinAlpha * alpha);
x184_ballModelData->Render( x184_ballModelData->Render(
mgr, x10_ballXf * zeus::CTransform::RotateZ(spinAngle) * zeus::CTransform::Scale(spinScale), mgr, x10_ballXf * zeus::CTransform::RotateZ(spinAngle) * zeus::CTransform::Scale(spinScale),
x24c_actorLights.get(), flags); x24c_actorLights.get(), flags);
} }
} }
if (x270_24_hasSpiderBall) { if (x270_24_hasSpiderBall && ballAlpha > 0.f) {
CGraphics::SetModelMatrix(x10_ballXf); CGraphics::SetModelMatrix(x10_ballXf);
CModelFlags flags = {}; const auto glassMatIdx = static_cast<u8>(x1e4_glassMatIdx);
flags.x1_matSetIdx = x1e4_glassMatIdx; x1d4_spiderBallGlass->Draw({5, glassMatIdx, 3, zeus::CColor{1.f, 0.f}});
// x1d4_spiderBallGlass->GetInstance().ActivateLights(x23c_lights); x1d4_spiderBallGlass->Draw({5, glassMatIdx, 3, zeus::CColor{1.f, combinedBallAlpha}});
x1d4_spiderBallGlass->Draw(
// flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly; {7, glassMatIdx, 3, zeus::CColor{1.f, x6c_ballPulseFactor * itemPulse * combinedBallAlpha}});
flags.x4_color = zeus::skWhite;
x1d4_spiderBallGlass->Draw(flags);
// flags.m_extendedShader = EExtendedShader::ForcedAlpha;
flags.x4_color = zeus::skWhite;
flags.x4_color.a() = alpha;
x1d4_spiderBallGlass->Draw(flags);
// flags.m_extendedShader = EExtendedShader::ForcedAdditive;
flags.x4_color = zeus::skWhite;
flags.x4_color.a() = x6c_ballPulseFactor * alpha * itemPulse;
x1d4_spiderBallGlass->Draw(flags);
} }
} }
@ -496,21 +447,16 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha) {
0.1f, offset, offset); 0.1f, offset, offset);
} }
} else { } else {
CModelFlags flags = {}; const auto ballMatIdx = static_cast<u8>(x1e0_ballMatIdx);
flags.x1_matSetIdx = x1e0_ballMatIdx; const std::array flags{
// flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly; CModelFlags{5, ballMatIdx, 3, zeus::CColor{1.f, 0.f}},
flags.x4_color = zeus::skWhite; CModelFlags{5, ballMatIdx, 3, zeus::CColor{1.f, alpha}},
x184_ballModelData->Render(mgr, x10_ballXf, x24c_actorLights.get(), flags); };
x184_ballModelData->MultiPassDraw(CModelData::EWhichModel::Normal, x10_ballXf, x24c_actorLights.get(), flags.data(),
// flags.m_extendedShader = EExtendedShader::ForcedAlpha; flags.size());
flags.x4_color = zeus::skWhite; x184_ballModelData->Render(
flags.x4_color.a() = alpha; mgr, x10_ballXf, nullptr,
x184_ballModelData->Render(mgr, x10_ballXf, x24c_actorLights.get(), flags); CModelFlags{7, ballMatIdx, 3, zeus::CColor{1.f, x6c_ballPulseFactor * alpha * itemPulse}});
// flags.m_extendedShader = EExtendedShader::ForcedAdditive;
flags.x4_color = zeus::skWhite;
flags.x4_color.a() = x6c_ballPulseFactor * alpha * itemPulse;
x184_ballModelData->Render(mgr, x10_ballXf, x24c_actorLights.get(), flags);
const CMorphBall::ColorArray ballGlowColorData = CMorphBall::BallGlowColors[x1e8_ballGlowColorIdx]; const CMorphBall::ColorArray ballGlowColorData = CMorphBall::BallGlowColors[x1e8_ballGlowColorIdx];
const zeus::CColor ballGlowColor{ const zeus::CColor ballGlowColor{
@ -547,24 +493,11 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha) {
} }
if (x270_24_hasSpiderBall) { if (x270_24_hasSpiderBall) {
const auto glassMatIdx = static_cast<u8>(x1e4_glassMatIdx);
CGraphics::SetModelMatrix(x10_ballXf); CGraphics::SetModelMatrix(x10_ballXf);
CModelFlags spiderBallGlassFlags = {}; x1d4_spiderBallGlass->Draw({5, 0, 3, zeus::CColor{1.f, 0.f}});
spiderBallGlassFlags.x1_matSetIdx = x1e4_glassMatIdx; x1d4_spiderBallGlass->Draw({5, glassMatIdx, 3, zeus::CColor{1.f, alpha}});
// x1d4_spiderBallGlass->GetInstance().ActivateLights(x23c_lights); x1d4_spiderBallGlass->Draw({7, glassMatIdx, 3, zeus::CColor{1.f, x6c_ballPulseFactor * alpha * itemPulse}});
// spiderBallGlassFlags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
spiderBallGlassFlags.x4_color = zeus::skWhite;
x1d4_spiderBallGlass->Draw(spiderBallGlassFlags);
// spiderBallGlassFlags.m_extendedShader = EExtendedShader::ForcedAlpha;
spiderBallGlassFlags.x4_color = zeus::skWhite;
spiderBallGlassFlags.x4_color.a() = alpha;
x1d4_spiderBallGlass->Draw(spiderBallGlassFlags);
// spiderBallGlassFlags.m_extendedShader = EExtendedShader::ForcedAdditive;
spiderBallGlassFlags.x4_color = zeus::skWhite;
spiderBallGlassFlags.x4_color.a() = x6c_ballPulseFactor * alpha * itemPulse;
x1d4_spiderBallGlass->Draw(spiderBallGlassFlags);
} }
} }

View File

@ -128,9 +128,8 @@ std::optional<zeus::CAABox> CGrenadeLauncher::GetTouchBounds() const {
void CGrenadeLauncher::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) { void CGrenadeLauncher::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) {
if (x3f4_damageAddColor.a() == 1.f) { if (x3f4_damageAddColor.a() == 1.f) {
xb4_drawFlags = CModelFlags{2, 0, 3, zeus::skWhite};
// Original code redundantly sets a() = 1.f // Original code redundantly sets a() = 1.f
// TODO xb4_drawFlags.addColor = x3f4_damageAddColor; xb4_drawFlags = CModelFlags{2, 0, 3, x3f4_damageAddColor};
} else { } else {
xb4_drawFlags = CModelFlags{5, 0, 3, x3f4_damageAddColor}; xb4_drawFlags = CModelFlags{5, 0, 3, x3f4_damageAddColor};
} }

View File

@ -398,38 +398,29 @@ void CScriptPlayerActor::AddToRenderer(const zeus::CFrustum& frustum, CStateMana
} }
void CScriptPlayerActor::Render(CStateManager& mgr) { void CScriptPlayerActor::Render(CStateManager& mgr) {
// CBooModel::SetReflectionCube(m_reflectionCube);
const bool phazonSuit = x2e8_suitRes.GetCharacterNodeId() == 3; const bool phazonSuit = x2e8_suitRes.GetCharacterNodeId() == 3;
if (phazonSuit) { if (phazonSuit) {
// Draw into alpha buffer aurora::gfx::set_dst_alpha(true, 1.f);
CModelFlags flags = xb4_drawFlags;
flags.x4_color = zeus::skWhite;
// flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
CModelData::EWhichModel which = CModelData::GetRenderingModel(mgr);
x64_modelData->Render(which, x34_transform, x90_actorLights.get(), flags);
} }
CPhysicsActor::Render(mgr); CPhysicsActor::Render(mgr);
if (x314_beamModelData && !x314_beamModelData->IsNull() && x64_modelData && !x64_modelData->IsNull()) { if (x314_beamModelData && !x314_beamModelData->IsNull() && x64_modelData && !x64_modelData->IsNull()) {
zeus::CTransform modelXf = GetTransform() * x64_modelData->GetScaledLocatorTransform("GUN_LCTR"); const auto modelXf = GetTransform() * x64_modelData->GetScaledLocatorTransform("GUN_LCTR");
CModelFlags flags(5, 0, 3, zeus::skWhite); const CModelFlags flags{5, 0, 3, zeus::CColor{1.f, xb4_drawFlags.x4_color.a()}};
// flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
x314_beamModelData->Render(mgr, modelXf, x90_actorLights.get(), flags);
// flags.m_extendedShader = EExtendedShader::LightingCubeReflection;
flags.x4_color = zeus::CColor{1.f, xb4_drawFlags.x4_color.a()};
x314_beamModelData->Render(mgr, modelXf, x90_actorLights.get(), flags); x314_beamModelData->Render(mgr, modelXf, x90_actorLights.get(), flags);
} }
if (phazonSuit) { if (phazonSuit) {
// TODO
// CCubeRenderer::CopyTex
zeus::CVector3f vecFromCam = zeus::CVector3f vecFromCam =
GetBoundingBox().center() - mgr.GetCameraManager()->GetCurrentCamera(mgr)->GetTranslation(); GetBoundingBox().center() - mgr.GetCameraManager()->GetCurrentCamera(mgr)->GetTranslation();
const float radius = zeus::clamp(0.25f, (6.f - vecFromCam.magnitude()) / 6.f, 2.f); const float radius = zeus::clamp(0.25f, (6.f - vecFromCam.magnitude()) / 6.f, 2.f);
const float offsetX = std::sin(x34c_phazonOffsetAngle); const float offsetX = std::sin(x34c_phazonOffsetAngle);
const float offsetY = std::sin(x34c_phazonOffsetAngle) * 0.5f; const float offsetY = std::sin(x34c_phazonOffsetAngle) * 0.5f;
// g_Renderer->DrawPhazonSuitIndirectEffect(zeus::CColor(0.1f, 1.f), x338_phazonIndirectTexture, zeus::skWhite, g_Renderer->DrawPhazonSuitIndirectEffect(zeus::CColor(0.1f, 1.f), x338_phazonIndirectTexture, zeus::skWhite, radius,
// radius, 0.05f, offsetX, offsetY); 0.05f, offsetX, offsetY);
} }
} }

View File

@ -413,15 +413,15 @@ void CSnakeWeedSwarm::RenderBoid(u32 idx, const CBoid& boid, u32& posesToBuild)
auto& modelData = *x1b0_modelData[modelIdx]; auto& modelData = *x1b0_modelData[modelIdx];
auto& model = modelData.PickAnimatedModel(x1c4_which); auto& model = modelData.PickAnimatedModel(x1c4_which);
auto& animData = *modelData.GetAnimationData(); auto& animData = *modelData.GetAnimationData();
constexpr CModelFlags useFlags(0, 0, 3, zeus::skWhite);
if (posesToBuild & 1 << modelIdx) { if (posesToBuild & 1 << modelIdx) {
posesToBuild &= ~(1 << modelIdx); posesToBuild &= ~(1 << modelIdx);
animData.BuildPose(); animData.BuildPose();
model.Calculate(animData.GetPose(), useFlags, std::nullopt, nullptr); model.Calculate(animData.GetPose(), std::nullopt, nullptr);
} }
CGraphics::SetModelMatrix( CGraphics::SetModelMatrix(
zeus::CTransform::Translate(boid.GetPosition() - zeus::CVector3f(0.f, 0.f, boid.GetZOffset())) * zeus::CTransform::Translate(boid.GetPosition() - zeus::CVector3f(0.f, 0.f, boid.GetZOffset())) *
zeus::CTransform::Scale(boid.GetScale())); zeus::CTransform::Scale(boid.GetScale()));
constexpr CModelFlags useFlags{0, 0, 3, zeus::skWhite};
animData.Render(model, useFlags, std::nullopt, nullptr); animData.Render(model, useFlags, std::nullopt, nullptr);
} }

View File

@ -541,6 +541,7 @@ var<storage, read> v_packed_uvs: Vec2Block;
info.uniformSize += 32; info.uniformSize += 32;
vtxOutAttrs += fmt::format(FMT_STRING("\n @location({}) cc{}: vec4<f32>;"), locIdx++, i); vtxOutAttrs += fmt::format(FMT_STRING("\n @location({}) cc{}: vec4<f32>;"), locIdx++, i);
// TODO only perform lighting on CC0 when enabled
vtxXfrAttrs += fmt::format(FMT_STRING(R"""( vtxXfrAttrs += fmt::format(FMT_STRING(R"""(
{{ {{
var lighting = ubuf.lighting_ambient + ubuf.cc{0}_amb; var lighting = ubuf.lighting_ambient + ubuf.cc{0}_amb;
@ -561,8 +562,7 @@ var<storage, read> v_packed_uvs: Vec2Block;
lighting = lighting + vec4<f32>(this_color, 0.0); lighting = lighting + vec4<f32>(this_color, 0.0);
}} }}
out.cc{0} = clamp(lighting, vec4<f32>(0.0), vec4<f32>(1.0)); out.cc{0} = clamp(lighting, vec4<f32>(0.0), vec4<f32>(1.0));
}} }})"""), i, MaxLights);
)"""), i, MaxLights);
if (config.channelMatSrcs[i] == GX::SRC_VTX) { if (config.channelMatSrcs[i] == GX::SRC_VTX) {
if (config.denormalizedVertexAttributes) { if (config.denormalizedVertexAttributes) {