Runtime: GX state accuracy updates

CullMode, AlphaUpdate, ColorUpdate, DstAlpha
This commit is contained in:
Luke Street 2020-10-21 01:30:44 -04:00
parent 4995a1524e
commit 73c7755e4c
21 changed files with 100 additions and 49 deletions

View File

@ -468,18 +468,23 @@ void CActorLights::ActivateLights(CBooModel& model) const {
if (x298_28_inArea) { if (x298_28_inArea) {
if (!x298_26_hasAreaLights || x299_26_ambientOnly) { 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)); lights.push_back(CLight::BuildLocalAmbient(zeus::skZero3f, zeus::skWhite));
model.ActivateLights(lights); model.ActivateLights(lights);
return; return;
} }
} }
zeus::CColor amb = x288_ambientColor;
amb.a() = 1.f;
g_Renderer->SetAmbientColor(amb);
lights = BuildLightVector(); lights = BuildLightVector();
model.ActivateLights(lights); model.ActivateLights(lights);
if (x298_31_disableWorldLights) { if (x298_31_disableWorldLights) {
zeus::CColor color(x2d4_worldLightingLevel); zeus::CColor color(x2d4_worldLightingLevel);
g_Renderer->SetAmbientColor(zeus::skBlack);
g_Renderer->SetGXRegister1Color(color); g_Renderer->SetGXRegister1Color(color);
} }
} }

View File

@ -386,7 +386,6 @@ void CModelData::InvSuitDraw(EWhichModel which, const zeus::CTransform& xf, cons
if (x10_animData) { if (x10_animData) {
CSkinnedModel& model = PickAnimatedModel(which); CSkinnedModel& model = PickAnimatedModel(which);
model.GetModelInst()->DisableAllLights(); model.GetModelInst()->DisableAllLights();
CModelFlags flags = {};
/* Z-prime */ /* Z-prime */
x10_animData->Render(model, zPrimeFlags, std::nullopt, nullptr); x10_animData->Render(model, zPrimeFlags, std::nullopt, nullptr);

View File

@ -555,12 +555,16 @@ void CBooRenderer::ReallyRenderFogVolume(const zeus::CColor& color, const zeus::
fvs = nullptr; fvs = nullptr;
} }
CGraphics::SetCullMode(ERglCullMode::Front);
CGraphics::SetDstAlpha(true, 1.f);
RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 0, fvs); RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 0, fvs);
if (camInModel) if (camInModel)
RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 1, fvs); RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 1, fvs);
CGraphics::SetDstAlpha(true, 0.f);
CGraphics::ResolveSpareDepth(rect, 0); CGraphics::ResolveSpareDepth(rect, 0);
CGraphics::SetCullMode(ERglCullMode::Back);
RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 2, fvs); RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 2, fvs);
if (camInModel) if (camInModel)
RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 3, fvs); RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 3, fvs);
@ -1055,7 +1059,7 @@ void CBooRenderer::SetDebugOption(EDebugOption, int) {}
void CBooRenderer::BeginScene() { void CBooRenderer::BeginScene() {
CGraphics::SetViewport(0, 0, g_Viewport.x8_width, g_Viewport.xc_height); 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::SetDepthWriteMode(true, ERglEnum::LEqual, true);
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::InvSrcAlpha, CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::InvSrcAlpha,
ERglLogicOp::Clear); ERglLogicOp::Clear);
@ -1074,7 +1078,7 @@ void CBooRenderer::BeginScene() {
x318_26_requestRGBA6 = false; x318_26_requestRGBA6 = false;
// GXSetPixelFmt(x318_27_currentRGBA6); // GXSetPixelFmt(x318_27_currentRGBA6);
CGraphics::SetAlphaUpdate(true); CGraphics::SetAlphaUpdate(true);
// GXSetDstAlpha(true, 0); CGraphics::SetDstAlpha(true, 0.f);
CGraphics::BeginScene(); CGraphics::BeginScene();
m_nextFogVolumePlaneShader = m_fogVolumePlaneShaders.begin(); m_nextFogVolumePlaneShader = m_fogVolumePlaneShaders.begin();
m_nextFogVolumeFilter = m_fogVolumeFilters.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); ReallyDrawPhazonSuitIndirectEffect(zeus::skWhite, *indTex, indirectMod, scale, offX, offY);
else else
ReallyDrawPhazonSuitEffect(nonIndirectMod); ReallyDrawPhazonSuitEffect(nonIndirectMod);
CGraphics::SetDstAlpha(false);
} }
void CBooRenderer::AllocatePhazonSuitMaskTexture() { void CBooRenderer::AllocatePhazonSuitMaskTexture() {
@ -1351,7 +1357,7 @@ int CBooRenderer::DrawOverlappingWorldModelIDs(int alphaVal, const std::vector<u
return alphaVal; return alphaVal;
} }
flags.x4_color.a() = static_cast<float>(alphaVal) / 255.f; CGraphics::SetDstAlpha(true, alphaVal);
CBooModel& model = *item.x10_models[wordModel + j]; CBooModel& model = *item.x10_models[wordModel + j];
model.UpdateUniformData(flags, nullptr, nullptr, 3); model.UpdateUniformData(flags, nullptr, nullptr, 3);
model.VerifyCurrentShader(0); model.VerifyCurrentShader(0);

View File

@ -17,9 +17,15 @@ ERglBlendMode gx_BlendMode;
ERglBlendFactor gx_BlendSrcFac; ERglBlendFactor gx_BlendSrcFac;
ERglBlendFactor gx_BlendDstFac; ERglBlendFactor gx_BlendDstFac;
ERglLogicOp gx_BlendOp; 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; ERglCullMode gx_CullMode;
std::array<zeus::CColor, 2> gx_AmbientColors; std::array<zeus::CColor, 2> 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 /// End GX state
hsh::owner<hsh::render_texture2d> CGraphics::g_SpareTexture; hsh::owner<hsh::render_texture2d> CGraphics::g_SpareTexture;
@ -124,8 +130,16 @@ void CGraphics::SetBlendMode(ERglBlendMode type, ERglBlendFactor srcFac, ERglBle
void CGraphics::SetCullMode(ERglCullMode mode) { gx_CullMode = mode; } void CGraphics::SetCullMode(ERglCullMode mode) { gx_CullMode = mode; }
// URDE addition (GXSetAlphaUpdate) // URDE additions (GXSetAlphaUpdate, GXSetColorUpdate, GXSetDstAlpha)
void CGraphics::SetAlphaUpdate(bool value) { gx_AlphaWrite = value; } 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() {} void CGraphics::BeginScene() {}

View File

@ -71,7 +71,7 @@ enum class ERglLogicOp {
Set = 15 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 { enum class ERglAlphaFunc {
Never = 0, Never = 0,
@ -119,7 +119,10 @@ extern ERglBlendMode gx_BlendMode;
extern ERglBlendFactor gx_BlendSrcFac; extern ERglBlendFactor gx_BlendSrcFac;
extern ERglBlendFactor gx_BlendDstFac; extern ERglBlendFactor gx_BlendDstFac;
extern ERglLogicOp gx_BlendOp; 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; extern ERglCullMode gx_CullMode;
// GX_COLOR0A0 & GX_COLOR1A1 // GX_COLOR0A0 & GX_COLOR1A1
extern std::array<zeus::CColor, 2> gx_AmbientColors; extern std::array<zeus::CColor, 2> gx_AmbientColors;
@ -299,6 +302,8 @@ public:
static void SetBlendMode(ERglBlendMode type, ERglBlendFactor srcFac, ERglBlendFactor dstFac, ERglLogicOp op); static void SetBlendMode(ERglBlendMode type, ERglBlendFactor srcFac, ERglBlendFactor dstFac, ERglLogicOp op);
static void SetCullMode(ERglCullMode mode); static void SetCullMode(ERglCullMode mode);
static void SetAlphaUpdate(bool value); static void SetAlphaUpdate(bool value);
static void SetColorUpdate(bool value);
static void SetDstAlpha(bool enabled, float alpha = 0.f);
static void BeginScene(); static void BeginScene();
static void EndScene(); static void EndScene();
static void SetAlphaCompare(ERglAlphaFunc comp0, u8 ref0, ERglAlphaOp op, ERglAlphaFunc comp1, u8 ref1); static void SetAlphaCompare(ERglAlphaFunc comp0, u8 ref0, ERglAlphaOp op, ERglAlphaFunc comp1, u8 ref1);
@ -337,7 +342,7 @@ public:
static const std::array<zeus::CMatrix3f, 6> skCubeBasisMats; static const std::array<zeus::CMatrix3f, 6> 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(); } static void ShutdownBoo() { g_SpareTexture.reset(); }
@ -346,10 +351,12 @@ public:
g_SpareTexture.resolve_color_binding(bindIdx, wrect); g_SpareTexture.resolve_color_binding(bindIdx, wrect);
if (clearDepth) if (clearDepth)
hsh::clear_attachments(false, true); 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) { static void ResolveSpareDepth(const SClipScreenRect& rect, int bindIdx = 0) {
hsh::rect2d wrect = {{rect.x4_left, rect.x8_top}, {rect.xc_width, rect.x10_height}}; hsh::rect2d wrect = {{rect.x4_left, rect.x8_top}, {rect.xc_width, rect.x10_height}};
g_SpareTexture.resolve_depth_binding(bindIdx, wrect); g_SpareTexture.resolve_depth_binding(bindIdx, wrect);
hsh::set_blend_constants(0.f, 0.f, 0.f, gx_DstAlphaValue);
} }
static const CTevCombiners::CTevPass sTevPass805a564c; static const CTevCombiners::CTevPass sTevPass805a564c;

View File

@ -1388,7 +1388,7 @@ void CModel::_WarmupShaders() {
for (SShader& shader : x18_matSets) { for (SShader& shader : x18_matSets) {
GetInstance().RemapMaterialData(shader); GetInstance().RemapMaterialData(shader);
GetInstance().UpdateUniformData(defaultFlags, nullptr, nullptr); GetInstance().UpdateUniformData(defaultFlags, nullptr, nullptr);
GetInstance().WarmupDrawSurfaces(); GetInstance().WarmupDrawSurfaces(defaultFlags, defaultFlags);
} }
CGraphics::SetProjectionState(backupProj); CGraphics::SetProjectionState(backupProj);
CGraphics::SetViewPointMatrix(backupViewPoint); CGraphics::SetViewPointMatrix(backupViewPoint);

View File

@ -485,12 +485,14 @@ void CCompoundTargetReticle::Draw(const CStateManager& mgr, bool hideLockon) {
SCOPED_GRAPHICS_DEBUG_GROUP("CCompoundTargetReticle::Draw", zeus::skCyan); SCOPED_GRAPHICS_DEBUG_GROUP("CCompoundTargetReticle::Draw", zeus::skCyan);
const zeus::CTransform camXf = mgr.GetCameraManager()->GetCurrentCameraTransform(mgr); const zeus::CTransform camXf = mgr.GetCameraManager()->GetCurrentCameraTransform(mgr);
CGraphics::SetViewPointMatrix(camXf); CGraphics::SetViewPointMatrix(camXf);
CGraphics::SetCullMode(ERglCullMode::None);
if (!hideLockon) { if (!hideLockon) {
DrawCurrLockOnGroup(camXf.basis, mgr); DrawCurrLockOnGroup(camXf.basis, mgr);
DrawNextLockOnGroup(camXf.basis, mgr); DrawNextLockOnGroup(camXf.basis, mgr);
DrawOrbitZoneGroup(camXf.basis, mgr); DrawOrbitZoneGroup(camXf.basis, mgr);
} }
DrawGrappleGroup(camXf.basis, mgr, hideLockon); DrawGrappleGroup(camXf.basis, mgr, hideLockon);
CGraphics::SetCullMode(ERglCullMode::Back);
} }
if (x28_noDrawTicks > 0) { if (x28_noDrawTicks > 0) {

View File

@ -73,10 +73,10 @@ void CGuiFrame::EnableLights(u32 lights, CBooModel& model) const {
++idx; ++idx;
} }
if (lightsOut.empty()) { if (lightsOut.empty()) {
// CGraphics::SetAmbientColor(zeus::skWhite); CGraphics::SetAmbientColor(zeus::skWhite);
lightsOut.push_back(CLight::BuildLocalAmbient(zeus::skZero3f, zeus::skWhite)); lightsOut.push_back(CLight::BuildLocalAmbient(zeus::skZero3f, zeus::skWhite));
} else { } else {
// CGraphics::SetAmbientColor(ambColor); CGraphics::SetAmbientColor(ambColor);
lightsOut.push_back(CLight::BuildLocalAmbient(zeus::skZero3f, ambColor)); lightsOut.push_back(CLight::BuildLocalAmbient(zeus::skZero3f, ambColor));
} }
@ -126,9 +126,7 @@ void CGuiFrame::SetMaxAspect(float c) {
CGuiSys::ViewportResizeFrame(this); CGuiSys::ViewportResizeFrame(this);
} }
void CGuiFrame::Reset() { void CGuiFrame::Reset() { x10_rootWidget->Reset(ETraversalMode::Children); }
x10_rootWidget->Reset(ETraversalMode::Children);
}
void CGuiFrame::Update(float dt) { xc_headWidget->Update(dt); } 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) { bool CGuiFrame::ProcessMouseInput(const CFinalInput& input, const CGuiWidgetDrawParms& parms) {
if (const auto& kbm = input.GetKBM()) { if (const auto& kbm = input.GetKBM()) {
zeus::CVector2f point(kbm->m_mouseCoord.x * 2.f - 1.f, zeus::CVector2f point(kbm->m_mouseCoord.x * 2.f - 1.f, kbm->m_mouseCoord.y * 2.f - 1.f);
kbm->m_mouseCoord.y * 2.f - 1.f);
CGuiWidget* hit = BestCursorHit(point, parms); CGuiWidget* hit = BestCursorHit(point, parms);
if (hit != m_lastMouseOverWidget) { if (hit != m_lastMouseOverWidget) {
if (m_inMouseDown && m_mouseDownWidget != hit) { if (m_inMouseDown && m_mouseDownWidget != hit) {

View File

@ -55,8 +55,8 @@ void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) {
zeus::CColor moduCol = xa8_color2; zeus::CColor moduCol = xa8_color2;
moduCol.a() *= parms.x0_alphaMod; moduCol.a() *= parms.x0_alphaMod;
xb0_frame->EnableLights(xcc_lightMask, model->GetInstance()); xb0_frame->EnableLights(xcc_lightMask, model->GetInstance());
// if (xb6_29_cullFaces) if (xb6_29_cullFaces)
// CGraphics::SetCullMode(ERglCullMode::Front); CGraphics::SetCullMode(ERglCullMode::Back);
switch (xac_drawFlags) { switch (xac_drawFlags) {
case EGuiModelDrawFlags::Shadeless: { case EGuiModelDrawFlags::Shadeless: {
@ -92,8 +92,8 @@ void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) {
break; break;
} }
// if (xb6_29_cullFaces) if (xb6_29_cullFaces)
// CGraphics::SetCullMode(ERglCullMode::None); CGraphics::SetCullMode(ERglCullMode::None);
xb0_frame->DisableLights(); xb0_frame->DisableLights();
} }

View File

@ -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)) * CGraphics::SetModelMatrix(zeus::CTransform::RotateX(zeus::degToRad(std::sin(angle) * 8.f)) *
zeus::CTransform::RotateZ(zeus::degToRad(std::cos(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)); zeus::CTransform::RotateX(M_PIF / 2.f) * zeus::CTransform::Scale(0.2f));
CGraphics::SetCullMode(ERglCullMode::None);
CPlayerState& playerState = *mgr.GetPlayerState(); CPlayerState& playerState = *mgr.GetPlayerState();
for (size_t i = 0; i < x0_models.size(); ++i) { 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; flags.x4_color.a() *= alpha;
model->Draw({8, 0, 1, flags.x4_color}); model->Draw({8, 0, 1, flags.x4_color});
} }
CGraphics::SetCullMode(ERglCullMode::Back);
// CGraphics::DisableAllLights();
} }
void CArtifactDoll::UpdateActorLights() { void CArtifactDoll::UpdateActorLights() {

View File

@ -379,7 +379,7 @@ void CPlayerVisor::DrawScanEffect(const CStateManager& mgr, CTargetingManager* t
}}; }};
x108_newScanPane.drawVerts(zeus::CColor(1.f, transFactor), rttVerts); 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(), zeus::CColor frameColor = zeus::CColor::lerp(g_tweakGuiColors->GetScanFrameInactiveColor(),
g_tweakGuiColors->GetScanFrameActiveColor(), x54c_scanFrameColorInterp); g_tweakGuiColors->GetScanFrameActiveColor(), x54c_scanFrameColorInterp);
@ -451,7 +451,7 @@ void CPlayerVisor::DrawScanEffect(const CStateManager& mgr, CTargetingManager* t
xf0_scanFrameStretchSide->Draw(flags); xf0_scanFrameStretchSide->Draw(flags);
} }
// cull faces CGraphics::SetCullMode(ERglCullMode::Back);
} }
void CPlayerVisor::DrawXRayEffect(const CStateManager&) { void CPlayerVisor::DrawXRayEffect(const CStateManager&) {

View File

@ -332,7 +332,9 @@ 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) {
CGraphics::SetDstAlpha(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();

View File

@ -800,6 +800,8 @@ void CMain::Init(const hecl::Runtime::FileStoreManager& storeMgr, hecl::CVarMana
x164_archSupport->PreloadAudio(); x164_archSupport->PreloadAudio();
std::srand(static_cast<u32>(std::time(nullptr))); std::srand(static_cast<u32>(std::time(nullptr)));
// g_TweakManager->ReadFromMemoryCard("AudioTweaks"); // g_TweakManager->ReadFromMemoryCard("AudioTweaks");
m_alphaPass.SetFilter(EFilterType::NoColor, EFilterShape::Fullscreen, 0.f, zeus::skBlack, {});
} }
static logvisor::Module WarmupLog("ShaderWarmup"); static logvisor::Module WarmupLog("ShaderWarmup");
@ -911,8 +913,11 @@ void CMain::Draw() {
return; return;
} }
#if !HSH_PROFILE_MODE
hsh::clear_attachments(); hsh::clear_attachments();
x164_archSupport->Draw(); x164_archSupport->Draw();
m_alphaPass.Draw();
#endif
} }
void CMain::ShutdownSubsystems() { void CMain::ShutdownSubsystems() {

View File

@ -254,6 +254,7 @@ private:
using delta_clock = std::chrono::high_resolution_clock; using delta_clock = std::chrono::high_resolution_clock;
std::chrono::time_point<delta_clock> m_prevFrameTime; std::chrono::time_point<delta_clock> m_prevFrameTime;
DataSpec::URDEVersionInfo m_version; DataSpec::URDEVersionInfo m_version;
CCameraFilterPass<CColoredQuadFilter> m_alphaPass;
void InitializeSubsystems(); void InitializeSubsystems();
static void InitializeDiscord(); static void InitializeDiscord();

View File

@ -855,8 +855,11 @@ void CElementGen::Render(const CActorLights* actorLights) {
void CElementGen::RenderModels(const CActorLights* actorLights) { void CElementGen::RenderModels(const CActorLights* actorLights) {
CGenDescription* desc = x1c_genDesc.GetObj(); CGenDescription* desc = x1c_genDesc.GetObj();
if (x26d_26_modelsUseLights) if (x26d_26_modelsUseLights) {
CGraphics::SetLightState(x274_backupLightActive); CGraphics::SetLightState(x274_backupLightActive);
} else {
CGraphics::SetAmbientColor(zeus::skWhite);
}
CGlobalRandom gr(x27c_randState); CGlobalRandom gr(x27c_randState);
SUVElementSet uvs = {0.f, 0.f, 1.f, 1.f}; 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, CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::InvSrcAlpha,
ERglLogicOp::Clear); ERglLogicOp::Clear);
} }
CGraphics::SetCullMode(ERglCullMode::None);
#endif #endif
CGraphics::SetCullMode(ERglCullMode::None);
if (texr) { if (texr) {
CParticle& target = x30_particles[0]; CParticle& target = x30_particles[0];

View File

@ -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) { void CGrappleArm::RenderXRayModel(const CStateManager& mgr, const zeus::CTransform& modelXf, const CModelFlags& flags) {
CGraphics::SetModelMatrix(modelXf * zeus::CTransform::Scale(x0_grappleArmModel->GetScale())); CGraphics::SetModelMatrix(modelXf * zeus::CTransform::Scale(x0_grappleArmModel->GetScale()));
// CGraphics::DisableAllLights(); CGraphics::DisableAllLights();
// g_Renderer->SetAmbientColor(zeus::skWhite); CGraphics::SetAmbientColor(zeus::skWhite);
CSkinnedModel& model = *x50_grappleArmSkeletonModel->GetAnimationData()->GetModelData(); CSkinnedModel& model = *x50_grappleArmSkeletonModel->GetAnimationData()->GetModelData();
model.GetModelInst()->ActivateLights({CLight::BuildLocalAmbient({}, zeus::skWhite)}); model.GetModelInst()->ActivateLights({CLight::BuildLocalAmbient({}, zeus::skWhite)});
x0_grappleArmModel->GetAnimationData()->Render(model, flags, std::nullopt, nullptr); x0_grappleArmModel->GetAnimationData()->Render(model, flags, std::nullopt, nullptr);
// g_Renderer->SetAmbientColor(zeus::skWhite); CGraphics::SetAmbientColor(zeus::skWhite);
// CGraphics::DisableAllLights(); CGraphics::DisableAllLights();
} }
void CGrappleArm::PointGenerator(void* ctx, const std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vn) { void CGrappleArm::PointGenerator(void* ctx, const std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vn) {

View File

@ -509,13 +509,13 @@ void CGunWeapon::DrawHologram(const CStateManager& mgr, const zeus::CTransform&
x60_holoModelData->Render(CModelData::EWhichModel::Normal, xf, nullptr, flags); x60_holoModelData->Render(CModelData::EWhichModel::Normal, xf, nullptr, flags);
} else { } else {
CGraphics::SetModelMatrix(xf * zeus::CTransform::Scale(x10_solidModelData->GetScale())); CGraphics::SetModelMatrix(xf * zeus::CTransform::Scale(x10_solidModelData->GetScale()));
// CGraphics::DisableAllLights(); CGraphics::DisableAllLights();
// g_Renderer->SetAmbientColor(zeus::skWhite); CGraphics::SetAmbientColor(zeus::skWhite);
CSkinnedModel& model = *x60_holoModelData->GetAnimationData()->GetModelData(); CSkinnedModel& model = *x60_holoModelData->GetAnimationData()->GetModelData();
model.GetModelInst()->ActivateLights({CLight::BuildLocalAmbient({}, zeus::skWhite)}); model.GetModelInst()->ActivateLights({CLight::BuildLocalAmbient({}, zeus::skWhite)});
x10_solidModelData->GetAnimationData()->Render(model, flags, std::nullopt, nullptr); x10_solidModelData->GetAnimationData()->Render(model, flags, std::nullopt, nullptr);
// g_Renderer->SetAmbientColor(zeus::skWhite); CGraphics::SetAmbientColor(zeus::skWhite);
// CGraphics::DisableAllLights(); CGraphics::DisableAllLights();
} }
} }

View File

@ -169,7 +169,7 @@ void CPhazonBeam::DrawClipScaleCube() {
g_Renderer->SetBlendMode_AlphaBlended(); g_Renderer->SetBlendMode_AlphaBlended();
CGraphics::SetCullMode(ERglCullMode::None); CGraphics::SetCullMode(ERglCullMode::None);
m_aaboxShaderScale.draw(zeus::CColor{1.f, 1.f, 1.f, 0.f}); m_aaboxShaderScale.draw(zeus::CColor{1.f, 1.f, 1.f, 0.f});
CGraphics::SetCullMode(ERglCullMode::Front); CGraphics::SetCullMode(ERglCullMode::Back);
} }
void CPhazonBeam::DrawClipTranslateCube() { void CPhazonBeam::DrawClipTranslateCube() {
@ -177,7 +177,7 @@ void CPhazonBeam::DrawClipTranslateCube() {
g_Renderer->SetBlendMode_AlphaBlended(); g_Renderer->SetBlendMode_AlphaBlended();
CGraphics::SetCullMode(ERglCullMode::None); CGraphics::SetCullMode(ERglCullMode::None);
m_aaboxShaderTranslate.draw(zeus::CColor{1.f, 1.f, 1.f, 0.f}); 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, 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) { if (drawIndirect) {
CGraphics::ResolveSpareTexture(g_Viewport); CGraphics::ResolveSpareTexture(g_Viewport);
CModelFlags tmpFlags = flags; CGraphics::SetDstAlpha(true, 1.f);
tmpFlags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
CGunWeapon::Draw(drawSuitArm, mgr, xf, tmpFlags, lights);
} }
CGunWeapon::Draw(drawSuitArm, mgr, xf, flags, lights); CGunWeapon::Draw(drawSuitArm, mgr, xf, flags, lights);

View File

@ -2137,7 +2137,7 @@ void CPlayerGun::DrawClipCube(const zeus::CAABox& aabb) {
g_Renderer->SetBlendMode_AlphaBlended(); g_Renderer->SetBlendMode_AlphaBlended();
CGraphics::SetCullMode(ERglCullMode::None); CGraphics::SetCullMode(ERglCullMode::None);
m_aaboxShader.draw(zeus::CColor{1.f, 1.f, 1.f, 0.f}); 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) { void CPlayerGun::Render(const CStateManager& mgr, const zeus::CVector3f& pos, const CModelFlags& flags) {

View File

@ -54,7 +54,17 @@ void CMorphBallShadow::RenderIdBuffer(const zeus::CAABox& aabb, const CStateMana
rstl::reserved_vector<TUniqueId, 1024> nearItems; rstl::reserved_vector<TUniqueId, 1024> nearItems;
mgr.BuildNearList(nearItems, aabb, CMaterialFilter::skPassEverything, &player); 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::SetViewPointMatrix(viewMtx);
// CGraphics::SetAlphaCompare(Always,0,And,Always,0);
// CGraphics::SetBlendMode(Blend,One,Zero,Clear);
CBooModel::SetRenderModelBlack(true);
// TODO
int alphaVal = 4; int alphaVal = 4;
for (TUniqueId id : nearItems) { for (TUniqueId id : nearItems) {
@ -84,6 +94,10 @@ void CMorphBallShadow::RenderIdBuffer(const zeus::CAABox& aabb, const CStateMana
g_Renderer->FindOverlappingWorldModels(x30_worldModelBits, aabb); g_Renderer->FindOverlappingWorldModels(x30_worldModelBits, aabb);
alphaVal = g_Renderer->DrawOverlappingWorldModelIDs(alphaVal, 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->ResolveBallShadowIdTarget();
g_Renderer->BindMainDrawTarget(); g_Renderer->BindMainDrawTarget();

View File

@ -402,11 +402,7 @@ void CScriptPlayerActor::Render(CStateManager& mgr) {
const bool phazonSuit = x2e8_suitRes.GetCharacterNodeId() == 3; const bool phazonSuit = x2e8_suitRes.GetCharacterNodeId() == 3;
if (phazonSuit) { if (phazonSuit) {
// Draw into alpha buffer // Draw into alpha buffer
CModelFlags flags = xb4_drawFlags; CGraphics::SetDstAlpha(true, 1.f);
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);