Lots of bug fixes; working CPhazonSuitFilter

This commit is contained in:
Jack Andersen 2017-12-19 20:06:54 -10:00
parent 1c44f8d1bc
commit c00cc6cea9
41 changed files with 322 additions and 161 deletions

View File

@ -734,8 +734,8 @@ void CCameraManager::SetPlayerCamera(CStateManager& mgr, TUniqueId newCamId)
float CCameraManager::GetCameraBobMagnitude() const float CCameraManager::GetCameraBobMagnitude() const
{ {
return 1.f - zeus::clamp(-1.f, zeus::clamp(-1.f, return 1.f - zeus::clamp(-1.f, std::fabs(zeus::clamp(-1.f,
x7c_fpCamera->GetTransform().basis[1].dot(zeus::CVector3f::skUp), 1.f) / x7c_fpCamera->GetTransform().basis[1].dot(zeus::CVector3f::skUp), 1.f)) /
std::cos(2.f * M_PIF / 12.f), 1.f); std::cos(2.f * M_PIF / 12.f), 1.f);
} }

View File

@ -316,7 +316,7 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt)
if (player->GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Morphed || if (player->GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Morphed ||
player->GetOrbitState() == CPlayer::EPlayerOrbitState::Grapple || player->GetOrbitState() == CPlayer::EPlayerOrbitState::Grapple ||
player->GetGrappleState() == CPlayer::EGrappleState::None || player->GetGrappleState() != CPlayer::EGrappleState::None ||
mgr.GetGameState() == CStateManager::EGameState::SoftPaused || mgr.GetGameState() == CStateManager::EGameState::SoftPaused ||
mgr.GetCameraManager()->IsInCinematicCamera() || mgr.GetCameraManager()->IsInCinematicCamera() ||
x1d4_closeInTimer > 0.f) x1d4_closeInTimer > 0.f)

View File

@ -533,17 +533,18 @@ zeus::CTransform CAnimData::GetLocatorTransform(CSegId id, const CCharAnimTime*
return {}; return {};
zeus::CTransform ret; zeus::CTransform ret;
if (!x220_31_poseCached) if (time || !x220_31_poseCached)
{
const_cast<CAnimData*>(this)->RecalcPoseBuilder(time); const_cast<CAnimData*>(this)->RecalcPoseBuilder(time);
const_cast<CAnimData*>(this)->x220_31_poseCached = time == nullptr;
}
if (!x220_30_poseBuilt) if (!x220_30_poseBuilt)
x2fc_poseBuilder.BuildTransform(id, ret); x2fc_poseBuilder.BuildTransform(id, ret);
else else
{ {
zeus::CMatrix3f rot = x224_pose.GetRotation(id); ret.setRotation(x224_pose.GetTransformMinusOffset(id));
zeus::CVector3f offset = x224_pose.GetOffset(id); ret.origin = x224_pose.GetOffset(id);
ret.setRotation(rot);
ret.origin = offset;
} }
return ret; return ret;
} }

View File

@ -339,6 +339,7 @@ bool CBitLevelLoader::LoadBool()
CSegIdToIndexConverter::CSegIdToIndexConverter(const CFBStreamedAnimReaderTotals& totals) CSegIdToIndexConverter::CSegIdToIndexConverter(const CFBStreamedAnimReaderTotals& totals)
{ {
std::fill(std::begin(x0_indices), std::end(x0_indices), -1);
for (u32 b=0 ; b<totals.x24_boneChanCount ; ++b) for (u32 b=0 ; b<totals.x24_boneChanCount ; ++b)
{ {
u16 segId = totals.xc_segIds2[b]; u16 segId = totals.xc_segIds2[b];
@ -360,13 +361,19 @@ CFBStreamedAnimReader::CFBStreamedAnimReader(const TSubAnimTypeToken<CFBStreamed
bool CFBStreamedAnimReader::HasOffset(const CSegId& seg) const bool CFBStreamedAnimReader::HasOffset(const CSegId& seg) const
{ {
return x7c_totals.Prior().x8_hasTrans1[x114_segIdToIndex.SegIdToIndex(seg)]; s32 idx = x114_segIdToIndex.SegIdToIndex(seg);
if (idx == -1)
return false;
return x7c_totals.Prior().x8_hasTrans1[idx];
} }
zeus::CVector3f CFBStreamedAnimReader::GetOffset(const CSegId& seg) const zeus::CVector3f CFBStreamedAnimReader::GetOffset(const CSegId& seg) const
{ {
const float* af = x7c_totals.Prior().GetFloats(x114_segIdToIndex.SegIdToIndex(seg)); s32 idx = x114_segIdToIndex.SegIdToIndex(seg);
const float* bf = x7c_totals.Next().GetFloats(x114_segIdToIndex.SegIdToIndex(seg)); if (idx == -1)
return {};
const float* af = x7c_totals.Prior().GetFloats(idx);
const float* bf = x7c_totals.Next().GetFloats(idx);
zeus::CVector3f a(af[4], af[5], af[6]); zeus::CVector3f a(af[4], af[5], af[6]);
zeus::CVector3f b(bf[4], bf[5], bf[6]); zeus::CVector3f b(bf[4], bf[5], bf[6]);
return zeus::CVector3f::lerp(a, b, x7c_totals.GetT()); return zeus::CVector3f::lerp(a, b, x7c_totals.GetT());
@ -374,8 +381,11 @@ zeus::CVector3f CFBStreamedAnimReader::GetOffset(const CSegId& seg) const
zeus::CQuaternion CFBStreamedAnimReader::GetRotation(const CSegId& seg) const zeus::CQuaternion CFBStreamedAnimReader::GetRotation(const CSegId& seg) const
{ {
const float* af = x7c_totals.Prior().GetFloats(x114_segIdToIndex.SegIdToIndex(seg)); s32 idx = x114_segIdToIndex.SegIdToIndex(seg);
const float* bf = x7c_totals.Next().GetFloats(x114_segIdToIndex.SegIdToIndex(seg)); if (idx == -1)
return {};
const float* af = x7c_totals.Prior().GetFloats(idx);
const float* bf = x7c_totals.Next().GetFloats(idx);
zeus::CQuaternion a(af[0], af[1], af[2], af[3]); zeus::CQuaternion a(af[0], af[1], af[2], af[3]);
zeus::CQuaternion b(bf[0], bf[1], bf[2], bf[3]); zeus::CQuaternion b(bf[0], bf[1], bf[2], bf[3]);
return zeus::CQuaternion::slerp(a, b, x7c_totals.GetT()); return zeus::CQuaternion::slerp(a, b, x7c_totals.GetT());
@ -479,33 +489,40 @@ SAdvancementResults CFBStreamedAnimReader::VAdvanceView(const CCharAnimTime& dt)
SAdvancementResults res = {}; SAdvancementResults res = {};
CCharAnimTime animDur = x54_source->GetAnimationDuration(); CCharAnimTime animDur = x54_source->GetAnimationDuration();
if (xc_curTime >= animDur || dt.EqualsZero()) if (xc_curTime == animDur)
{ {
xc_curTime = CCharAnimTime(0); xc_curTime = CCharAnimTime();
x7c_totals.SetTime(x108_bitLoader, xc_curTime); x7c_totals.SetTime(x108_bitLoader, xc_curTime);
res.x0_remTime = dt;
return res;
}
else if (dt.EqualsZero())
{
return res; return res;
} }
zeus::CQuaternion priorQ = GetRotation(3); zeus::CQuaternion priorQ = GetRotation(3);
zeus::CVector3f priorV = GetOffset(3); zeus::CVector3f priorV = GetOffset(3);
CCharAnimTime nextTime = xc_curTime + dt; xc_curTime += dt;
if (nextTime > animDur) CCharAnimTime overTime;
if (xc_curTime > animDur)
{ {
nextTime = animDur; overTime = xc_curTime - animDur;
res.x0_remTime = nextTime - animDur; xc_curTime = animDur;
} }
xc_curTime = nextTime;
x7c_totals.SetTime(x108_bitLoader, xc_curTime); x7c_totals.SetTime(x108_bitLoader, xc_curTime);
if (x54_source->HasPOIData()) if (x54_source->HasPOIData())
UpdatePOIStates(); UpdatePOIStates();
zeus::CQuaternion nextQ = GetRotation(3); zeus::CQuaternion nextQ = GetRotation(3);
zeus::CVector3f nextV = GetOffset(3); zeus::CVector3f nextV = GetOffset(3);
res.x8_deltas.xc_rotDelta = priorQ.inverse() * nextQ; res.x0_remTime = overTime;
res.x8_deltas.xc_rotDelta = nextQ * priorQ.inverse();
if (HasOffset(3)) if (HasOffset(3))
res.x8_deltas.x0_posDelta = res.x8_deltas.xc_rotDelta.transform(nextV - priorV); res.x8_deltas.x0_posDelta = nextQ.inverse().transform(nextV - priorV);
return res; return res;
} }

View File

@ -85,10 +85,10 @@ public:
class CSegIdToIndexConverter class CSegIdToIndexConverter
{ {
u32 x0_indices[96] = {u32(-1)}; s32 x0_indices[96];
public: public:
CSegIdToIndexConverter(const CFBStreamedAnimReaderTotals& totals); CSegIdToIndexConverter(const CFBStreamedAnimReaderTotals& totals);
u32 SegIdToIndex(const CSegId& id) const { return x0_indices[id]; } s32 SegIdToIndex(const CSegId& id) const { return x0_indices[id]; }
}; };
class CFBStreamedAnimReader : public CAnimSourceReaderBase class CFBStreamedAnimReader : public CAnimSourceReaderBase

View File

@ -19,10 +19,10 @@ std::shared_ptr<CAnimTreeNode>
CMetaAnimPlay::VGetAnimationTree(const CAnimSysContext& animSys, CMetaAnimPlay::VGetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const const CMetaAnimTreeBuildOrders& orders) const
{ {
if (orders.x0_) if (orders.x0_recursiveAdvance)
{ {
CMetaAnimTreeBuildOrders modOrders; CMetaAnimTreeBuildOrders modOrders;
modOrders.PreAdvanceForAll(*orders.x0_); modOrders.PreAdvanceForAll(*orders.x0_recursiveAdvance);
return GetAnimationTree(animSys, modOrders); return GetAnimationTree(animSys, modOrders);
} }

View File

@ -1,5 +1,6 @@
#include "CMetaAnimRandom.hpp" #include "CMetaAnimRandom.hpp"
#include "CMetaAnimFactory.hpp" #include "CMetaAnimFactory.hpp"
#include "CAnimSysContext.hpp"
namespace urde namespace urde
{ {
@ -32,7 +33,16 @@ std::shared_ptr<CAnimTreeNode>
CMetaAnimRandom::VGetAnimationTree(const CAnimSysContext& animSys, CMetaAnimRandom::VGetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const const CMetaAnimTreeBuildOrders& orders) const
{ {
return {}; s32 r = animSys.x8_random->Range(1, 100);
const std::pair<std::shared_ptr<IMetaAnim>, u32>* useRd = nullptr;
for (auto& rd : x4_randomData)
{
useRd = &rd;
if (r <= rd.second)
break;
}
return useRd->first->GetAnimationTree(animSys, orders);
} }
} }

View File

@ -30,10 +30,10 @@ std::shared_ptr<CAnimTreeNode>
CMetaAnimSequence::VGetAnimationTree(const CAnimSysContext& animSys, CMetaAnimSequence::VGetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const const CMetaAnimTreeBuildOrders& orders) const
{ {
if (orders.x0_) if (orders.x0_recursiveAdvance)
{ {
CMetaAnimTreeBuildOrders modOrders; CMetaAnimTreeBuildOrders modOrders;
modOrders.PreAdvanceForAll(*orders.x0_); modOrders.PreAdvanceForAll(*orders.x0_recursiveAdvance);
return GetAnimationTree(animSys, modOrders); return GetAnimationTree(animSys, modOrders);
} }

View File

@ -423,7 +423,7 @@ void CModelData::InvSuitDraw(EWhichModel which, const zeus::CTransform& xf, cons
/* Normal Blended */ /* Normal Blended */
lights->ActivateLights(*model.GetModelInst()); lights->ActivateLights(*model.GetModelInst());
flags.m_extendedShader = EExtendedShader::Lighting; flags.m_extendedShader = EExtendedShader::ForcedAlpha;
flags.x4_color = alphaColor; flags.x4_color = alphaColor;
x10_animData->Render(model, flags, {}, nullptr); x10_animData->Render(model, flags, {}, nullptr);
@ -445,7 +445,7 @@ void CModelData::InvSuitDraw(EWhichModel which, const zeus::CTransform& xf, cons
/* Normal Blended */ /* Normal Blended */
lights->ActivateLights(model); lights->ActivateLights(model);
flags.m_extendedShader = EExtendedShader::Lighting; flags.m_extendedShader = EExtendedShader::ForcedAlpha;
flags.x4_color = alphaColor; flags.x4_color = alphaColor;
model.Draw(flags, nullptr, nullptr); model.Draw(flags, nullptr, nullptr);

View File

@ -11,13 +11,13 @@ std::shared_ptr<CAnimTreeNode>
IMetaAnim::GetAnimationTree(const CAnimSysContext& animSys, IMetaAnim::GetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const const CMetaAnimTreeBuildOrders& orders) const
{ {
if (orders.x44_) if (orders.x44_singleAdvance)
{ {
std::shared_ptr<CAnimTreeNode> tree = std::shared_ptr<CAnimTreeNode> tree =
VGetAnimationTree(animSys, CMetaAnimTreeBuildOrders::NoSpecialOrders()); VGetAnimationTree(animSys, CMetaAnimTreeBuildOrders::NoSpecialOrders());
if (orders.x44_->IsTime() || orders.x44_->IsString()) if (orders.x44_singleAdvance->IsTime() || orders.x44_singleAdvance->IsString())
{ {
CCharAnimTime time = GetTime(*orders.x44_, *tree); CCharAnimTime time = GetTime(*orders.x44_singleAdvance, *tree);
AdvanceAnim(*tree, time); AdvanceAnim(*tree, time);
} }
return tree; return tree;

View File

@ -52,14 +52,14 @@ public:
struct CMetaAnimTreeBuildOrders struct CMetaAnimTreeBuildOrders
{ {
std::experimental::optional<CPreAdvanceIndicator> x0_; std::experimental::optional<CPreAdvanceIndicator> x0_recursiveAdvance;
std::experimental::optional<CPreAdvanceIndicator> x44_; std::experimental::optional<CPreAdvanceIndicator> x44_singleAdvance;
static CMetaAnimTreeBuildOrders NoSpecialOrders() { return {}; } static CMetaAnimTreeBuildOrders NoSpecialOrders() { return {}; }
static CMetaAnimTreeBuildOrders PreAdvanceForAll(const CPreAdvanceIndicator& ind) static CMetaAnimTreeBuildOrders PreAdvanceForAll(const CPreAdvanceIndicator& ind)
{ {
CMetaAnimTreeBuildOrders ret; CMetaAnimTreeBuildOrders ret;
ret.x0_.emplace(ind); ret.x0_recursiveAdvance.emplace(ind);
ret.x44_.emplace(ind); ret.x44_singleAdvance.emplace(ind);
return ret; return ret;
} }
}; };

View File

@ -664,11 +664,6 @@ bool CMetroidAreaCollider::MovingAABoxCollisionCheck_BoxVertexTri(const CCollisi
{ {
pointOut = float(d) * dir + point; pointOut = float(d) * dir + point;
normalOut = surf.GetNormal(); normalOut = surf.GetNormal();
if (normalOut.z > 100.f)
{
printf("");
normalOut = surf.GetNormal();
}
ret = true; ret = true;
} }
} }

View File

@ -1310,7 +1310,8 @@ void CBooRenderer::ReallyDrawPhazonSuitIndirectEffect(const zeus::CColor& vertCo
const CTexture& indTex, const zeus::CColor& modColor, const CTexture& indTex, const zeus::CColor& modColor,
float scale, float offX, float offY) float scale, float offX, float offY)
{ {
m_phazonSuitFilter.draw(modColor, scale, offX * scale, offY * scale); float qScale = scale / 8.f; // Adjustment for URDE
m_phazonSuitFilter.draw(modColor, scale, offX * qScale, offY * qScale);
} }
void CBooRenderer::ReallyDrawPhazonSuitEffect(const zeus::CColor& modColor /*, const CTexture& maskTex*/) void CBooRenderer::ReallyDrawPhazonSuitEffect(const zeus::CColor& modColor /*, const CTexture& maskTex*/)

View File

@ -119,7 +119,7 @@ TShader<CCameraBlurFilter>::IDataBindingFactory* CCameraBlurFilter::Initialize(b
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, true, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
return new CCameraBlurFilterMetalDataBindingFactory; return new CCameraBlurFilterMetalDataBindingFactory;
} }

View File

@ -92,15 +92,15 @@ CColoredQuadFilter::Initialize(boo::MetalDataFactory::Context& ctx)
s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, true, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
s_AddPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, s_AddPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, true, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
s_MultPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, s_MultPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::Zero, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::Zero,
boo::BlendFactor::SrcColor, boo::Primitive::TriStrips, boo::BlendFactor::SrcColor, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, true, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
return new CColoredQuadFilterMetalDataBindingFactory; return new CColoredQuadFilterMetalDataBindingFactory;
} }

View File

@ -318,28 +318,28 @@ TShader<CElementGenShaders>::IDataBindingFactory* CElementGenShaders::Initialize
m_texZTestZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_texZTestZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
m_vtxFormatTex, CGraphics::g_ViewportSamples, m_vtxFormatTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::LEqual, true, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::LEqual, true, true, false, boo::CullMode::None);
m_texNoZTestZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_texNoZTestZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
m_vtxFormatTex, CGraphics::g_ViewportSamples, m_vtxFormatTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, true, true, false, boo::CullMode::None);
m_texZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_texZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
m_vtxFormatTex, CGraphics::g_ViewportSamples, m_vtxFormatTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
m_texNoZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_texNoZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
m_vtxFormatTex, CGraphics::g_ViewportSamples, m_vtxFormatTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None);
m_texAdditiveZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_texAdditiveZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
m_vtxFormatTex, CGraphics::g_ViewportSamples, m_vtxFormatTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
m_texAdditiveNoZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_texAdditiveNoZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
m_vtxFormatTex, CGraphics::g_ViewportSamples, m_vtxFormatTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None);
m_texRedToAlphaZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, nullptr, nullptr, m_texRedToAlphaZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, nullptr, nullptr,
m_vtxFormatTex, CGraphics::g_ViewportSamples, m_vtxFormatTex, CGraphics::g_ViewportSamples,
@ -365,64 +365,64 @@ TShader<CElementGenShaders>::IDataBindingFactory* CElementGenShaders::Initialize
m_vtxFormatTex, CGraphics::g_ViewportSamples, m_vtxFormatTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract, boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
true, false, boo::CullMode::None); true, true, boo::CullMode::None);
m_texRedToAlphaNoZTestSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, nullptr, nullptr, m_texRedToAlphaNoZTestSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, nullptr, nullptr,
m_vtxFormatTex, CGraphics::g_ViewportSamples, m_vtxFormatTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract, boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
boo::Primitive::TriStrips, boo::ZTest::None, false, boo::Primitive::TriStrips, boo::ZTest::None, false,
true, false, boo::CullMode::None); true, true, boo::CullMode::None);
m_indTexZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_INDTEX, nullptr, nullptr, m_indTexZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_INDTEX, nullptr, nullptr,
m_vtxFormatIndTex, CGraphics::g_ViewportSamples, m_vtxFormatIndTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, true, true, false, boo::CullMode::None);
m_indTexNoZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_INDTEX, nullptr, nullptr, m_indTexNoZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_INDTEX, nullptr, nullptr,
m_vtxFormatIndTex, CGraphics::g_ViewportSamples, m_vtxFormatIndTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None);
m_indTexAdditive = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_INDTEX, nullptr, nullptr, m_indTexAdditive = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_INDTEX, nullptr, nullptr,
m_vtxFormatIndTex, CGraphics::g_ViewportSamples, m_vtxFormatIndTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, true, true, false, boo::CullMode::None);
m_cindTexZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_CINDTEX, nullptr, nullptr, m_cindTexZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_CINDTEX, nullptr, nullptr,
m_vtxFormatIndTex, CGraphics::g_ViewportSamples, m_vtxFormatIndTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, true, true, false, boo::CullMode::None);
m_cindTexNoZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_CINDTEX, nullptr, nullptr, m_cindTexNoZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_CINDTEX, nullptr, nullptr,
m_vtxFormatIndTex, CGraphics::g_ViewportSamples, m_vtxFormatIndTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None);
m_cindTexAdditive = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_CINDTEX, nullptr, nullptr, m_cindTexAdditive = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_CINDTEX, nullptr, nullptr,
m_vtxFormatIndTex, CGraphics::g_ViewportSamples, m_vtxFormatIndTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, true, true, false, boo::CullMode::None);
m_noTexZTestZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr, m_noTexZTestZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr,
m_vtxFormatNoTex, CGraphics::g_ViewportSamples, m_vtxFormatNoTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::LEqual, true, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::LEqual, true, true, false, boo::CullMode::None);
m_noTexNoZTestZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr, m_noTexNoZTestZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr,
m_vtxFormatNoTex, CGraphics::g_ViewportSamples, m_vtxFormatNoTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, true, true, false, boo::CullMode::None);
m_noTexZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr, m_noTexZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr,
m_vtxFormatNoTex, CGraphics::g_ViewportSamples, m_vtxFormatNoTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
m_noTexNoZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr, m_noTexNoZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr,
m_vtxFormatNoTex, CGraphics::g_ViewportSamples, m_vtxFormatNoTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None);
m_noTexAdditiveZTest = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr, m_noTexAdditiveZTest = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr,
m_vtxFormatNoTex, CGraphics::g_ViewportSamples, m_vtxFormatNoTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
m_noTexAdditiveNoZTest = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr, m_noTexAdditiveNoZTest = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr,
m_vtxFormatNoTex, CGraphics::g_ViewportSamples, m_vtxFormatNoTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None);
return new struct MetalElementDataBindingFactory; return new struct MetalElementDataBindingFactory;
} }

View File

@ -3,6 +3,8 @@
namespace urde namespace urde
{ {
#define BLUR_SCALE (1.f / 32.f)
void CPhazonSuitFilter::drawBlurPasses(float radius, const CTexture* indTex) void CPhazonSuitFilter::drawBlurPasses(float radius, const CTexture* indTex)
{ {
if (!m_dataBind || indTex != m_indTex) if (!m_dataBind || indTex != m_indTex)
@ -27,6 +29,7 @@ void CPhazonSuitFilter::drawBlurPasses(float radius, const CTexture* indTex)
}; };
m_blurVbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, blurVerts, sizeof(BlurVert), 4); m_blurVbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, blurVerts, sizeof(BlurVert), 4);
float aspect = g_Viewport.x8_width / float(g_Viewport.xc_height);
struct Vert struct Vert
{ {
zeus::CVector3f pos; zeus::CVector3f pos;
@ -35,10 +38,10 @@ void CPhazonSuitFilter::drawBlurPasses(float radius, const CTexture* indTex)
zeus::CVector2f maskUv; zeus::CVector2f maskUv;
} verts[4] = } verts[4] =
{ {
{{-1.f, 1.f, 0.f}, {0.01f, 0.99f}, {0.f, 1.f}, {0.f, 1.f}}, {{-1.f, 1.f, 0.f}, {0.01f, 0.99f}, {0.f, 4.f}, {0.f, 1.f}},
{{-1.f, -1.f, 0.f}, {0.01f, 0.01f}, {0.f, 1.f}, {0.f, 1.f}}, {{-1.f, -1.f, 0.f}, {0.01f, 0.01f}, {0.f, 0.f}, {0.f, 0.f}},
{{ 1.f, 1.f, 0.f}, {0.99f, 0.99f}, {0.f, 1.f}, {0.f, 1.f}}, {{ 1.f, 1.f, 0.f}, {0.99f, 0.99f}, {aspect * 4.f, 4.f}, {1.f, 1.f}},
{{ 1.f, -1.f, 0.f}, {0.99f, 0.01f}, {0.f, 1.f}, {0.f, 1.f}} {{ 1.f, -1.f, 0.f}, {0.99f, 0.01f}, {aspect * 4.f, 0.f}, {1.f, 0.f}}
}; };
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts, sizeof(Vert), 4); m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts, sizeof(Vert), 4);
@ -54,7 +57,8 @@ void CPhazonSuitFilter::drawBlurPasses(float radius, const CTexture* indTex)
rect.x10_height = g_Viewport.xc_height; rect.x10_height = g_Viewport.xc_height;
/* X Pass */ /* X Pass */
zeus::CVector4f blurDir = zeus::CVector4f{2.f * radius / g_Viewport.x8_width, 0.f, 0.f, 0.f}; zeus::CVector4f blurDir = zeus::CVector4f{g_Viewport.xc_height / float(g_Viewport.x8_width) *
radius * BLUR_SCALE, 0.f, 0.f, 0.f};
m_uniBufBlurX->load(&blurDir, sizeof(zeus::CVector4f)); m_uniBufBlurX->load(&blurDir, sizeof(zeus::CVector4f));
CGraphics::SetShaderDataBinding(m_dataBindBlurX); CGraphics::SetShaderDataBinding(m_dataBindBlurX);
@ -62,7 +66,7 @@ void CPhazonSuitFilter::drawBlurPasses(float radius, const CTexture* indTex)
CGraphics::ResolveSpareTexture(rect, 2); CGraphics::ResolveSpareTexture(rect, 2);
/* Y Pass */ /* Y Pass */
blurDir = zeus::CVector4f{0.f, 2.f * radius / g_Viewport.xc_height, 0.f, 0.f}; blurDir = zeus::CVector4f{0.f, radius * BLUR_SCALE, 0.f, 0.f};
m_uniBufBlurY->load(&blurDir, sizeof(zeus::CVector4f)); m_uniBufBlurY->load(&blurDir, sizeof(zeus::CVector4f));
CGraphics::SetShaderDataBinding(m_dataBindBlurY); CGraphics::SetShaderDataBinding(m_dataBindBlurY);

View File

@ -59,10 +59,11 @@ BOO_GLSL_BINDING_HEAD
"TBINDING3 uniform sampler2D maskTexBlur;\n" "TBINDING3 uniform sampler2D maskTexBlur;\n"
"void main()\n" "void main()\n"
"{\n" "{\n"
" vec2 indUv = (texture(indTex, vtf.indUv).rg - vec2(0.5, 0.5)) * \n" " vec2 indUv = (texture(indTex, vtf.indUv).ra - vec2(0.5, 0.5)) * \n"
" vtf.indScaleOff.xy + vtf.indScaleOff.zw;\n" " vtf.indScaleOff.xy + vtf.indScaleOff.zw;\n"
" colorOut = vtf.color * texture(screenTex, indUv + vtf.screenUv) * \n" " float maskBlurAlpha = clamp(0.0, (texture(maskTexBlur, vtf.maskUv).a - texture(maskTex, vtf.maskUv).a) * 2.0, 1.0);\n"
" (texture(maskTexBlur, vtf.maskUv).a - texture(maskTex, vtf.maskUv).a);\n" " colorOut = vtf.color * texture(screenTex, indUv + vtf.screenUv) * maskBlurAlpha;\n"
" colorOut.a = vtf.color.a;\n"
"}\n"; "}\n";
static const char* FS = static const char* FS =
@ -84,8 +85,9 @@ BOO_GLSL_BINDING_HEAD
"TBINDING2 uniform sampler2D maskTexBlur;\n" "TBINDING2 uniform sampler2D maskTexBlur;\n"
"void main()\n" "void main()\n"
"{\n" "{\n"
" colorOut = vtf.color * texture(screenTex, vtf.screenUv) * \n" " float maskBlurAlpha = clamp(0.0, (texture(maskTexBlur, vtf.maskUv).a - texture(maskTex, vtf.maskUv).a) * 2.0, 1.0);\n"
" (texture(maskTexBlur, vtf.maskUv).a - texture(maskTex, vtf.maskUv).a);\n" " colorOut = vtf.color * texture(screenTex, vtf.screenUv) * maskBlurAlpha;\n"
" colorOut.a = vtf.color.a;\n"
"}\n"; "}\n";
static const char* BlurVS = static const char* BlurVS =
@ -139,10 +141,10 @@ BOO_GLSL_BINDING_HEAD
"\n" "\n"
" sum += texture(maskTex, vtf.uv).a * 0.2270270270;\n" " sum += texture(maskTex, vtf.uv).a * 0.2270270270;\n"
"\n" "\n"
" sum += texture(maskTex, vtf.uv - 1.0 * vtf.blurDir).a * 0.1945945946;\n" " sum += texture(maskTex, vtf.uv + 1.0 * vtf.blurDir).a * 0.1945945946;\n"
" sum += texture(maskTex, vtf.uv - 2.0 * vtf.blurDir).a * 0.1216216216;\n" " sum += texture(maskTex, vtf.uv + 2.0 * vtf.blurDir).a * 0.1216216216;\n"
" sum += texture(maskTex, vtf.uv - 3.0 * vtf.blurDir).a * 0.0540540541;\n" " sum += texture(maskTex, vtf.uv + 3.0 * vtf.blurDir).a * 0.0540540541;\n"
" sum += texture(maskTex, vtf.uv - 4.0 * vtf.blurDir).a * 0.0162162162;\n" " sum += texture(maskTex, vtf.uv + 4.0 * vtf.blurDir).a * 0.0162162162;\n"
"\n" "\n"
" colorOut = vec4(1.0, 1.0, 1.0, sum);\n" " colorOut = vec4(1.0, 1.0, 1.0, sum);\n"
"}\n"; "}\n";
@ -291,12 +293,12 @@ CPhazonSuitFilter::Initialize(boo::GLDataFactory::Context& ctx)
{ {
const char* uniNames[] = {"PhazonSuitUniform"}; const char* uniNames[] = {"PhazonSuitUniform"};
const char* texNames[] = {"screenTex", "indTex", "maskTex", "maskTexBlur"}; const char* texNames[] = {"screenTex", "indTex", "maskTex", "maskTexBlur"};
s_IndPipeline = ctx.newShaderPipeline(VS, IndFS, 4, texNames, 1, uniNames, boo::BlendFactor::One, s_IndPipeline = ctx.newShaderPipeline(VS, IndFS, 4, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
texNames[1] = "maskTex"; texNames[1] = "maskTex";
texNames[2] = "maskTexBlur"; texNames[2] = "maskTexBlur";
s_Pipeline = ctx.newShaderPipeline(VS, FS, 3, texNames, 1, uniNames, boo::BlendFactor::One, s_Pipeline = ctx.newShaderPipeline(VS, FS, 3, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
uniNames[0] = "PhazonSuitBlurUniform"; uniNames[0] = "PhazonSuitBlurUniform";
@ -333,10 +335,10 @@ CPhazonSuitFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
{nullptr, nullptr, boo::VertexSemantic::UV4} {nullptr, nullptr, boo::VertexSemantic::UV4}
}; };
s_BlurVtxFmt = ctx.newVertexFormat(2, BlurVtxVmt); s_BlurVtxFmt = ctx.newVertexFormat(2, BlurVtxVmt);
s_IndPipeline = ctx.newShaderPipeline(VS, IndFS, s_VtxFmt, boo::BlendFactor::One, s_IndPipeline = ctx.newShaderPipeline(VS, IndFS, s_VtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, boo::BlendFactor::One, s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
s_BlurPipeline = ctx.newShaderPipeline(BlurVS, BlurFS, s_BlurVtxFmt, boo::BlendFactor::One, s_BlurPipeline = ctx.newShaderPipeline(BlurVS, BlurFS, s_BlurVtxFmt, boo::BlendFactor::One,

View File

@ -35,8 +35,10 @@ static const char* VS =
" vtf.color = color;\n" " vtf.color = color;\n"
" vtf.indScaleOff = indScaleOff;\n" " vtf.indScaleOff = indScaleOff;\n"
" vtf.screenUv = v.screenUvIn.xy;\n" " vtf.screenUv = v.screenUvIn.xy;\n"
" vtf.screenUv.y = 1.0 - vtf.screenUv.y;\n"
" vtf.indUv = v.indUvIn.xy;\n" " vtf.indUv = v.indUvIn.xy;\n"
" vtf.maskUv = v.maskUvIn.xy;\n" " vtf.maskUv = v.maskUvIn.xy;\n"
" vtf.maskUv.y = 1.0 - vtf.maskUv.y;\n"
" vtf.position = float4(v.posIn.xyz, 1.0);\n" " vtf.position = float4(v.posIn.xyz, 1.0);\n"
" return vtf;\n" " return vtf;\n"
"}\n"; "}\n";
@ -59,10 +61,10 @@ static const char* IndFS =
"Texture2D maskTexBlur : register(t3);\n" "Texture2D maskTexBlur : register(t3);\n"
"float4 main(in VertToFrag vtf) : SV_Target0\n" "float4 main(in VertToFrag vtf) : SV_Target0\n"
"{\n" "{\n"
" float2 indUv = (indTex.Sample(samp, vtf.indUv).rg - float2(0.5, 0.5)) * \n" " float2 indUv = (indTex.Sample(samp, vtf.indUv).ra - float2(0.5, 0.5)) * \n"
" vtf.indScaleOff.xy + vtf.indScaleOff.zw;\n" " vtf.indScaleOff.xy + vtf.indScaleOff.zw;\n"
" return vtf.color * screenTex.Sample(samp, indUv + vtf.screenUv) * \n" " float maskBlurAlpha = saturate((maskTexBlur.Sample(samp, vtf.maskUv).a - maskTex.Sample(samp, vtf.maskUv).a) * 2.0);\n"
" (maskTexBlur.Sample(samp, vtf.maskUv).a - maskTex.Sample(samp, vtf.maskUv).a);\n" " return float4((vtf.color * screenTex.Sample(samp, indUv + vtf.screenUv) * maskBlurAlpha).rgb, vtf.color.a);\n"
"}\n"; "}\n";
static const char* FS = static const char* FS =
@ -76,14 +78,14 @@ static const char* FS =
" float2 maskUv : UV2;\n" " float2 maskUv : UV2;\n"
"};\n" "};\n"
"\n" "\n"
"SamplerState samp : register(s0);\n" "SamplerState samp : register(s2);\n"
"Texture2D screenTex : register(t0);\n" "Texture2D screenTex : register(t0);\n"
"Texture2D maskTex : register(t1);\n" "Texture2D maskTex : register(t1);\n"
"Texture2D maskTexBlur : register(t2);\n" "Texture2D maskTexBlur : register(t2);\n"
"float4 main(in VertToFrag vtf) : SV_Target0\n" "float4 main(in VertToFrag vtf) : SV_Target0\n"
"{\n" "{\n"
" return vtf.color * screenTex.Sample(samp, vtf.screenUv) * \n" " float maskBlurAlpha = saturate((maskTexBlur.Sample(samp, vtf.maskUv).a - maskTex.Sample(samp, vtf.maskUv).a) * 2.0);\n"
" (maskTexBlur.Sample(samp, vtf.maskUv).a - maskTex.Sample(samp, vtf.maskUv).a);\n" " return float4((vtf.color * screenTex.Sample(samp, vtf.screenUv) * maskBlurAlpha).rgb, vtf.color.a);\n"
"}\n"; "}\n";
static const char* BlurVS = static const char* BlurVS =
@ -108,6 +110,7 @@ static const char* BlurVS =
"{\n" "{\n"
" VertToFrag vtf;\n" " VertToFrag vtf;\n"
" vtf.uv = v.uvIn.xy;\n" " vtf.uv = v.uvIn.xy;\n"
" vtf.uv.y = 1.0 - vtf.uv.y;\n"
" vtf.blurDir = blurDir.xy;\n" " vtf.blurDir = blurDir.xy;\n"
" vtf.position = float4(v.posIn.xyz, 1.0);\n" " vtf.position = float4(v.posIn.xyz, 1.0);\n"
" return vtf;\n" " return vtf;\n"
@ -121,7 +124,7 @@ static const char* BlurFS =
" float2 blurDir : BLURDIR;\n" " float2 blurDir : BLURDIR;\n"
"};\n" "};\n"
"\n" "\n"
"SamplerState samp : register(s0);\n" "SamplerState samp : register(s2);\n"
"Texture2D maskTex : register(t0);\n" "Texture2D maskTex : register(t0);\n"
"float4 main(in VertToFrag vtf) : SV_Target0\n" "float4 main(in VertToFrag vtf) : SV_Target0\n"
"{\n" "{\n"
@ -137,10 +140,10 @@ static const char* BlurFS =
"\n" "\n"
" sum += maskTex.Sample(samp, vtf.uv).a * 0.2270270270;\n" " sum += maskTex.Sample(samp, vtf.uv).a * 0.2270270270;\n"
"\n" "\n"
" sum += maskTex.Sample(samp, vtf.uv - 1.0 * vtf.blurDir).a * 0.1945945946;\n" " sum += maskTex.Sample(samp, vtf.uv + 1.0 * vtf.blurDir).a * 0.1945945946;\n"
" sum += maskTex.Sample(samp, vtf.uv - 2.0 * vtf.blurDir).a * 0.1216216216;\n" " sum += maskTex.Sample(samp, vtf.uv + 2.0 * vtf.blurDir).a * 0.1216216216;\n"
" sum += maskTex.Sample(samp, vtf.uv - 3.0 * vtf.blurDir).a * 0.0540540541;\n" " sum += maskTex.Sample(samp, vtf.uv + 3.0 * vtf.blurDir).a * 0.0540540541;\n"
" sum += maskTex.Sample(samp, vtf.uv - 4.0 * vtf.blurDir).a * 0.0162162162;\n" " sum += maskTex.Sample(samp, vtf.uv + 4.0 * vtf.blurDir).a * 0.0162162162;\n"
"\n" "\n"
" return float4(1.0, 1.0, 1.0, sum);\n" " return float4(1.0, 1.0, 1.0, sum);\n"
"}\n"; "}\n";

View File

@ -38,8 +38,10 @@ static const char* VS =
" vtf.color = psu.color;\n" " vtf.color = psu.color;\n"
" vtf.indScaleOff = psu.indScaleOff;\n" " vtf.indScaleOff = psu.indScaleOff;\n"
" vtf.screenUv = v.screenUvIn.xy;\n" " vtf.screenUv = v.screenUvIn.xy;\n"
" vtf.screenUv.y = 1.0 - vtf.screenUv.y;\n"
" vtf.indUv = v.indUvIn.xy;\n" " vtf.indUv = v.indUvIn.xy;\n"
" vtf.maskUv = v.maskUvIn.xy;\n" " vtf.maskUv = v.maskUvIn.xy;\n"
" vtf.maskUv.y = 1.0 - vtf.maskUv.y;\n"
" vtf.position = float4(v.posIn.xyz, 1.0);\n" " vtf.position = float4(v.posIn.xyz, 1.0);\n"
" return vtf;\n" " return vtf;\n"
"}\n"; "}\n";
@ -64,16 +66,16 @@ static const char* IndFS =
" texture2d<float> maskTex [[ texture(2) ]],\n" " texture2d<float> maskTex [[ texture(2) ]],\n"
" texture2d<float> maskTexBlur [[ texture(3) ]])\n" " texture2d<float> maskTexBlur [[ texture(3) ]])\n"
"{\n" "{\n"
" float2 indUv = (indTex.sample(samp, vtf.indUv).rg - float2(0.5, 0.5)) * \n" " float2 indUv = (indTex.sample(samp, vtf.indUv).ra - float2(0.5, 0.5)) * \n"
" vtf.indScaleOff.xy + vtf.indScaleOff.zw;\n" " vtf.indScaleOff.xy + vtf.indScaleOff.zw;\n"
" return vtf.color * screenTex.sample(samp, indUv + vtf.screenUv) * \n" " float maskBlurAlpha = saturate((maskTexBlur.sample(samp, vtf.maskUv).a - maskTex.sample(samp, vtf.maskUv).a) * 2.0);\n"
" (maskTexBlur.sample(samp, vtf.maskUv).a - maskTex.sample(samp, vtf.maskUv).a);\n" " return float4((vtf.color * screenTex.sample(samp, indUv + vtf.screenUv) * maskBlurAlpha).rgb, vtf.color.a);\n"
"}\n"; "}\n";
static const char* FS = static const char* FS =
"#include <metal_stdlib>\n" "#include <metal_stdlib>\n"
"using namespace metal;\n" "using namespace metal;\n"
"constexpr sampler samp(address::repeat, filter::linear);\n" "constexpr sampler samp(address::clamp_to_edge, filter::linear);\n"
"struct VertToFrag\n" "struct VertToFrag\n"
"{\n" "{\n"
" float4 color;\n" " float4 color;\n"
@ -88,8 +90,8 @@ static const char* FS =
" texture2d<float> maskTex [[ texture(1) ]],\n" " texture2d<float> maskTex [[ texture(1) ]],\n"
" texture2d<float> maskTexBlur [[ texture(2) ]])\n" " texture2d<float> maskTexBlur [[ texture(2) ]])\n"
"{\n" "{\n"
" return vtf.color * screenTex.sample(samp, vtf.screenUv) * \n" " float maskBlurAlpha = saturate((maskTexBlur.sample(samp, vtf.maskUv).a - maskTex.sample(samp, vtf.maskUv).a) * 2.0);\n"
" (maskTexBlur.sample(samp, vtf.maskUv).a - maskTex.sample(samp, vtf.maskUv).a);\n" " return float4((vtf.color * screenTex.sample(samp, vtf.screenUv) * maskBlurAlpha).rgb, vtf.color.a);\n"
"}\n"; "}\n";
static const char* BlurVS = static const char* BlurVS =
@ -117,6 +119,7 @@ static const char* BlurVS =
"{\n" "{\n"
" VertToFrag vtf;\n" " VertToFrag vtf;\n"
" vtf.uv = v.uvIn.xy;\n" " vtf.uv = v.uvIn.xy;\n"
" vtf.uv.y = 1.0 - vtf.uv.y;\n"
" vtf.blurDir = psu.blurDir.xy;\n" " vtf.blurDir = psu.blurDir.xy;\n"
" vtf.position = float4(v.posIn.xyz, 1.0);\n" " vtf.position = float4(v.posIn.xyz, 1.0);\n"
" return vtf;\n" " return vtf;\n"
@ -125,7 +128,7 @@ static const char* BlurVS =
static const char* BlurFS = static const char* BlurFS =
"#include <metal_stdlib>\n" "#include <metal_stdlib>\n"
"using namespace metal;\n" "using namespace metal;\n"
"constexpr sampler samp(address::repeat, filter::linear);\n" "constexpr sampler samp(address::clamp_to_edge, filter::linear);\n"
"struct VertToFrag\n" "struct VertToFrag\n"
"{\n" "{\n"
" float4 position [[ position ]];\n" " float4 position [[ position ]];\n"
@ -148,10 +151,10 @@ static const char* BlurFS =
"\n" "\n"
" sum += maskTex.sample(samp, vtf.uv).a * 0.2270270270;\n" " sum += maskTex.sample(samp, vtf.uv).a * 0.2270270270;\n"
"\n" "\n"
" sum += maskTex.sample(samp, vtf.uv - 1.0 * vtf.blurDir).a * 0.1945945946;\n" " sum += maskTex.sample(samp, vtf.uv + 1.0 * vtf.blurDir).a * 0.1945945946;\n"
" sum += maskTex.sample(samp, vtf.uv - 2.0 * vtf.blurDir).a * 0.1216216216;\n" " sum += maskTex.sample(samp, vtf.uv + 2.0 * vtf.blurDir).a * 0.1216216216;\n"
" sum += maskTex.sample(samp, vtf.uv - 3.0 * vtf.blurDir).a * 0.0540540541;\n" " sum += maskTex.sample(samp, vtf.uv + 3.0 * vtf.blurDir).a * 0.0540540541;\n"
" sum += maskTex.sample(samp, vtf.uv - 4.0 * vtf.blurDir).a * 0.0162162162;\n" " sum += maskTex.sample(samp, vtf.uv + 4.0 * vtf.blurDir).a * 0.0162162162;\n"
"\n" "\n"
" return float4(1.0, 1.0, 1.0, sum);\n" " return float4(1.0, 1.0, 1.0, sum);\n"
"}\n"; "}\n";
@ -238,11 +241,11 @@ CPhazonSuitFilter::Initialize(boo::MetalDataFactory::Context& ctx)
}; };
s_BlurVtxFmt = ctx.newVertexFormat(2, BlurVtxVmt); s_BlurVtxFmt = ctx.newVertexFormat(2, BlurVtxVmt);
s_IndPipeline = ctx.newShaderPipeline(VS, IndFS, nullptr, nullptr, s_VtxFmt, s_IndPipeline = ctx.newShaderPipeline(VS, IndFS, nullptr, nullptr, s_VtxFmt,
CGraphics::g_ViewportSamples, boo::BlendFactor::One, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, s_VtxFmt, s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, s_VtxFmt,
CGraphics::g_ViewportSamples, boo::BlendFactor::One, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
s_BlurPipeline = ctx.newShaderPipeline(BlurVS, BlurFS, nullptr, nullptr, s_BlurVtxFmt, s_BlurPipeline = ctx.newShaderPipeline(BlurVS, BlurFS, nullptr, nullptr, s_BlurVtxFmt,

View File

@ -96,15 +96,15 @@ CScanLinesFilter::Initialize(boo::MetalDataFactory::Context& ctx)
s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, true, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
s_AddPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, s_AddPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, true, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
s_MultPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, s_MultPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::Zero, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::Zero,
boo::BlendFactor::SrcColor, boo::Primitive::TriStrips, boo::BlendFactor::SrcColor, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, true, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
return new CScanLinesFilterMetalDataBindingFactory; return new CScanLinesFilterMetalDataBindingFactory;
} }

View File

@ -86,7 +86,7 @@ TShader<CSpaceWarpFilter>::IDataBindingFactory* CSpaceWarpFilter::Initialize(boo
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::One, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::One,
boo::BlendFactor::Zero, boo::Primitive::TriStrips, boo::BlendFactor::Zero, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, true, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
return new CSpaceWarpFilterMetalDataBindingFactory; return new CSpaceWarpFilterMetalDataBindingFactory;
} }

View File

@ -7,10 +7,12 @@ namespace urde
boo::ObjToken<boo::IVertexFormat> CTextSupportShader::s_TextVtxFmt; boo::ObjToken<boo::IVertexFormat> CTextSupportShader::s_TextVtxFmt;
boo::ObjToken<boo::IShaderPipeline> CTextSupportShader::s_TextAlphaPipeline; boo::ObjToken<boo::IShaderPipeline> CTextSupportShader::s_TextAlphaPipeline;
boo::ObjToken<boo::IShaderPipeline> CTextSupportShader::s_TextAddPipeline; boo::ObjToken<boo::IShaderPipeline> CTextSupportShader::s_TextAddPipeline;
boo::ObjToken<boo::IShaderPipeline> CTextSupportShader::s_TextAddOverdrawPipeline;
boo::ObjToken<boo::IVertexFormat> CTextSupportShader::s_ImageVtxFmt; boo::ObjToken<boo::IVertexFormat> CTextSupportShader::s_ImageVtxFmt;
boo::ObjToken<boo::IShaderPipeline> CTextSupportShader::s_ImageAlphaPipeline; boo::ObjToken<boo::IShaderPipeline> CTextSupportShader::s_ImageAlphaPipeline;
boo::ObjToken<boo::IShaderPipeline> CTextSupportShader::s_ImageAddPipeline; boo::ObjToken<boo::IShaderPipeline> CTextSupportShader::s_ImageAddPipeline;
boo::ObjToken<boo::IShaderPipeline> CTextSupportShader::s_ImageAddOverdrawPipeline;
hecl::VertexBufferPool<CTextSupportShader::CharacterInstance> CTextSupportShader::s_CharInsts; hecl::VertexBufferPool<CTextSupportShader::CharacterInstance> CTextSupportShader::s_CharInsts;
hecl::VertexBufferPool<CTextSupportShader::ImageInstance> CTextSupportShader::s_ImgInsts; hecl::VertexBufferPool<CTextSupportShader::ImageInstance> CTextSupportShader::s_ImgInsts;
@ -64,9 +66,11 @@ void CTextSupportShader::Shutdown()
s_TextVtxFmt.reset(); s_TextVtxFmt.reset();
s_TextAlphaPipeline.reset(); s_TextAlphaPipeline.reset();
s_TextAddPipeline.reset(); s_TextAddPipeline.reset();
s_TextAddOverdrawPipeline.reset();
s_ImageVtxFmt.reset(); s_ImageVtxFmt.reset();
s_ImageAlphaPipeline.reset(); s_ImageAlphaPipeline.reset();
s_ImageAddPipeline.reset(); s_ImageAddPipeline.reset();
s_ImageAddOverdrawPipeline.reset();
s_CharInsts.doDestroy(); s_CharInsts.doDestroy();
s_ImgInsts.doDestroy(); s_ImgInsts.doDestroy();

View File

@ -23,10 +23,12 @@ class CTextSupportShader
static boo::ObjToken<boo::IVertexFormat> s_TextVtxFmt; static boo::ObjToken<boo::IVertexFormat> s_TextVtxFmt;
static boo::ObjToken<boo::IShaderPipeline> s_TextAlphaPipeline; static boo::ObjToken<boo::IShaderPipeline> s_TextAlphaPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_TextAddPipeline; static boo::ObjToken<boo::IShaderPipeline> s_TextAddPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_TextAddOverdrawPipeline;
static boo::ObjToken<boo::IVertexFormat> s_ImageVtxFmt; static boo::ObjToken<boo::IVertexFormat> s_ImageVtxFmt;
static boo::ObjToken<boo::IShaderPipeline> s_ImageAlphaPipeline; static boo::ObjToken<boo::IShaderPipeline> s_ImageAlphaPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_ImageAddPipeline; static boo::ObjToken<boo::IShaderPipeline> s_ImageAddPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_ImageAddOverdrawPipeline;
struct Uniform struct Uniform
{ {
@ -67,9 +69,9 @@ public:
case CGuiWidget::EGuiModelDrawFlags::Shadeless: case CGuiWidget::EGuiModelDrawFlags::Shadeless:
case CGuiWidget::EGuiModelDrawFlags::Opaque: case CGuiWidget::EGuiModelDrawFlags::Opaque:
case CGuiWidget::EGuiModelDrawFlags::Alpha: case CGuiWidget::EGuiModelDrawFlags::Alpha:
case CGuiWidget::EGuiModelDrawFlags::AlphaAdditiveOverdraw:
return s_TextAlphaPipeline; return s_TextAlphaPipeline;
case CGuiWidget::EGuiModelDrawFlags::Additive: case CGuiWidget::EGuiModelDrawFlags::Additive:
case CGuiWidget::EGuiModelDrawFlags::AlphaAdditiveOverdraw:
return s_TextAddPipeline; return s_TextAddPipeline;
default: default:
return {}; return {};
@ -83,15 +85,25 @@ public:
case CGuiWidget::EGuiModelDrawFlags::Shadeless: case CGuiWidget::EGuiModelDrawFlags::Shadeless:
case CGuiWidget::EGuiModelDrawFlags::Opaque: case CGuiWidget::EGuiModelDrawFlags::Opaque:
case CGuiWidget::EGuiModelDrawFlags::Alpha: case CGuiWidget::EGuiModelDrawFlags::Alpha:
case CGuiWidget::EGuiModelDrawFlags::AlphaAdditiveOverdraw:
return s_ImageAlphaPipeline; return s_ImageAlphaPipeline;
case CGuiWidget::EGuiModelDrawFlags::Additive: case CGuiWidget::EGuiModelDrawFlags::Additive:
case CGuiWidget::EGuiModelDrawFlags::AlphaAdditiveOverdraw:
return s_ImageAddPipeline; return s_ImageAddPipeline;
default: default:
return {}; return {};
} }
} }
static boo::ObjToken<boo::IShaderPipeline> GetTextAdditiveOverdrawPipeline()
{
return s_TextAddOverdrawPipeline;
}
static boo::ObjToken<boo::IShaderPipeline> GetImageAdditiveOverdrawPipeline()
{
return s_ImageAddOverdrawPipeline;
}
static void UpdateBuffers() static void UpdateBuffers()
{ {
s_CharInsts.updateBuffers(); s_CharInsts.updateBuffers();

View File

@ -118,6 +118,9 @@ CTextSupportShader::Initialize(boo::GLDataFactory::Context& ctx)
s_TextAddPipeline = ctx.newShaderPipeline(TextVS, TextFS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, s_TextAddPipeline = ctx.newShaderPipeline(TextVS, TextFS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::LEqual, false, true, false, boo::CullMode::None); boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
s_TextAddOverdrawPipeline = ctx.newShaderPipeline(TextVS, TextFS, 1, texNames, 1, uniNames, boo::BlendFactor::One,
boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
s_ImageAlphaPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, s_ImageAlphaPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
@ -125,6 +128,9 @@ CTextSupportShader::Initialize(boo::GLDataFactory::Context& ctx)
s_ImageAddPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, s_ImageAddPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::LEqual, false, true, false, boo::CullMode::None); boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
s_ImageAddOverdrawPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, 1, texNames, 1, uniNames, boo::BlendFactor::One,
boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
return nullptr; return nullptr;
} }
@ -134,8 +140,10 @@ void CTextSupportShader::Shutdown<boo::GLDataFactory>()
{ {
s_TextAlphaPipeline.reset(); s_TextAlphaPipeline.reset();
s_TextAddPipeline.reset(); s_TextAddPipeline.reset();
s_TextAddOverdrawPipeline.reset();
s_ImageAlphaPipeline.reset(); s_ImageAlphaPipeline.reset();
s_ImageAddPipeline.reset(); s_ImageAddPipeline.reset();
s_ImageAddOverdrawPipeline.reset();
} }
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
@ -163,6 +171,9 @@ CTextSupportShader::Initialize(boo::VulkanDataFactory::Context& ctx)
s_TextAddPipeline = ctx.newShaderPipeline(TextVS, TextFS, s_TextVtxFmt, boo::BlendFactor::SrcAlpha, s_TextAddPipeline = ctx.newShaderPipeline(TextVS, TextFS, s_TextVtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::LEqual, false, true, false, boo::CullMode::None); boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
s_TextAddOverdrawPipeline = ctx.newShaderPipeline(TextVS, TextFS, s_TextVtxFmt, boo::BlendFactor::One,
boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
boo::VertexElementDescriptor ImageVtxVmt[] = boo::VertexElementDescriptor ImageVtxVmt[] =
{ {
@ -183,6 +194,9 @@ CTextSupportShader::Initialize(boo::VulkanDataFactory::Context& ctx)
s_ImageAddPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, s_ImageVtxFmt, boo::BlendFactor::SrcAlpha, s_ImageAddPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, s_ImageVtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::LEqual, false, true, false, boo::CullMode::None); boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
s_ImageAddOverdrawPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, s_ImageVtxFmt, boo::BlendFactor::One,
boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
return nullptr; return nullptr;
} }
@ -193,9 +207,11 @@ void CTextSupportShader::Shutdown<boo::VulkanDataFactory>()
s_TextVtxFmt.reset(); s_TextVtxFmt.reset();
s_TextAlphaPipeline.reset(); s_TextAlphaPipeline.reset();
s_TextAddPipeline.reset(); s_TextAddPipeline.reset();
s_TextAddOverdrawPipeline.reset();
s_ImageVtxFmt.reset(); s_ImageVtxFmt.reset();
s_ImageAlphaPipeline.reset(); s_ImageAlphaPipeline.reset();
s_ImageAddPipeline.reset(); s_ImageAddPipeline.reset();
s_ImageAddOverdrawPipeline.reset();
} }
#endif #endif

View File

@ -134,6 +134,10 @@ CTextSupportShader::Initialize(boo::ID3DDataFactory::Context& ctx)
s_TextVtxFmt, boo::BlendFactor::SrcAlpha, s_TextVtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::LEqual, false, true, false, boo::CullMode::None); boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
s_TextAddOverdrawPipeline = ctx.newShaderPipeline(TextVS, TextFS, nullptr, nullptr, nullptr,
s_TextVtxFmt, boo::BlendFactor::One,
boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
boo::VertexElementDescriptor ImageVtxVmt[] = boo::VertexElementDescriptor ImageVtxVmt[] =
{ {
@ -156,6 +160,10 @@ CTextSupportShader::Initialize(boo::ID3DDataFactory::Context& ctx)
s_ImageVtxFmt, boo::BlendFactor::SrcAlpha, s_ImageVtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::LEqual, false, true, false, boo::CullMode::None); boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
s_ImageAddOverdrawPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, nullptr, nullptr, nullptr,
s_ImageVtxFmt, boo::BlendFactor::One,
boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
return nullptr; return nullptr;
} }
@ -166,8 +174,10 @@ void CTextSupportShader::Shutdown<boo::ID3DDataFactory>()
s_TextVtxFmt.reset(); s_TextVtxFmt.reset();
s_TextAlphaPipeline.reset(); s_TextAlphaPipeline.reset();
s_TextAddPipeline.reset(); s_TextAddPipeline.reset();
s_TextAddOverdrawPipeline.reset();
s_ImageVtxFmt.reset(); s_ImageVtxFmt.reset();
s_ImageAlphaPipeline.reset(); s_ImageAlphaPipeline.reset();
s_ImageAddPipeline.reset(); s_ImageAddPipeline.reset();
s_ImageAddOverdrawPipeline.reset();
} }
} }

View File

@ -141,11 +141,15 @@ CTextSupportShader::Initialize(boo::MetalDataFactory::Context& ctx)
s_TextAlphaPipeline = ctx.newShaderPipeline(TextVS, TextFS, nullptr, nullptr, s_TextAlphaPipeline = ctx.newShaderPipeline(TextVS, TextFS, nullptr, nullptr,
s_TextVtxFmt, CGraphics::g_ViewportSamples, s_TextVtxFmt, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::LEqual, false, true, true, boo::CullMode::None); boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
s_TextAddPipeline = ctx.newShaderPipeline(TextVS, TextFS, nullptr, nullptr, s_TextAddPipeline = ctx.newShaderPipeline(TextVS, TextFS, nullptr, nullptr,
s_TextVtxFmt, CGraphics::g_ViewportSamples, s_TextVtxFmt, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::Primitive::TriStrips, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::LEqual, false, true, true, boo::CullMode::None); boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
s_TextAddOverdrawPipeline = ctx.newShaderPipeline(TextVS, TextFS, nullptr, nullptr,
s_TextVtxFmt, CGraphics::g_ViewportSamples,
boo::BlendFactor::One, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
boo::VertexElementDescriptor ImageVtxVmt[] = boo::VertexElementDescriptor ImageVtxVmt[] =
{ {
@ -163,11 +167,15 @@ CTextSupportShader::Initialize(boo::MetalDataFactory::Context& ctx)
s_ImageAlphaPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, nullptr, nullptr, s_ImageAlphaPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, nullptr, nullptr,
s_ImageVtxFmt, CGraphics::g_ViewportSamples, s_ImageVtxFmt, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::LEqual, false, true, true, boo::CullMode::None); boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
s_ImageAddPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, nullptr, nullptr, s_ImageAddPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, nullptr, nullptr,
s_ImageVtxFmt, CGraphics::g_ViewportSamples, s_ImageVtxFmt, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::Primitive::TriStrips, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::LEqual, false, true, true, boo::CullMode::None); boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
s_ImageAddOverdrawPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, nullptr, nullptr,
s_ImageVtxFmt, CGraphics::g_ViewportSamples,
boo::BlendFactor::One, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
return nullptr; return nullptr;
} }
@ -178,9 +186,11 @@ void CTextSupportShader::Shutdown<boo::MetalDataFactory>()
s_TextVtxFmt.reset(); s_TextVtxFmt.reset();
s_TextAlphaPipeline.reset(); s_TextAlphaPipeline.reset();
s_TextAddPipeline.reset(); s_TextAddPipeline.reset();
s_TextAddOverdrawPipeline.reset();
s_ImageVtxFmt.reset(); s_ImageVtxFmt.reset();
s_ImageAlphaPipeline.reset(); s_ImageAlphaPipeline.reset();
s_ImageAddPipeline.reset(); s_ImageAddPipeline.reset();
s_ImageAddOverdrawPipeline.reset();
} }
} }

View File

@ -114,7 +114,7 @@ TShader<CThermalColdFilter>::IDataBindingFactory* CThermalColdFilter::Initialize
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::One, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::One,
boo::BlendFactor::Zero, boo::Primitive::TriStrips, boo::BlendFactor::Zero, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, true, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
return new CThermalColdFilterMetalDataBindingFactory; return new CThermalColdFilterMetalDataBindingFactory;
} }

View File

@ -88,7 +88,7 @@ TShader<CThermalHotFilter>::IDataBindingFactory* CThermalHotFilter::Initialize(b
s_VtxFmt, CGraphics::g_ViewportSamples, s_VtxFmt, CGraphics::g_ViewportSamples,
boo::BlendFactor::DstAlpha, boo::BlendFactor::InvDstAlpha, boo::BlendFactor::DstAlpha, boo::BlendFactor::InvDstAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, false, boo::Primitive::TriStrips, boo::ZTest::None, false,
true, true, boo::CullMode::None); true, false, boo::CullMode::None);
return new CThermalHotFilterMetalDataBindingFactory; return new CThermalHotFilterMetalDataBindingFactory;
} }

View File

@ -102,7 +102,7 @@ TShader<CXRayBlurFilter>::IDataBindingFactory* CXRayBlurFilter::Initialize(boo::
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::One, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::One,
boo::BlendFactor::Zero, boo::Primitive::TriStrips, boo::ZTest::None, false, boo::BlendFactor::Zero, boo::Primitive::TriStrips, boo::ZTest::None, false,
true, true, boo::CullMode::None); true, false, boo::CullMode::None);
return new CXRayBlurFilterMetalDataBindingFactory; return new CXRayBlurFilterMetalDataBindingFactory;
} }

View File

@ -117,9 +117,10 @@ void CHudEnergyInterface::Update(float dt, float energyLowPulse)
zeus::CColor emptyColor = x1c_27_energyLow ? g_tweakGuiColors->GetEnergyBarEmptyLowEnergy() : barColors.empty; zeus::CColor emptyColor = x1c_27_energyLow ? g_tweakGuiColors->GetEnergyBarEmptyLowEnergy() : barColors.empty;
zeus::CColor filledColor = x1c_27_energyLow ? g_tweakGuiColors->GetEnergyBarFilledLowEnergy() : barColors.filled; zeus::CColor filledColor = x1c_27_energyLow ? g_tweakGuiColors->GetEnergyBarFilledLowEnergy() : barColors.filled;
zeus::CColor shadowColor = x1c_27_energyLow ? g_tweakGuiColors->GetEnergyBarShadowLowEnergy() : barColors.shadow; zeus::CColor shadowColor = x1c_27_energyLow ? g_tweakGuiColors->GetEnergyBarShadowLowEnergy() : barColors.shadow;
x2c_energybart01_energybar->SetFilledColor(zeus::CColor::lerp( zeus::CColor useFillColor = zeus::CColor::lerp(filledColor, g_tweakGuiColors->GetEnergyBarFlashColor(), x8_flashMag);
zeus::CColor::lerp(filledColor, g_tweakGuiColors->GetEnergyBarFlashColor(), x8_flashMag), if (x1c_27_energyLow)
zeus::CColor(1.f, 0.8f, 0.4f, 1.f), energyLowPulse)); useFillColor = zeus::CColor::lerp(useFillColor, zeus::CColor(1.f, 0.8f, 0.4f, 1.f), energyLowPulse);
x2c_energybart01_energybar->SetFilledColor(useFillColor);
x2c_energybart01_energybar->SetShadowColor(shadowColor); x2c_energybart01_energybar->SetShadowColor(shadowColor);
x2c_energybart01_energybar->SetEmptyColor(emptyColor); x2c_energybart01_energybar->SetEmptyColor(emptyColor);
} }

View File

@ -58,6 +58,12 @@ void CTextRenderBuffer::CommitResources()
{ {
m_uniBuf = CTextSupportShader::s_Uniforms.allocateBlock(CGraphics::g_BooFactory); m_uniBuf = CTextSupportShader::s_Uniforms.allocateBlock(CGraphics::g_BooFactory);
auto uBufInfo = m_uniBuf.getBufferInfo(); auto uBufInfo = m_uniBuf.getBufferInfo();
decltype(uBufInfo) uBufInfo2;
if (m_drawFlags == CGuiWidget::EGuiModelDrawFlags::AlphaAdditiveOverdraw)
{
m_uniBuf2 = CTextSupportShader::s_Uniforms.allocateBlock(CGraphics::g_BooFactory);
uBufInfo2 = m_uniBuf2.getBufferInfo();
}
for (BooFontCharacters& chs : m_fontCharacters) for (BooFontCharacters& chs : m_fontCharacters)
{ {
@ -94,6 +100,16 @@ void CTextRenderBuffer::CommitResources()
vFmt, nullptr, iBufInfo.first.get(), nullptr, vFmt, nullptr, iBufInfo.first.get(), nullptr,
1, uniforms, unistages, unioffs, 1, uniforms, unistages, unioffs,
unisizes, 1, texs, nullptr, nullptr, 0, iBufInfo.second); unisizes, 1, texs, nullptr, nullptr, 0, iBufInfo.second);
if (m_drawFlags == CGuiWidget::EGuiModelDrawFlags::AlphaAdditiveOverdraw)
{
uniforms[0] = uBufInfo2.first.get();
unioffs[0] = size_t(uBufInfo2.second);
chs.m_dataBinding2 = ctx.newShaderDataBinding(CTextSupportShader::GetTextAdditiveOverdrawPipeline(),
vFmt, nullptr, iBufInfo.first.get(), nullptr,
1, uniforms, unistages, unioffs,
unisizes, 1, texs, nullptr, nullptr, 0, iBufInfo.second);
}
} }
for (BooImage& img : m_images) for (BooImage& img : m_images)
@ -134,6 +150,21 @@ void CTextRenderBuffer::CommitResources()
1, uniforms, unistages, unioffs, 1, uniforms, unistages, unioffs,
unisizes, 1, texs, nullptr, nullptr, 0, iBufInfo.second)); unisizes, 1, texs, nullptr, nullptr, 0, iBufInfo.second));
} }
if (m_drawFlags == CGuiWidget::EGuiModelDrawFlags::AlphaAdditiveOverdraw)
{
uniforms[0] = uBufInfo2.first.get();
unioffs[0] = size_t(uBufInfo2.second);
img.m_dataBinding2.reserve(img.m_imageDef.x4_texs.size());
for (TToken<CTexture>& tex : img.m_imageDef.x4_texs)
{
boo::ObjToken<boo::ITexture> texs[] = {tex->GetBooTexture()};
img.m_dataBinding2.push_back(ctx.newShaderDataBinding(CTextSupportShader::GetImageAdditiveOverdrawPipeline(),
vFmt, nullptr, iBufInfo.first.get(), nullptr,
1, uniforms, unistages, unioffs,
unisizes, 1, texs, nullptr, nullptr, 0, iBufInfo.second));
}
}
} }
return true; return true;
}); });
@ -166,6 +197,13 @@ void CTextRenderBuffer::Render(const zeus::CColor& col, float time) const
const_cast<CTextRenderBuffer*>(this)->m_uniBuf.access() = const_cast<CTextRenderBuffer*>(this)->m_uniBuf.access() =
CTextSupportShader::Uniform{mat, col}; CTextSupportShader::Uniform{mat, col};
if (m_drawFlags == CGuiWidget::EGuiModelDrawFlags::AlphaAdditiveOverdraw)
{
zeus::CColor colSq = col * col;
colSq.a = col.a;
const_cast<CTextRenderBuffer*>(this)->m_uniBuf2.access() =
CTextSupportShader::Uniform{mat, colSq};
}
for (const BooFontCharacters& chs : m_fontCharacters) for (const BooFontCharacters& chs : m_fontCharacters)
{ {
@ -180,6 +218,11 @@ void CTextRenderBuffer::Render(const zeus::CColor& col, float time) const
} }
CGraphics::SetShaderDataBinding(chs.m_dataBinding); CGraphics::SetShaderDataBinding(chs.m_dataBinding);
CGraphics::DrawInstances(0, 4, chs.m_charData.size()); CGraphics::DrawInstances(0, 4, chs.m_charData.size());
if (m_drawFlags == CGuiWidget::EGuiModelDrawFlags::AlphaAdditiveOverdraw)
{
CGraphics::SetShaderDataBinding(chs.m_dataBinding2);
CGraphics::DrawInstances(0, 4, chs.m_charData.size());
}
} }
} }
@ -193,6 +236,11 @@ void CTextRenderBuffer::Render(const zeus::CColor& col, float time) const
int idx = int(img.m_imageDef.x0_fps * time) % img.m_dataBinding.size(); int idx = int(img.m_imageDef.x0_fps * time) % img.m_dataBinding.size();
CGraphics::SetShaderDataBinding(img.m_dataBinding[idx]); CGraphics::SetShaderDataBinding(img.m_dataBinding[idx]);
CGraphics::DrawInstances(0, 4, 1); CGraphics::DrawInstances(0, 4, 1);
if (m_drawFlags == CGuiWidget::EGuiModelDrawFlags::AlphaAdditiveOverdraw)
{
CGraphics::SetShaderDataBinding(img.m_dataBinding2[idx]);
CGraphics::DrawInstances(0, 4, 1);
}
} }
} }

View File

@ -67,12 +67,14 @@ private:
#else #else
/* Boo-specific text-rendering functionality */ /* Boo-specific text-rendering functionality */
hecl::UniformBufferPool<CTextSupportShader::Uniform>::Token m_uniBuf; hecl::UniformBufferPool<CTextSupportShader::Uniform>::Token m_uniBuf;
hecl::UniformBufferPool<CTextSupportShader::Uniform>::Token m_uniBuf2;
struct BooFontCharacters struct BooFontCharacters
{ {
TLockedToken<CRasterFont> m_font; TLockedToken<CRasterFont> m_font;
hecl::VertexBufferPool<CTextSupportShader::CharacterInstance>::Token m_instBuf; hecl::VertexBufferPool<CTextSupportShader::CharacterInstance>::Token m_instBuf;
boo::ObjToken<boo::IShaderDataBinding> m_dataBinding; boo::ObjToken<boo::IShaderDataBinding> m_dataBinding;
boo::ObjToken<boo::IShaderDataBinding> m_dataBinding2;
std::vector<CTextSupportShader::CharacterInstance> m_charData; std::vector<CTextSupportShader::CharacterInstance> m_charData;
u32 m_charCount = 0; u32 m_charCount = 0;
bool m_dirty = true; bool m_dirty = true;
@ -86,6 +88,7 @@ private:
CFontImageDef m_imageDef; CFontImageDef m_imageDef;
hecl::VertexBufferPool<CTextSupportShader::ImageInstance>::Token m_instBuf; hecl::VertexBufferPool<CTextSupportShader::ImageInstance>::Token m_instBuf;
std::vector<boo::ObjToken<boo::IShaderDataBinding>> m_dataBinding; std::vector<boo::ObjToken<boo::IShaderDataBinding>> m_dataBinding;
std::vector<boo::ObjToken<boo::IShaderDataBinding>> m_dataBinding2;
CTextSupportShader::ImageInstance m_imageData; CTextSupportShader::ImageInstance m_imageData;
bool m_dirty = true; bool m_dirty = true;
BooImage(const CFontImageDef& imgDef, const zeus::CVector2i& offset); BooImage(const CFontImageDef& imgDef, const zeus::CVector2i& offset);

View File

@ -75,9 +75,9 @@ CInventoryScreen::CInventoryScreen(const CStateManager& mgr, CGuiFrame& frame, c
: CPauseScreenBase(mgr, frame, pauseStrg) : CPauseScreenBase(mgr, frame, pauseStrg)
{ {
CPlayerState& playerState = *mgr.GetPlayerState(); CPlayerState& playerState = *mgr.GetPlayerState();
x19c_samusDoll = std::make_unique<CSamusDoll>(suitDgrp, ballDgrp, x19c_samusDoll = std::make_unique<CSamusDoll>(suitDgrp, ballDgrp, CPlayerState::EPlayerSuit::Phazon
CPlayerState::EPlayerSuit(int(playerState.GetCurrentSuit()) + /*CPlayerState::EPlayerSuit(int(playerState.GetCurrentSuit()) +
playerState.IsFusionEnabled() * 4), playerState.IsFusionEnabled() * 4)*/,
playerState.GetCurrentBeam(), playerState.GetCurrentBeam(),
playerState.HasPowerUp(CPlayerState::EItemType::SpiderBall), playerState.HasPowerUp(CPlayerState::EItemType::SpiderBall),
playerState.HasPowerUp(CPlayerState::EItemType::GrappleBeam)); playerState.HasPowerUp(CPlayerState::EItemType::GrappleBeam));

View File

@ -120,6 +120,8 @@ CSamusDoll::CSamusDoll(const CDependencyGroup& suitDgrp, const CDependencyGroup&
bool hasSpiderBall, bool hasGrappleBeam) bool hasSpiderBall, bool hasGrappleBeam)
: x44_suit(suit), x48_beam(beam) : x44_suit(suit), x48_beam(beam)
{ {
x70_fixedRot.rotateZ(M_PIF);
x90_userInterpRot = xb0_userRot = x70_fixedRot;
x1d4_spiderBallGlass = g_SimplePool->GetObj(SpiderBallGlassModels[int(suit)].first); x1d4_spiderBallGlass = g_SimplePool->GetObj(SpiderBallGlassModels[int(suit)].first);
x1e0_ballMatIdx = hasSpiderBall ? SpiderBallCharacters[int(suit)].second : BallCharacters[int(suit)].second; x1e0_ballMatIdx = hasSpiderBall ? SpiderBallCharacters[int(suit)].second : BallCharacters[int(suit)].second;
x1e4_glassMatIdx = SpiderBallGlassModels[int(suit)].second; x1e4_glassMatIdx = SpiderBallGlassModels[int(suit)].second;
@ -398,7 +400,7 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha)
flags.x4_color = zeus::CColor::skWhite; flags.x4_color = zeus::CColor::skWhite;
x1f4_invBeam->Draw(flags); x1f4_invBeam->Draw(flags);
flags.m_extendedShader = EExtendedShader::Lighting; flags.m_extendedShader = EExtendedShader::ForcedAlpha;
flags.x4_color = zeus::CColor(1.f, alpha); flags.x4_color = zeus::CColor(1.f, alpha);
x1f4_invBeam->Draw(flags); x1f4_invBeam->Draw(flags);
@ -431,7 +433,7 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha)
x20c_invGrappleBeam->GetInstance().ActivateLights(x23c_lights); x20c_invGrappleBeam->GetInstance().ActivateLights(x23c_lights);
CModelFlags flags = {}; CModelFlags flags = {};
flags.m_extendedShader = EExtendedShader::Lighting; flags.m_extendedShader = EExtendedShader::ForcedAlpha;
flags.x4_color = zeus::CColor(1.f, alpha); flags.x4_color = zeus::CColor(1.f, alpha);
x20c_invGrappleBeam->Draw(flags); x20c_invGrappleBeam->Draw(flags);
@ -445,7 +447,7 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha)
x218_invFins->GetInstance().ActivateLights(x23c_lights); x218_invFins->GetInstance().ActivateLights(x23c_lights);
CModelFlags flags = {}; CModelFlags flags = {};
flags.m_extendedShader = EExtendedShader::Lighting; flags.m_extendedShader = EExtendedShader::ForcedAlpha;
flags.x4_color = zeus::CColor(1.f, alpha); flags.x4_color = zeus::CColor(1.f, alpha);
x218_invFins->Draw(flags); x218_invFins->Draw(flags);
@ -472,7 +474,7 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha)
flags.x4_color = zeus::CColor::skWhite; flags.x4_color = zeus::CColor::skWhite;
x184_ballModelData->Render(mgr, x10_xf, x24c_actorLights.get(), flags); x184_ballModelData->Render(mgr, x10_xf, x24c_actorLights.get(), flags);
flags.m_extendedShader = EExtendedShader::Lighting; flags.m_extendedShader = EExtendedShader::ForcedAlpha;
flags.x4_color = zeus::CColor::skWhite; flags.x4_color = zeus::CColor::skWhite;
flags.x4_color.a = alpha * ballAlpha; flags.x4_color.a = alpha * ballAlpha;
x184_ballModelData->Render(mgr, x10_xf, x24c_actorLights.get(), flags); x184_ballModelData->Render(mgr, x10_xf, x24c_actorLights.get(), flags);
@ -523,7 +525,7 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha)
flags.x4_color = zeus::CColor::skWhite; flags.x4_color = zeus::CColor::skWhite;
x1d4_spiderBallGlass->Draw(flags); x1d4_spiderBallGlass->Draw(flags);
flags.m_extendedShader = EExtendedShader::Lighting; flags.m_extendedShader = EExtendedShader::ForcedAlpha;
flags.x4_color = zeus::CColor::skWhite; flags.x4_color = zeus::CColor::skWhite;
flags.x4_color.a = alpha; flags.x4_color.a = alpha;
x1d4_spiderBallGlass->Draw(flags); x1d4_spiderBallGlass->Draw(flags);
@ -533,16 +535,16 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha)
flags.x4_color.a = x6c_ballPulseFactor * alpha * itemPulse; flags.x4_color.a = x6c_ballPulseFactor * alpha * itemPulse;
x1d4_spiderBallGlass->Draw(flags); x1d4_spiderBallGlass->Draw(flags);
} }
}
if (phazonSuit && alpha > 0.1f) if (phazonSuit && alpha > 0.1f)
{ {
float radius = zeus::clamp(0.2f, (10.f - (xc0_userZoom >= 0.f ? xc0_userZoom : -xc0_userZoom)) / 20.f, 1.f); float radius = zeus::clamp(0.2f, (10.f - (xc0_userZoom >= 0.f ? xc0_userZoom : -xc0_userZoom)) / 20.f, 1.f);
float offset = std::sin(x260_phazonOffsetAngle); float offset = std::sin(x260_phazonOffsetAngle);
zeus::CColor color = g_tweakGuiColors->GetPauseBlurFilterColor(); zeus::CColor color = g_tweakGuiColors->GetPauseBlurFilterColor();
color.a = alpha; color.a = alpha;
g_Renderer->DrawPhazonSuitIndirectEffect(zeus::CColor(0.1f, alpha), x250_phazonIndirectTexture, g_Renderer->DrawPhazonSuitIndirectEffect(zeus::CColor(0.1f, alpha), x250_phazonIndirectTexture,
color, radius, 0.1f, offset, offset); color, radius, 0.1f, offset, offset);
}
} }
} }
else else
@ -553,7 +555,7 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha)
flags.x4_color = zeus::CColor::skWhite; flags.x4_color = zeus::CColor::skWhite;
x184_ballModelData->Render(mgr, x10_xf, x24c_actorLights.get(), flags); x184_ballModelData->Render(mgr, x10_xf, x24c_actorLights.get(), flags);
flags.m_extendedShader = EExtendedShader::Lighting; flags.m_extendedShader = EExtendedShader::ForcedAlpha;
flags.x4_color = zeus::CColor::skWhite; flags.x4_color = zeus::CColor::skWhite;
flags.x4_color.a = alpha; flags.x4_color.a = alpha;
x184_ballModelData->Render(mgr, x10_xf, x24c_actorLights.get(), flags); x184_ballModelData->Render(mgr, x10_xf, x24c_actorLights.get(), flags);
@ -596,7 +598,7 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha)
flags.x4_color = zeus::CColor::skWhite; flags.x4_color = zeus::CColor::skWhite;
x1d4_spiderBallGlass->Draw(flags); x1d4_spiderBallGlass->Draw(flags);
flags.m_extendedShader = EExtendedShader::Lighting; flags.m_extendedShader = EExtendedShader::ForcedAlpha;
flags.x4_color = zeus::CColor::skWhite; flags.x4_color = zeus::CColor::skWhite;
flags.x4_color.a = alpha; flags.x4_color.a = alpha;
x1d4_spiderBallGlass->Draw(flags); x1d4_spiderBallGlass->Draw(flags);
@ -726,16 +728,15 @@ void CSamusDoll::SetRotation(float xDelta, float zDelta, float dt)
float angXCenter = angX; float angXCenter = angX;
if (angXCenter > M_PIF) if (angXCenter > M_PIF)
angXCenter -= 2.f * M_PIF; angXCenter -= 2.f * M_PIF;
angX = zeus::clamp(-M_PIF / 2.f, angXCenter, M_PIF / 2.f); angXCenter = zeus::clamp(-1.555f, angXCenter, 1.555f);
float angZCenter = angZ; float angZCenter = angZ;
if (angZCenter > M_PIF) if (angZCenter > M_PIF)
angZCenter -= 2.f * M_PIF; angZCenter -= 2.f * M_PIF;
angZ = zeus::clamp(-M_PIF / 2.f, angZCenter, M_PIF / 2.f);
zeus::CQuaternion quat; zeus::CQuaternion quat;
quat.rotateZ(angZ); quat.rotateZ(angZCenter);
quat.rotateX(angX); quat.rotateX(angXCenter);
xb0_userRot = quat; xb0_userRot = quat;
} }

View File

@ -123,6 +123,26 @@ void CActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMana
CEntity::AcceptScriptMsg(msg, uid, mgr); CEntity::AcceptScriptMsg(msg, uid, mgr);
} }
void CActor::PreRender(CStateManager&, const zeus::CFrustum&)
{
}
void CActor::AddToRenderer(const zeus::CFrustum&, const CStateManager&) const
{
}
void CActor::Render(const CStateManager&) const
{
}
bool CActor::CanRenderUnsorted(const CStateManager&) const
{
return false;
}
void CActor::CalculateRenderBounds() void CActor::CalculateRenderBounds()
{ {
if (x64_modelData && (x64_modelData->AnimationData() || x64_modelData->GetNormalModel())) if (x64_modelData && (x64_modelData->AnimationData() || x64_modelData->GetNormalModel()))

View File

@ -109,10 +109,10 @@ public:
xe7_29_actorActive = active; xe7_29_actorActive = active;
CEntity::SetActive(active); CEntity::SetActive(active);
} }
virtual void PreRender(CStateManager&, const zeus::CFrustum&) {} virtual void PreRender(CStateManager&, const zeus::CFrustum&);
virtual void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const {} virtual void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const;
virtual void Render(const CStateManager&) const {} virtual void Render(const CStateManager&) const;
virtual bool CanRenderUnsorted(const CStateManager&) const { return false; } virtual bool CanRenderUnsorted(const CStateManager&) const;
virtual void CalculateRenderBounds(); virtual void CalculateRenderBounds();
virtual CHealthInfo* HealthInfo(CStateManager&); virtual CHealthInfo* HealthInfo(CStateManager&);
virtual const CDamageVulnerability* GetDamageVulnerability() const; virtual const CDamageVulnerability* GetDamageVulnerability() const;

View File

@ -116,7 +116,7 @@ void CPlayerCameraBob::UpdateViewWander(float dt, CStateManager& mgr)
xb0_wanderPitches[(xcc_wanderIndex + 2) & 3], xb0_wanderPitches[(xcc_wanderIndex + 2) & 3],
xb0_wanderPitches[(xcc_wanderIndex + 3) & 3], dt) * xb0_wanderPitches[(xcc_wanderIndex + 3) & 3], dt) *
x100_wanderMagnitude)); x100_wanderMagnitude));
xd0_viewWanderXf = zeus::lookAt(pt, zeus::CVector3f::skZero, zeus::CVector3f::skUp) * orient; xd0_viewWanderXf = zeus::lookAt(zeus::CVector3f::skZero, pt, zeus::CVector3f::skUp) * orient;
xc4_wanderTime = (xc8_viewWanderSpeed * xc4_wanderTime) + dt; xc4_wanderTime = (xc8_viewWanderSpeed * xc4_wanderTime) + dt;
if (xc4_wanderTime > 1.f) if (xc4_wanderTime > 1.f)

View File

@ -39,7 +39,7 @@ public:
void PreRender(CStateManager&, const zeus::CFrustum&); void PreRender(CStateManager&, const zeus::CFrustum&);
zeus::CAABox GetSortingBounds(const CStateManager&) const; zeus::CAABox GetSortingBounds(const CStateManager&) const;
EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&,
const CWeaponMode&, int) const; const CWeaponMode&, int) const;
rstl::optional_object<zeus::CAABox> GetTouchBounds() const; rstl::optional_object<zeus::CAABox> GetTouchBounds() const;
void Touch(CActor&, CStateManager&); void Touch(CActor&, CStateManager&);
const CDamageVulnerability* GetDamageVulnerability() const { return &x268_damageVulnerability; } const CDamageVulnerability* GetDamageVulnerability() const { return &x268_damageVulnerability; }

2
hecl

@ -1 +1 @@
Subproject commit 0d3f9f345c43bd85cc21945dcd62566e2701a971 Subproject commit fac818d9a0b4cf41934cb9b7f780fe87cafba293

@ -1 +1 @@
Subproject commit ff9755bc27083b7c3bb461a27131ec7f2b886144 Subproject commit 1100f55788199d353e7310ed4427a655c7965255