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,
const std::optional<CVertexMorphEffect>& morphEffect, const float* morphMagnitudes) {
SetupRender(model, drawFlags, morphEffect, morphMagnitudes);
SetupRender(model, morphEffect, morphMagnitudes);
DrawSkinnedModel(model, drawFlags);
}
void CAnimData::SetupRender(CSkinnedModel& model, const CModelFlags& drawFlags,
const std::optional<CVertexMorphEffect>& morphEffect, const float* morphMagnitudes) {
void CAnimData::SetupRender(CSkinnedModel& model, const std::optional<CVertexMorphEffect>& morphEffect,
const float* morphMagnitudes) {
OPTICK_EVENT();
if (!x220_30_poseBuilt) {
x2fc_poseBuilder.BuildNoScale(x224_pose);
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) {
@ -805,9 +805,9 @@ void CAnimData::SetInfraModel(const TLockedToken<CModel>& model, const TLockedTo
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) {
model.Calculate(pose, drawFlags, morphEffect, morphMagnitudes);
model.Calculate(pose, morphEffect, morphMagnitudes);
}
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 Render(CSkinnedModel& model, const CModelFlags& drawFlags, const std::optional<CVertexMorphEffect>& morphEffect,
const float* morphMagnitudes);
void SetupRender(CSkinnedModel& model, const CModelFlags& drawFlags,
const std::optional<CVertexMorphEffect>& morphEffect, const float* morphMagnitudes);
void SetupRender(CSkinnedModel& model, const std::optional<CVertexMorphEffect>& morphEffect,
const float* morphMagnitudes);
static void DrawSkinnedModel(CSkinnedModel& model, const CModelFlags& flags);
void PreRender();
void BuildPose();
@ -218,7 +218,7 @@ public:
TLockedToken<CSkinnedModel>& GetModelData() { 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);
void AdvanceParticles(const zeus::CTransform& xf, float dt, const zeus::CVector3f&, CStateManager& stateMgr);
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) {
CSkinnedModel& model = PickAnimatedModel(EWhichModel::ThermalHot);
x10_animData->SetupRender(model, flags, {}, nullptr);
x10_animData->SetupRender(model, {}, nullptr);
ThermalDraw(mulColor, addColor, flags);
} else {
auto& model = PickStaticModel(EWhichModel::ThermalHot);
@ -360,51 +360,66 @@ void CModelData::Render(EWhichModel which, const zeus::CTransform& xf, const CAc
x14_24_renderSorted = false;
}
void CModelData::InvSuitDraw(EWhichModel which, const zeus::CTransform& xf, const CActorLights* lights,
const zeus::CColor& alphaColor, const zeus::CColor& additiveColor) {
void CModelData::MultiLightingDraw(EWhichModel which, const zeus::CTransform& xf, const CActorLights* lights,
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));
// TODO where is this method?
// if (x10_animData) {
// CSkinnedModel& model = PickAnimatedModel(which);
// model.GetModelInst()->DisableAllLights();
// CModelFlags flags = {};
//
// /* Z-prime */
// flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
// flags.x4_color = zeus::skWhite;
// x10_animData->Render(model, flags, std::nullopt, nullptr);
//
// /* Normal Blended */
// lights->ActivateLights(*model.GetModelInst());
// flags.m_extendedShader = EExtendedShader::ForcedAlpha;
// flags.x4_color = alphaColor;
// x10_animData->Render(model, flags, std::nullopt, nullptr);
//
// /* Selection Additive */
// flags.m_extendedShader = EExtendedShader::ForcedAdditive;
// flags.x4_color = additiveColor;
// x10_animData->Render(model, flags, std::nullopt, nullptr);
// } else {
// CBooModel& model = *PickStaticModel(which);
// model.DisableAllLights();
// CModelFlags flags = {};
//
// /* Z-prime */
// flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
// flags.x4_color = zeus::skWhite;
// model.Draw(flags, nullptr, nullptr);
//
// /* Normal Blended */
// lights->ActivateLights(model);
// 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);
// }
if (x10_animData) {
auto& skinnedModel = PickAnimatedModel(which);
x10_animData->SetupRender(skinnedModel, {}, nullptr);
model = skinnedModel.GetModel().GetObj();
skinnedModel.DoDrawCallback(callback);
} else {
model = PickStaticModel(which).GetObj();
callback(nullptr, nullptr);
}
}
void CModelData::MultiPassDraw(EWhichModel which, const zeus::CTransform& xf, const CActorLights* lights,
const CModelFlags* flags, u32 count) {
CGraphics::SetModelMatrix(xf * zeus::CTransform::Scale(x0_scale));
if (lights == nullptr) {
CGraphics::DisableAllLights();
g_Renderer->SetAmbientColor(x18_ambientColor);
} else {
lights->ActivateLights();
}
if (x10_animData) {
auto& skinnedModel = PickAnimatedModel(which);
x10_animData->SetupRender(skinnedModel, {}, nullptr);
auto& model = *skinnedModel.GetModel();
skinnedModel.DoDrawCallback([&](auto positions, auto normals) {
for (int i = 0; i < count; ++i) {
model.Draw(positions, normals, flags[i]);
}
});
} else {
auto& model = *PickStaticModel(which);
for (int i = 0; i < count; ++i) {
model.Draw(flags[i]);
}
}
}
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);
// }
}
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

View File

@ -122,8 +122,10 @@ public:
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,
const zeus::CColor& color0, const zeus::CColor& color1);
void MultiLightingDraw(EWhichModel which, const zeus::CTransform& xf, const CActorLights* lights,
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,
const zeus::CColor& addColor, float t);
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() {
if (!x40_24_texturesLoaded) {
bool texturesPumped = false;
bool texturesLoading = false;
for (auto& texture : *x1c_textures) {
texture.Lock();
bool loadTexture = true;
@ -77,11 +77,12 @@ bool CCubeModel::TryLockTextures() {
}
}
if (loadTexture) {
// texture->LoadToMRAM();
// texturesPumped = true;
// if (!texture->LoadToMRAM()) {
// texturesLoading = true;
// }
}
}
if (!texturesPumped) {
if (!texturesLoading) {
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) {
x318_30_inAreaDraw = true;
SetupRendererStates(true);
CModelFlags flags;
constexpr CModelFlags flags{0, 0, 3, zeus::skWhite};
for (CAreaListItem& item : x1c_areaListItems) {
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()) {
model->DrawSurface(*surf, CModelFlags(0, 0, 3, zeus::skWhite));
model->DrawSurface(*surf, flags);
}
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::AllocatePhazonSuitMaskTexture() {}
void CCubeRenderer::DrawPhazonSuitIndirectEffect(const zeus::CColor& nonIndirectMod,
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) {}
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}),
store.GetObj(SObjectTag{FOURCC('CINF'), layoutInfo})) {}
void CSkinnedModel::Calculate(const CPoseAsTransforms& pose, const CModelFlags& drawFlags,
const std::optional<CVertexMorphEffect>& morphEffect, const float* morphMagnitudes) {
void CSkinnedModel::Calculate(const CPoseAsTransforms& pose, const std::optional<CVertexMorphEffect>& morphEffect,
const float* morphMagnitudes) {
// TODO
// if (morphEffect || g_PointGenFunc) {
// 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; }
const TLockedToken<CCharLayoutInfo>& GetLayoutInfo() const { return x1c_layoutInfo; }
void Calculate(const CPoseAsTransforms& pose, const CModelFlags& drawFlags,
const std::optional<CVertexMorphEffect>& morphEffect, const float* morphMagnitudes);
void Calculate(const CPoseAsTransforms& pose, const std::optional<CVertexMorphEffect>& morphEffect,
const float* morphMagnitudes);
void Draw(TVectorRef verts, TVectorRef normals, const CModelFlags& drawFlags);
void Draw(const CModelFlags& drawFlags);
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));
// flags.m_extendedShader = EExtendedShader::SolidColorFrontfaceCullLEqualAlphaOnly;
// x20_actorLights->ActivateLights(model->GetInstance());
x20_actorLights->ActivateLights();
model->Draw(flags);
flags.x4_color = color;
flags.x4_color.a() *= alpha;
// 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);
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) {
TCachedToken<CSkinnedModel> backupModelData = xc8_suitModel0->GetAnimationData()->GetModelData();
if (i < x118_suitModel1and2.size())
xc8_suitModel0->GetAnimationData()->SubstituteModelData(x118_suitModel1and2[i]);
xc8_suitModel0->InvSuitDraw(CModelData::EWhichModel::Normal, zeus::CTransform(), x24c_actorLights.get(),
zeus::CColor(1.f, alpha), zeus::CColor(1.f, alpha * suitPulse));
xc8_suitModel0->MultiLightingDraw(CModelData::EWhichModel::Normal, zeus::CTransform(), x24c_actorLights.get(),
zeus::CColor(1.f, alpha), zeus::CColor(1.f, alpha * suitPulse));
xc8_suitModel0->GetAnimationData()->SubstituteModelData(backupModelData);
}
x134_suitModelBoots->InvSuitDraw(CModelData::EWhichModel::Normal, zeus::CTransform(), x24c_actorLights.get(),
zeus::CColor(1.f, alpha), zeus::CColor(1.f, alpha * bootsPulse));
x134_suitModelBoots->MultiLightingDraw(CModelData::EWhichModel::Normal, zeus::CTransform(), x24c_actorLights.get(),
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);
// TODO
// CGraphics::LoadLight(ERglLight::Zero, x248_);
// 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);
x1f4_invBeam->Draw({5, 0, 3, zeus::CColor{1.f, alpha}});
x1f4_invBeam->Draw({7, 0, 1, zeus::CColor(1.f, alpha * itemPulse * x5c_beamPulseFactor)});
}
{
@ -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 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);
CModelFlags flags = {};
// flags.m_extendedShader = EExtendedShader::Lighting;
flags.x4_color =
zeus::CColor::lerp(zeus::CColor(1.f, alpha), zeus::CColor(alphaBlend, alpha), x68_visorPulseFactor);
x200_invVisor->Draw(flags);
// flags.m_extendedShader = EExtendedShader::ForcedAdditive;
flags.x4_color = zeus::CColor(1.f, alpha * addBlend * x68_visorPulseFactor);
x200_invVisor->Draw(flags);
const auto c1 =
zeus::CColor::lerp(zeus::CColor{1.f, alpha}, zeus::CColor{alphaBlend, alpha}, x68_visorPulseFactor);
x200_invVisor->Draw({5, 0, 3, c1});
const zeus::CColor c2{1.f, alpha * addBlend * x68_visorPulseFactor};
x200_invVisor->Draw({7, 0, 1, c2});
}
if (x270_25_hasGrappleBeam) {
CGraphics::SetModelMatrix(grappleXf);
// x20c_invGrappleBeam->GetInstance().ActivateLights(x23c_lights);
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);
x20c_invGrappleBeam->Draw({5, 0, 3, zeus::CColor(1.f, alpha)});
x20c_invGrappleBeam->Draw({7, 0, 1, zeus::CColor(1.f, alpha * itemPulse * x60_grapplePulseFactor)});
} else if (x44_suit >= CPlayerState::EPlayerSuit::FusionPower) {
CGraphics::SetModelMatrix(grappleXf);
// x218_invFins->GetInstance().ActivateLights(x23c_lights);
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);
x218_invFins->Draw({5, 0, 3, zeus::CColor(1.f, alpha)});
x218_invFins->Draw({7, 0, 1, zeus::CColor(1.f, alpha * suitPulse)});
}
if (x54_remTransitionTime > 0.f) {
@ -419,22 +389,18 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha) {
else if (x4c_completedMorphball)
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) {
CModelFlags flags = {};
flags.x1_matSetIdx = x1e0_ballMatIdx;
// flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
flags.x4_color = zeus::skWhite;
x184_ballModelData->Render(mgr, x10_ballXf, x24c_actorLights.get(), flags);
// flags.m_extendedShader = EExtendedShader::ForcedAlpha;
flags.x4_color = zeus::skWhite;
flags.x4_color.a() = alpha * ballAlpha;
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);
const std::array flags{
CModelFlags{5, ballMatIdx, 3, zeus::CColor{1.f, 0.f}},
CModelFlags{5, ballMatIdx, 3, zeus::CColor{1.f, combinedBallAlpha}},
};
x184_ballModelData->MultiPassDraw(CModelData::EWhichModel::Normal, x10_ballXf, x24c_actorLights.get(),
flags.data(), flags.size());
x184_ballModelData->Render(
mgr, x10_ballXf, x24c_actorLights.get(),
CModelFlags{7, ballMatIdx, 3, zeus::CColor{1.f, x6c_ballPulseFactor * combinedBallAlpha * itemPulse}});
}
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);
spinAlpha *= 0.5f;
if (spinAlpha > 0.f) {
CModelFlags flags = {};
// flags.m_extendedShader = EExtendedShader::ForcedAdditive;
flags.x1_matSetIdx = x1e0_ballMatIdx;
flags.x4_color = zeus::CColor(1.f, spinAlpha * alpha);
const CModelFlags flags{7, ballMatIdx, 1, zeus::CColor{1.f, spinAlpha * alpha}};
x184_ballModelData->Render(
mgr, x10_ballXf * zeus::CTransform::RotateZ(spinAngle) * zeus::CTransform::Scale(spinScale),
x24c_actorLights.get(), flags);
}
}
if (x270_24_hasSpiderBall) {
if (x270_24_hasSpiderBall && ballAlpha > 0.f) {
CGraphics::SetModelMatrix(x10_ballXf);
CModelFlags flags = {};
flags.x1_matSetIdx = x1e4_glassMatIdx;
// x1d4_spiderBallGlass->GetInstance().ActivateLights(x23c_lights);
// flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
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);
const auto glassMatIdx = static_cast<u8>(x1e4_glassMatIdx);
x1d4_spiderBallGlass->Draw({5, glassMatIdx, 3, zeus::CColor{1.f, 0.f}});
x1d4_spiderBallGlass->Draw({5, glassMatIdx, 3, zeus::CColor{1.f, combinedBallAlpha}});
x1d4_spiderBallGlass->Draw(
{7, glassMatIdx, 3, zeus::CColor{1.f, x6c_ballPulseFactor * itemPulse * combinedBallAlpha}});
}
}
@ -496,21 +447,16 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha) {
0.1f, offset, offset);
}
} else {
CModelFlags flags = {};
flags.x1_matSetIdx = x1e0_ballMatIdx;
// flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
flags.x4_color = zeus::skWhite;
x184_ballModelData->Render(mgr, x10_ballXf, x24c_actorLights.get(), flags);
// flags.m_extendedShader = EExtendedShader::ForcedAlpha;
flags.x4_color = zeus::skWhite;
flags.x4_color.a() = alpha;
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 * itemPulse;
x184_ballModelData->Render(mgr, x10_ballXf, x24c_actorLights.get(), flags);
const auto ballMatIdx = static_cast<u8>(x1e0_ballMatIdx);
const std::array flags{
CModelFlags{5, ballMatIdx, 3, zeus::CColor{1.f, 0.f}},
CModelFlags{5, ballMatIdx, 3, zeus::CColor{1.f, alpha}},
};
x184_ballModelData->MultiPassDraw(CModelData::EWhichModel::Normal, x10_ballXf, x24c_actorLights.get(), flags.data(),
flags.size());
x184_ballModelData->Render(
mgr, x10_ballXf, nullptr,
CModelFlags{7, ballMatIdx, 3, zeus::CColor{1.f, x6c_ballPulseFactor * alpha * itemPulse}});
const CMorphBall::ColorArray ballGlowColorData = CMorphBall::BallGlowColors[x1e8_ballGlowColorIdx];
const zeus::CColor ballGlowColor{
@ -547,24 +493,11 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha) {
}
if (x270_24_hasSpiderBall) {
const auto glassMatIdx = static_cast<u8>(x1e4_glassMatIdx);
CGraphics::SetModelMatrix(x10_ballXf);
CModelFlags spiderBallGlassFlags = {};
spiderBallGlassFlags.x1_matSetIdx = x1e4_glassMatIdx;
// x1d4_spiderBallGlass->GetInstance().ActivateLights(x23c_lights);
// 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);
x1d4_spiderBallGlass->Draw({5, 0, 3, zeus::CColor{1.f, 0.f}});
x1d4_spiderBallGlass->Draw({5, glassMatIdx, 3, zeus::CColor{1.f, alpha}});
x1d4_spiderBallGlass->Draw({7, glassMatIdx, 3, zeus::CColor{1.f, x6c_ballPulseFactor * alpha * itemPulse}});
}
}

View File

@ -128,9 +128,8 @@ std::optional<zeus::CAABox> CGrenadeLauncher::GetTouchBounds() const {
void CGrenadeLauncher::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) {
if (x3f4_damageAddColor.a() == 1.f) {
xb4_drawFlags = CModelFlags{2, 0, 3, zeus::skWhite};
// Original code redundantly sets a() = 1.f
// TODO xb4_drawFlags.addColor = x3f4_damageAddColor;
xb4_drawFlags = CModelFlags{2, 0, 3, x3f4_damageAddColor};
} else {
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) {
// CBooModel::SetReflectionCube(m_reflectionCube);
const bool phazonSuit = x2e8_suitRes.GetCharacterNodeId() == 3;
if (phazonSuit) {
// Draw into alpha buffer
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);
aurora::gfx::set_dst_alpha(true, 1.f);
}
CPhysicsActor::Render(mgr);
if (x314_beamModelData && !x314_beamModelData->IsNull() && x64_modelData && !x64_modelData->IsNull()) {
zeus::CTransform modelXf = GetTransform() * x64_modelData->GetScaledLocatorTransform("GUN_LCTR");
CModelFlags flags(5, 0, 3, zeus::skWhite);
// 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()};
const auto modelXf = GetTransform() * x64_modelData->GetScaledLocatorTransform("GUN_LCTR");
const CModelFlags flags{5, 0, 3, zeus::CColor{1.f, xb4_drawFlags.x4_color.a()}};
x314_beamModelData->Render(mgr, modelXf, x90_actorLights.get(), flags);
}
if (phazonSuit) {
// TODO
// CCubeRenderer::CopyTex
zeus::CVector3f vecFromCam =
GetBoundingBox().center() - mgr.GetCameraManager()->GetCurrentCamera(mgr)->GetTranslation();
const float radius = zeus::clamp(0.25f, (6.f - vecFromCam.magnitude()) / 6.f, 2.f);
const float offsetX = std::sin(x34c_phazonOffsetAngle);
const float offsetY = std::sin(x34c_phazonOffsetAngle) * 0.5f;
// g_Renderer->DrawPhazonSuitIndirectEffect(zeus::CColor(0.1f, 1.f), x338_phazonIndirectTexture, zeus::skWhite,
// radius, 0.05f, offsetX, offsetY);
g_Renderer->DrawPhazonSuitIndirectEffect(zeus::CColor(0.1f, 1.f), x338_phazonIndirectTexture, zeus::skWhite, radius,
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& model = modelData.PickAnimatedModel(x1c4_which);
auto& animData = *modelData.GetAnimationData();
constexpr CModelFlags useFlags(0, 0, 3, zeus::skWhite);
if (posesToBuild & 1 << modelIdx) {
posesToBuild &= ~(1 << modelIdx);
animData.BuildPose();
model.Calculate(animData.GetPose(), useFlags, std::nullopt, nullptr);
model.Calculate(animData.GetPose(), std::nullopt, nullptr);
}
CGraphics::SetModelMatrix(
zeus::CTransform::Translate(boid.GetPosition() - zeus::CVector3f(0.f, 0.f, boid.GetZOffset())) *
zeus::CTransform::Scale(boid.GetScale()));
constexpr CModelFlags useFlags{0, 0, 3, zeus::skWhite};
animData.Render(model, useFlags, std::nullopt, nullptr);
}

View File

@ -541,6 +541,7 @@ var<storage, read> v_packed_uvs: Vec2Block;
info.uniformSize += 32;
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"""(
{{
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);
}}
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.denormalizedVertexAttributes) {