From 73c7755e4ca62d142dc476498f5b19c70cb90622 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Wed, 21 Oct 2020 01:30:44 -0400 Subject: [PATCH] Runtime: GX state accuracy updates CullMode, AlphaUpdate, ColorUpdate, DstAlpha --- Runtime/Character/CActorLights.cpp | 7 ++++++- Runtime/Character/CModelData.cpp | 1 - Runtime/Graphics/CBooRenderer.cpp | 12 +++++++++--- Runtime/Graphics/CGraphics.cpp | 22 ++++++++++++++++++---- Runtime/Graphics/CGraphics.hpp | 13 ++++++++++--- Runtime/Graphics/CModelBoo.cpp | 2 +- Runtime/GuiSys/CCompoundTargetReticle.cpp | 2 ++ Runtime/GuiSys/CGuiFrame.cpp | 11 ++++------- Runtime/GuiSys/CGuiModel.cpp | 8 ++++---- Runtime/MP1/CArtifactDoll.cpp | 3 +++ Runtime/MP1/CPlayerVisor.cpp | 4 ++-- Runtime/MP1/CSamusDoll.cpp | 4 +++- Runtime/MP1/MP1.cpp | 5 +++++ Runtime/MP1/MP1.hpp | 1 + Runtime/Particle/CElementGen.cpp | 8 +++++--- Runtime/Weapon/CGrappleArm.cpp | 8 ++++---- Runtime/Weapon/CGunWeapon.cpp | 8 ++++---- Runtime/Weapon/CPhazonBeam.cpp | 8 +++----- Runtime/Weapon/CPlayerGun.cpp | 2 +- Runtime/World/CMorphBallShadow.cpp | 14 ++++++++++++++ Runtime/World/CScriptPlayerActor.cpp | 6 +----- 21 files changed, 100 insertions(+), 49 deletions(-) diff --git a/Runtime/Character/CActorLights.cpp b/Runtime/Character/CActorLights.cpp index 70530aebf..7e252fc23 100644 --- a/Runtime/Character/CActorLights.cpp +++ b/Runtime/Character/CActorLights.cpp @@ -468,18 +468,23 @@ void CActorLights::ActivateLights(CBooModel& model) const { if (x298_28_inArea) { if (!x298_26_hasAreaLights || x299_26_ambientOnly) { - // g_Renderer->SetAmbientColor(zeus::skWhite); + g_Renderer->SetAmbientColor(zeus::skWhite); lights.push_back(CLight::BuildLocalAmbient(zeus::skZero3f, zeus::skWhite)); model.ActivateLights(lights); return; } } + zeus::CColor amb = x288_ambientColor; + amb.a() = 1.f; + g_Renderer->SetAmbientColor(amb); + lights = BuildLightVector(); model.ActivateLights(lights); if (x298_31_disableWorldLights) { zeus::CColor color(x2d4_worldLightingLevel); + g_Renderer->SetAmbientColor(zeus::skBlack); g_Renderer->SetGXRegister1Color(color); } } diff --git a/Runtime/Character/CModelData.cpp b/Runtime/Character/CModelData.cpp index 7fe084e70..469299fa9 100644 --- a/Runtime/Character/CModelData.cpp +++ b/Runtime/Character/CModelData.cpp @@ -386,7 +386,6 @@ void CModelData::InvSuitDraw(EWhichModel which, const zeus::CTransform& xf, cons if (x10_animData) { CSkinnedModel& model = PickAnimatedModel(which); model.GetModelInst()->DisableAllLights(); - CModelFlags flags = {}; /* Z-prime */ x10_animData->Render(model, zPrimeFlags, std::nullopt, nullptr); diff --git a/Runtime/Graphics/CBooRenderer.cpp b/Runtime/Graphics/CBooRenderer.cpp index 1a4f8ebec..5463f6d7c 100644 --- a/Runtime/Graphics/CBooRenderer.cpp +++ b/Runtime/Graphics/CBooRenderer.cpp @@ -555,12 +555,16 @@ void CBooRenderer::ReallyRenderFogVolume(const zeus::CColor& color, const zeus:: fvs = nullptr; } + CGraphics::SetCullMode(ERglCullMode::Front); + CGraphics::SetDstAlpha(true, 1.f); RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 0, fvs); if (camInModel) RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 1, fvs); + CGraphics::SetDstAlpha(true, 0.f); CGraphics::ResolveSpareDepth(rect, 0); + CGraphics::SetCullMode(ERglCullMode::Back); RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 2, fvs); if (camInModel) RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 3, fvs); @@ -1055,7 +1059,7 @@ void CBooRenderer::SetDebugOption(EDebugOption, int) {} void CBooRenderer::BeginScene() { CGraphics::SetViewport(0, 0, g_Viewport.x8_width, g_Viewport.xc_height); - CGraphics::SetCullMode(ERglCullMode::Front); + CGraphics::SetCullMode(ERglCullMode::Back); CGraphics::SetDepthWriteMode(true, ERglEnum::LEqual, true); CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::InvSrcAlpha, ERglLogicOp::Clear); @@ -1074,7 +1078,7 @@ void CBooRenderer::BeginScene() { x318_26_requestRGBA6 = false; // GXSetPixelFmt(x318_27_currentRGBA6); CGraphics::SetAlphaUpdate(true); - // GXSetDstAlpha(true, 0); + CGraphics::SetDstAlpha(true, 0.f); CGraphics::BeginScene(); m_nextFogVolumePlaneShader = m_fogVolumePlaneShaders.begin(); m_nextFogVolumeFilter = m_fogVolumeFilters.begin(); @@ -1278,6 +1282,8 @@ void CBooRenderer::DrawPhazonSuitIndirectEffect(const zeus::CColor& nonIndirectM ReallyDrawPhazonSuitIndirectEffect(zeus::skWhite, *indTex, indirectMod, scale, offX, offY); else ReallyDrawPhazonSuitEffect(nonIndirectMod); + + CGraphics::SetDstAlpha(false); } void CBooRenderer::AllocatePhazonSuitMaskTexture() { @@ -1351,7 +1357,7 @@ int CBooRenderer::DrawOverlappingWorldModelIDs(int alphaVal, const std::vector(alphaVal) / 255.f; + CGraphics::SetDstAlpha(true, alphaVal); CBooModel& model = *item.x10_models[wordModel + j]; model.UpdateUniformData(flags, nullptr, nullptr, 3); model.VerifyCurrentShader(0); diff --git a/Runtime/Graphics/CGraphics.cpp b/Runtime/Graphics/CGraphics.cpp index cc0d6e67f..85029fa32 100644 --- a/Runtime/Graphics/CGraphics.cpp +++ b/Runtime/Graphics/CGraphics.cpp @@ -17,9 +17,15 @@ ERglBlendMode gx_BlendMode; ERglBlendFactor gx_BlendSrcFac; ERglBlendFactor gx_BlendDstFac; ERglLogicOp gx_BlendOp; -bool gx_AlphaWrite; +bool gx_AlphaUpdate = true; +bool gx_ColorUpdate = true; +bool gx_DstAlpha = false; +float gx_DstAlphaValue = 0.f; ERglCullMode gx_CullMode; -std::array gx_AmbientColors; +std::array gx_AmbientColors = {{ + zeus::CColor{0.2f, 0.2f, 0.2f, 1.f}, + zeus::CColor{0.2f, 0.2f, 0.2f, 1.f}, +}}; /// End GX state hsh::owner CGraphics::g_SpareTexture; @@ -124,8 +130,16 @@ void CGraphics::SetBlendMode(ERglBlendMode type, ERglBlendFactor srcFac, ERglBle void CGraphics::SetCullMode(ERglCullMode mode) { gx_CullMode = mode; } -// URDE addition (GXSetAlphaUpdate) -void CGraphics::SetAlphaUpdate(bool value) { gx_AlphaWrite = value; } +// URDE additions (GXSetAlphaUpdate, GXSetColorUpdate, GXSetDstAlpha) +void CGraphics::SetAlphaUpdate(bool value) { gx_AlphaUpdate = value; } +void CGraphics::SetColorUpdate(bool value) { gx_ColorUpdate = value; } +void CGraphics::SetDstAlpha(bool enabled, float alpha) { + gx_DstAlpha = enabled; + gx_DstAlphaValue = alpha; + if (enabled) { + hsh::set_blend_constants(0.f, 0.f, 0.f, alpha); + } +} void CGraphics::BeginScene() {} diff --git a/Runtime/Graphics/CGraphics.hpp b/Runtime/Graphics/CGraphics.hpp index 36b9966ca..0b0875f57 100644 --- a/Runtime/Graphics/CGraphics.hpp +++ b/Runtime/Graphics/CGraphics.hpp @@ -71,7 +71,7 @@ enum class ERglLogicOp { Set = 15 }; -enum class ERglCullMode { None = 0, Front = 1, Back = 2, All = 3 }; +enum class ERglCullMode { None = 0, Back = 1, Front = 2, All = 3 }; enum class ERglAlphaFunc { Never = 0, @@ -119,7 +119,10 @@ extern ERglBlendMode gx_BlendMode; extern ERglBlendFactor gx_BlendSrcFac; extern ERglBlendFactor gx_BlendDstFac; extern ERglLogicOp gx_BlendOp; -extern bool gx_AlphaWrite; +extern bool gx_ColorUpdate; +extern bool gx_AlphaUpdate; +extern bool gx_DstAlpha; +extern float gx_DstAlphaValue; extern ERglCullMode gx_CullMode; // GX_COLOR0A0 & GX_COLOR1A1 extern std::array gx_AmbientColors; @@ -299,6 +302,8 @@ public: static void SetBlendMode(ERglBlendMode type, ERglBlendFactor srcFac, ERglBlendFactor dstFac, ERglLogicOp op); static void SetCullMode(ERglCullMode mode); static void SetAlphaUpdate(bool value); + static void SetColorUpdate(bool value); + static void SetDstAlpha(bool enabled, float alpha = 0.f); static void BeginScene(); static void EndScene(); static void SetAlphaCompare(ERglAlphaFunc comp0, u8 ref0, ERglAlphaOp op, ERglAlphaFunc comp1, u8 ref1); @@ -337,7 +342,7 @@ public: static const std::array skCubeBasisMats; - static void InitializeBoo(hsh::surface surface) { g_SpareTexture = hsh::create_render_texture2d(surface, 4, 1); } + static void InitializeBoo(hsh::surface surface) { g_SpareTexture = hsh::create_render_texture2d(surface, 3, 3); } static void ShutdownBoo() { g_SpareTexture.reset(); } @@ -346,10 +351,12 @@ public: g_SpareTexture.resolve_color_binding(bindIdx, wrect); if (clearDepth) hsh::clear_attachments(false, true); + hsh::set_blend_constants(0.f, 0.f, 0.f, gx_DstAlphaValue); } static void ResolveSpareDepth(const SClipScreenRect& rect, int bindIdx = 0) { hsh::rect2d wrect = {{rect.x4_left, rect.x8_top}, {rect.xc_width, rect.x10_height}}; g_SpareTexture.resolve_depth_binding(bindIdx, wrect); + hsh::set_blend_constants(0.f, 0.f, 0.f, gx_DstAlphaValue); } static const CTevCombiners::CTevPass sTevPass805a564c; diff --git a/Runtime/Graphics/CModelBoo.cpp b/Runtime/Graphics/CModelBoo.cpp index 2ce086fa0..85f51bc1a 100644 --- a/Runtime/Graphics/CModelBoo.cpp +++ b/Runtime/Graphics/CModelBoo.cpp @@ -1388,7 +1388,7 @@ void CModel::_WarmupShaders() { for (SShader& shader : x18_matSets) { GetInstance().RemapMaterialData(shader); GetInstance().UpdateUniformData(defaultFlags, nullptr, nullptr); - GetInstance().WarmupDrawSurfaces(); + GetInstance().WarmupDrawSurfaces(defaultFlags, defaultFlags); } CGraphics::SetProjectionState(backupProj); CGraphics::SetViewPointMatrix(backupViewPoint); diff --git a/Runtime/GuiSys/CCompoundTargetReticle.cpp b/Runtime/GuiSys/CCompoundTargetReticle.cpp index 737655de0..470fc308b 100644 --- a/Runtime/GuiSys/CCompoundTargetReticle.cpp +++ b/Runtime/GuiSys/CCompoundTargetReticle.cpp @@ -485,12 +485,14 @@ void CCompoundTargetReticle::Draw(const CStateManager& mgr, bool hideLockon) { SCOPED_GRAPHICS_DEBUG_GROUP("CCompoundTargetReticle::Draw", zeus::skCyan); const zeus::CTransform camXf = mgr.GetCameraManager()->GetCurrentCameraTransform(mgr); CGraphics::SetViewPointMatrix(camXf); + CGraphics::SetCullMode(ERglCullMode::None); if (!hideLockon) { DrawCurrLockOnGroup(camXf.basis, mgr); DrawNextLockOnGroup(camXf.basis, mgr); DrawOrbitZoneGroup(camXf.basis, mgr); } DrawGrappleGroup(camXf.basis, mgr, hideLockon); + CGraphics::SetCullMode(ERglCullMode::Back); } if (x28_noDrawTicks > 0) { diff --git a/Runtime/GuiSys/CGuiFrame.cpp b/Runtime/GuiSys/CGuiFrame.cpp index c30213274..c2d296c0d 100644 --- a/Runtime/GuiSys/CGuiFrame.cpp +++ b/Runtime/GuiSys/CGuiFrame.cpp @@ -73,10 +73,10 @@ void CGuiFrame::EnableLights(u32 lights, CBooModel& model) const { ++idx; } if (lightsOut.empty()) { - // CGraphics::SetAmbientColor(zeus::skWhite); + CGraphics::SetAmbientColor(zeus::skWhite); lightsOut.push_back(CLight::BuildLocalAmbient(zeus::skZero3f, zeus::skWhite)); } else { - // CGraphics::SetAmbientColor(ambColor); + CGraphics::SetAmbientColor(ambColor); lightsOut.push_back(CLight::BuildLocalAmbient(zeus::skZero3f, ambColor)); } @@ -126,9 +126,7 @@ void CGuiFrame::SetMaxAspect(float c) { CGuiSys::ViewportResizeFrame(this); } -void CGuiFrame::Reset() { - x10_rootWidget->Reset(ETraversalMode::Children); -} +void CGuiFrame::Reset() { x10_rootWidget->Reset(ETraversalMode::Children); } void CGuiFrame::Update(float dt) { xc_headWidget->Update(dt); } @@ -200,8 +198,7 @@ void CGuiFrame::ProcessUserInput(const CFinalInput& input) const { bool CGuiFrame::ProcessMouseInput(const CFinalInput& input, const CGuiWidgetDrawParms& parms) { if (const auto& kbm = input.GetKBM()) { - zeus::CVector2f point(kbm->m_mouseCoord.x * 2.f - 1.f, - kbm->m_mouseCoord.y * 2.f - 1.f); + zeus::CVector2f point(kbm->m_mouseCoord.x * 2.f - 1.f, kbm->m_mouseCoord.y * 2.f - 1.f); CGuiWidget* hit = BestCursorHit(point, parms); if (hit != m_lastMouseOverWidget) { if (m_inMouseDown && m_mouseDownWidget != hit) { diff --git a/Runtime/GuiSys/CGuiModel.cpp b/Runtime/GuiSys/CGuiModel.cpp index b724e997d..d5675c183 100644 --- a/Runtime/GuiSys/CGuiModel.cpp +++ b/Runtime/GuiSys/CGuiModel.cpp @@ -55,8 +55,8 @@ void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) { zeus::CColor moduCol = xa8_color2; moduCol.a() *= parms.x0_alphaMod; xb0_frame->EnableLights(xcc_lightMask, model->GetInstance()); - // if (xb6_29_cullFaces) - // CGraphics::SetCullMode(ERglCullMode::Front); + if (xb6_29_cullFaces) + CGraphics::SetCullMode(ERglCullMode::Back); switch (xac_drawFlags) { case EGuiModelDrawFlags::Shadeless: { @@ -92,8 +92,8 @@ void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) { break; } - // if (xb6_29_cullFaces) - // CGraphics::SetCullMode(ERglCullMode::None); + if (xb6_29_cullFaces) + CGraphics::SetCullMode(ERglCullMode::None); xb0_frame->DisableLights(); } diff --git a/Runtime/MP1/CArtifactDoll.cpp b/Runtime/MP1/CArtifactDoll.cpp index 9a90bbc87..f0b97ec4d 100644 --- a/Runtime/MP1/CArtifactDoll.cpp +++ b/Runtime/MP1/CArtifactDoll.cpp @@ -101,6 +101,7 @@ void CArtifactDoll::Draw(float alpha, const CStateManager& mgr, bool inArtifactC CGraphics::SetModelMatrix(zeus::CTransform::RotateX(zeus::degToRad(std::sin(angle) * 8.f)) * zeus::CTransform::RotateZ(zeus::degToRad(std::cos(angle) * 8.f)) * zeus::CTransform::RotateX(M_PIF / 2.f) * zeus::CTransform::Scale(0.2f)); + CGraphics::SetCullMode(ERglCullMode::None); CPlayerState& playerState = *mgr.GetPlayerState(); for (size_t i = 0; i < x0_models.size(); ++i) { @@ -134,6 +135,8 @@ void CArtifactDoll::Draw(float alpha, const CStateManager& mgr, bool inArtifactC flags.x4_color.a() *= alpha; model->Draw({8, 0, 1, flags.x4_color}); } + CGraphics::SetCullMode(ERglCullMode::Back); + // CGraphics::DisableAllLights(); } void CArtifactDoll::UpdateActorLights() { diff --git a/Runtime/MP1/CPlayerVisor.cpp b/Runtime/MP1/CPlayerVisor.cpp index 5f8150707..63df9d604 100644 --- a/Runtime/MP1/CPlayerVisor.cpp +++ b/Runtime/MP1/CPlayerVisor.cpp @@ -379,7 +379,7 @@ void CPlayerVisor::DrawScanEffect(const CStateManager& mgr, CTargetingManager* t }}; x108_newScanPane.drawVerts(zeus::CColor(1.f, transFactor), rttVerts); - // No cull faces + CGraphics::SetCullMode(ERglCullMode::None); zeus::CColor frameColor = zeus::CColor::lerp(g_tweakGuiColors->GetScanFrameInactiveColor(), g_tweakGuiColors->GetScanFrameActiveColor(), x54c_scanFrameColorInterp); @@ -451,7 +451,7 @@ void CPlayerVisor::DrawScanEffect(const CStateManager& mgr, CTargetingManager* t xf0_scanFrameStretchSide->Draw(flags); } - // cull faces + CGraphics::SetCullMode(ERglCullMode::Back); } void CPlayerVisor::DrawXRayEffect(const CStateManager&) { diff --git a/Runtime/MP1/CSamusDoll.cpp b/Runtime/MP1/CSamusDoll.cpp index 274371bba..8a6bd617b 100644 --- a/Runtime/MP1/CSamusDoll.cpp +++ b/Runtime/MP1/CSamusDoll.cpp @@ -332,7 +332,9 @@ 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) { + CGraphics::SetDstAlpha(true, 1.f); + } for (size_t i = 0; i <= x118_suitModel1and2.size(); ++i) { TCachedToken backupModelData = xc8_suitModel0->GetAnimationData()->GetModelData(); diff --git a/Runtime/MP1/MP1.cpp b/Runtime/MP1/MP1.cpp index 5c6436bdc..0de336f5f 100644 --- a/Runtime/MP1/MP1.cpp +++ b/Runtime/MP1/MP1.cpp @@ -800,6 +800,8 @@ void CMain::Init(const hecl::Runtime::FileStoreManager& storeMgr, hecl::CVarMana x164_archSupport->PreloadAudio(); std::srand(static_cast(std::time(nullptr))); // g_TweakManager->ReadFromMemoryCard("AudioTweaks"); + + m_alphaPass.SetFilter(EFilterType::NoColor, EFilterShape::Fullscreen, 0.f, zeus::skBlack, {}); } static logvisor::Module WarmupLog("ShaderWarmup"); @@ -911,8 +913,11 @@ void CMain::Draw() { return; } +#if !HSH_PROFILE_MODE hsh::clear_attachments(); x164_archSupport->Draw(); + m_alphaPass.Draw(); +#endif } void CMain::ShutdownSubsystems() { diff --git a/Runtime/MP1/MP1.hpp b/Runtime/MP1/MP1.hpp index 522e02067..9853bcd30 100644 --- a/Runtime/MP1/MP1.hpp +++ b/Runtime/MP1/MP1.hpp @@ -254,6 +254,7 @@ private: using delta_clock = std::chrono::high_resolution_clock; std::chrono::time_point m_prevFrameTime; DataSpec::URDEVersionInfo m_version; + CCameraFilterPass m_alphaPass; void InitializeSubsystems(); static void InitializeDiscord(); diff --git a/Runtime/Particle/CElementGen.cpp b/Runtime/Particle/CElementGen.cpp index 991c2dd4d..f3065fd5b 100644 --- a/Runtime/Particle/CElementGen.cpp +++ b/Runtime/Particle/CElementGen.cpp @@ -855,8 +855,11 @@ void CElementGen::Render(const CActorLights* actorLights) { void CElementGen::RenderModels(const CActorLights* actorLights) { CGenDescription* desc = x1c_genDesc.GetObj(); - if (x26d_26_modelsUseLights) + if (x26d_26_modelsUseLights) { CGraphics::SetLightState(x274_backupLightActive); + } else { + CGraphics::SetAmbientColor(zeus::skWhite); + } CGlobalRandom gr(x27c_randState); SUVElementSet uvs = {0.f, 0.f, 1.f, 1.f}; @@ -882,9 +885,8 @@ void CElementGen::RenderModels(const CActorLights* actorLights) { CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::InvSrcAlpha, ERglLogicOp::Clear); } - - CGraphics::SetCullMode(ERglCullMode::None); #endif + CGraphics::SetCullMode(ERglCullMode::None); if (texr) { CParticle& target = x30_particles[0]; diff --git a/Runtime/Weapon/CGrappleArm.cpp b/Runtime/Weapon/CGrappleArm.cpp index d67f6117c..d8a919e1c 100644 --- a/Runtime/Weapon/CGrappleArm.cpp +++ b/Runtime/Weapon/CGrappleArm.cpp @@ -491,13 +491,13 @@ void CGrappleArm::PreRender(const CStateManager& mgr, const zeus::CFrustum& frus void CGrappleArm::RenderXRayModel(const CStateManager& mgr, const zeus::CTransform& modelXf, const CModelFlags& flags) { CGraphics::SetModelMatrix(modelXf * zeus::CTransform::Scale(x0_grappleArmModel->GetScale())); - // CGraphics::DisableAllLights(); - // g_Renderer->SetAmbientColor(zeus::skWhite); + CGraphics::DisableAllLights(); + CGraphics::SetAmbientColor(zeus::skWhite); CSkinnedModel& model = *x50_grappleArmSkeletonModel->GetAnimationData()->GetModelData(); model.GetModelInst()->ActivateLights({CLight::BuildLocalAmbient({}, zeus::skWhite)}); x0_grappleArmModel->GetAnimationData()->Render(model, flags, std::nullopt, nullptr); - // g_Renderer->SetAmbientColor(zeus::skWhite); - // CGraphics::DisableAllLights(); + CGraphics::SetAmbientColor(zeus::skWhite); + CGraphics::DisableAllLights(); } void CGrappleArm::PointGenerator(void* ctx, const std::vector>& vn) { diff --git a/Runtime/Weapon/CGunWeapon.cpp b/Runtime/Weapon/CGunWeapon.cpp index 2c017dc95..ac8bc0261 100644 --- a/Runtime/Weapon/CGunWeapon.cpp +++ b/Runtime/Weapon/CGunWeapon.cpp @@ -509,13 +509,13 @@ void CGunWeapon::DrawHologram(const CStateManager& mgr, const zeus::CTransform& x60_holoModelData->Render(CModelData::EWhichModel::Normal, xf, nullptr, flags); } else { CGraphics::SetModelMatrix(xf * zeus::CTransform::Scale(x10_solidModelData->GetScale())); - // CGraphics::DisableAllLights(); - // g_Renderer->SetAmbientColor(zeus::skWhite); + CGraphics::DisableAllLights(); + CGraphics::SetAmbientColor(zeus::skWhite); CSkinnedModel& model = *x60_holoModelData->GetAnimationData()->GetModelData(); model.GetModelInst()->ActivateLights({CLight::BuildLocalAmbient({}, zeus::skWhite)}); x10_solidModelData->GetAnimationData()->Render(model, flags, std::nullopt, nullptr); - // g_Renderer->SetAmbientColor(zeus::skWhite); - // CGraphics::DisableAllLights(); + CGraphics::SetAmbientColor(zeus::skWhite); + CGraphics::DisableAllLights(); } } diff --git a/Runtime/Weapon/CPhazonBeam.cpp b/Runtime/Weapon/CPhazonBeam.cpp index 7ef082a4a..1ec346a9a 100644 --- a/Runtime/Weapon/CPhazonBeam.cpp +++ b/Runtime/Weapon/CPhazonBeam.cpp @@ -169,7 +169,7 @@ void CPhazonBeam::DrawClipScaleCube() { g_Renderer->SetBlendMode_AlphaBlended(); CGraphics::SetCullMode(ERglCullMode::None); m_aaboxShaderScale.draw(zeus::CColor{1.f, 1.f, 1.f, 0.f}); - CGraphics::SetCullMode(ERglCullMode::Front); + CGraphics::SetCullMode(ERglCullMode::Back); } void CPhazonBeam::DrawClipTranslateCube() { @@ -177,7 +177,7 @@ void CPhazonBeam::DrawClipTranslateCube() { g_Renderer->SetBlendMode_AlphaBlended(); CGraphics::SetCullMode(ERglCullMode::None); m_aaboxShaderTranslate.draw(zeus::CColor{1.f, 1.f, 1.f, 0.f}); - CGraphics::SetCullMode(ERglCullMode::Front); + CGraphics::SetCullMode(ERglCullMode::Back); } void CPhazonBeam::Draw(bool drawSuitArm, const CStateManager& mgr, const zeus::CTransform& xf, const CModelFlags& flags, @@ -187,9 +187,7 @@ void CPhazonBeam::Draw(bool drawSuitArm, const CStateManager& mgr, const zeus::C if (drawIndirect) { CGraphics::ResolveSpareTexture(g_Viewport); - CModelFlags tmpFlags = flags; - tmpFlags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly; - CGunWeapon::Draw(drawSuitArm, mgr, xf, tmpFlags, lights); + CGraphics::SetDstAlpha(true, 1.f); } CGunWeapon::Draw(drawSuitArm, mgr, xf, flags, lights); diff --git a/Runtime/Weapon/CPlayerGun.cpp b/Runtime/Weapon/CPlayerGun.cpp index 929a0a9cf..69523d6ce 100644 --- a/Runtime/Weapon/CPlayerGun.cpp +++ b/Runtime/Weapon/CPlayerGun.cpp @@ -2137,7 +2137,7 @@ void CPlayerGun::DrawClipCube(const zeus::CAABox& aabb) { g_Renderer->SetBlendMode_AlphaBlended(); CGraphics::SetCullMode(ERglCullMode::None); m_aaboxShader.draw(zeus::CColor{1.f, 1.f, 1.f, 0.f}); - CGraphics::SetCullMode(ERglCullMode::Front); + CGraphics::SetCullMode(ERglCullMode::Back); } void CPlayerGun::Render(const CStateManager& mgr, const zeus::CVector3f& pos, const CModelFlags& flags) { diff --git a/Runtime/World/CMorphBallShadow.cpp b/Runtime/World/CMorphBallShadow.cpp index 543707be7..80603efeb 100644 --- a/Runtime/World/CMorphBallShadow.cpp +++ b/Runtime/World/CMorphBallShadow.cpp @@ -54,7 +54,17 @@ void CMorphBallShadow::RenderIdBuffer(const zeus::CAABox& aabb, const CStateMana rstl::reserved_vector nearItems; mgr.BuildNearList(nearItems, aabb, CMaterialFilter::skPassEverything, &player); + CGraphics::SetAlphaUpdate(true); + CGraphics::SetDstAlpha(true, 0.f); + CGraphics::SetColorUpdate(false); + // CGX::SetZMode(true,GX_ALWAYS,true) + //CGraphics::SetCullMode(ERglCullMode::None); CGraphics::SetViewPointMatrix(viewMtx); + // CGraphics::SetAlphaCompare(Always,0,And,Always,0); + // CGraphics::SetBlendMode(Blend,One,Zero,Clear); + + CBooModel::SetRenderModelBlack(true); + // TODO int alphaVal = 4; for (TUniqueId id : nearItems) { @@ -84,6 +94,10 @@ void CMorphBallShadow::RenderIdBuffer(const zeus::CAABox& aabb, const CStateMana g_Renderer->FindOverlappingWorldModels(x30_worldModelBits, aabb); alphaVal = g_Renderer->DrawOverlappingWorldModelIDs(alphaVal, x30_worldModelBits, aabb); + CBooModel::SetRenderModelBlack(false); + CGraphics::SetColorUpdate(true); + CGraphics::SetDstAlpha(false, 0.f); + g_Renderer->ResolveBallShadowIdTarget(); g_Renderer->BindMainDrawTarget(); diff --git a/Runtime/World/CScriptPlayerActor.cpp b/Runtime/World/CScriptPlayerActor.cpp index 602bdb45a..1aa4cefd0 100644 --- a/Runtime/World/CScriptPlayerActor.cpp +++ b/Runtime/World/CScriptPlayerActor.cpp @@ -402,11 +402,7 @@ void CScriptPlayerActor::Render(CStateManager& mgr) { 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); + CGraphics::SetDstAlpha(true, 1.f); } CPhysicsActor::Render(mgr);