From 1a372d2589bb0aee46f983bce8578d4c9f46262b Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Thu, 6 Sep 2018 20:37:39 -0700 Subject: [PATCH] Add support for InvDstMultiply blending for shadows, initial CAi implementation --- Runtime/Camera/CCameraFilter.hpp | 3 +- Runtime/Graphics/CSimpleShadow.cpp | 2 +- Runtime/Graphics/CSimpleShadow.hpp | 1 + .../Shaders/CTexturedQuadFilterGLSL.cpp | 239 +++++++++++++++++- Runtime/MP1/CFrontEndUI.cpp | 2 +- Runtime/World/CAi.cpp | 26 ++ Runtime/World/CAi.hpp | 2 +- Runtime/World/CDamageVulnerability.hpp | 3 + 8 files changed, 271 insertions(+), 7 deletions(-) diff --git a/Runtime/Camera/CCameraFilter.hpp b/Runtime/Camera/CCameraFilter.hpp index 3bea74ac7..af93ab4c2 100644 --- a/Runtime/Camera/CCameraFilter.hpp +++ b/Runtime/Camera/CCameraFilter.hpp @@ -21,7 +21,8 @@ enum class EFilterType Blend, Widescreen, SceneAdd, - NoColor + NoColor, + InvDstMultiply }; enum class EFilterShape diff --git a/Runtime/Graphics/CSimpleShadow.cpp b/Runtime/Graphics/CSimpleShadow.cpp index 2acdfdbba..3e74b3685 100644 --- a/Runtime/Graphics/CSimpleShadow.cpp +++ b/Runtime/Graphics/CSimpleShadow.cpp @@ -39,7 +39,7 @@ void CSimpleShadow::Render(const TLockedToken& tex) const CGraphics::SetModelMatrix(x0_xf); if (!m_filter || m_filter->GetTex().GetObj() != tex.GetObj()) - m_filter.emplace(EFilterType::Blend, tex, CTexturedQuadFilter::ZTest::LEqual); + m_filter.emplace(EFilterType::InvDstMultiply, tex, CTexturedQuadFilter::ZTest::LEqual); float radius = x34_radius * x30_scale; CTexturedQuadFilter::Vert verts[] = diff --git a/Runtime/Graphics/CSimpleShadow.hpp b/Runtime/Graphics/CSimpleShadow.hpp index bb2c32d23..0e3102064 100644 --- a/Runtime/Graphics/CSimpleShadow.hpp +++ b/Runtime/Graphics/CSimpleShadow.hpp @@ -27,6 +27,7 @@ public: bool Valid() const { return x48_24_collision; } zeus::CAABox GetMaxShadowBox(const zeus::CAABox& aabb) const; zeus::CAABox GetBounds() const; + void SetAlwaysCalculateRadius(bool) { x48_25_alwaysCalculateRadius = true; } float GetMaxObjectHeight() const { return x40_maxObjHeight; } void SetUserAlpha(float a) { x38_userAlpha = a; } const zeus::CTransform& GetTransform() const { return x0_xf; } diff --git a/Runtime/Graphics/Shaders/CTexturedQuadFilterGLSL.cpp b/Runtime/Graphics/Shaders/CTexturedQuadFilterGLSL.cpp index 0f5b8f064..ea3de1503 100644 --- a/Runtime/Graphics/Shaders/CTexturedQuadFilterGLSL.cpp +++ b/Runtime/Graphics/Shaders/CTexturedQuadFilterGLSL.cpp @@ -109,12 +109,32 @@ static boo::ObjToken s_AlphaPipeline; static boo::ObjToken s_AlphaGEqualPipeline; static boo::ObjToken s_AlphaLEqualPipeline; static boo::ObjToken s_AddPipeline; +static boo::ObjToken s_AddGEqualPipeline; +static boo::ObjToken s_AddLEqualPipeline; +static boo::ObjToken s_SubtractPipeline; +static boo::ObjToken s_SubtractGEqualPipeline; +static boo::ObjToken s_SubtractLEqualPipeline; static boo::ObjToken s_MultPipeline; +static boo::ObjToken s_MultGEqualPipeline; +static boo::ObjToken s_MultLEqualPipeline; +static boo::ObjToken s_InvDstMultPipeline; +static boo::ObjToken s_InvDstMultGEqualPipeline; +static boo::ObjToken s_InvDstMultLEqualPipeline; static boo::ObjToken s_AlphaFlipPipeline; static boo::ObjToken s_AlphaGEqualFlipPipeline; static boo::ObjToken s_AlphaLEqualFlipPipeline; static boo::ObjToken s_AddFlipPipeline; +static boo::ObjToken s_AddGEqualFlipPipeline; +static boo::ObjToken s_AddLEqualFlipPipeline; +static boo::ObjToken s_SubtractFlipPipeline; +static boo::ObjToken s_SubtractGEqualFlipPipeline; +static boo::ObjToken s_SubtractLEqualFlipPipeline; static boo::ObjToken s_MultFlipPipeline; +static boo::ObjToken s_MultGEqualFlipPipeline; +static boo::ObjToken s_MultLEqualFlipPipeline; +static boo::ObjToken s_InvDstMultFlipPipeline; +static boo::ObjToken s_InvDstMultGEqualFlipPipeline; +static boo::ObjToken s_InvDstMultLEqualFlipPipeline; static boo::ObjToken SelectPipeline(EFilterType type, CTexturedQuadFilter::ZTest zTest, bool flip) @@ -122,20 +142,51 @@ static boo::ObjToken SelectPipeline(EFilterType type, switch (zTest) { case CTexturedQuadFilter::ZTest::GEqual: - return flip ? s_AlphaGEqualFlipPipeline : s_AlphaGEqualPipeline; - case CTexturedQuadFilter::ZTest::LEqual: - return flip ? s_AlphaLEqualFlipPipeline : s_AlphaLEqualPipeline; + switch (type) + { + case EFilterType::Blend: + return flip ? s_AlphaGEqualFlipPipeline : s_AlphaGEqualPipeline; + case EFilterType::Add: + return flip ? s_AddGEqualFlipPipeline : s_AddGEqualPipeline; + case EFilterType::Subtract: + return flip ? s_SubtractGEqualFlipPipeline : s_SubtractGEqualPipeline; + case EFilterType::Multiply: + return flip ? s_MultGEqualFlipPipeline : s_MultGEqualPipeline; + default: + break; + } + case CTexturedQuadFilter::ZTest::LEqual: + switch (type) + { + case EFilterType::Blend: + return flip ? s_AlphaLEqualFlipPipeline : s_AlphaLEqualPipeline; + case EFilterType::Add: + return flip ? s_AddLEqualFlipPipeline : s_AddLEqualPipeline; + case EFilterType::Subtract: + return flip ? s_SubtractLEqualFlipPipeline : s_SubtractLEqualPipeline; + case EFilterType::Multiply: + return flip ? s_MultLEqualFlipPipeline : s_MultLEqualPipeline; + case EFilterType::InvDstMultiply: + return flip ? s_InvDstMultLEqualFlipPipeline : s_InvDstMultLEqualPipeline; + default: + break; + } default: break; } + switch (type) { case EFilterType::Blend: return flip ? s_AlphaFlipPipeline : s_AlphaPipeline; case EFilterType::Add: return flip ? s_AddFlipPipeline : s_AddPipeline; + case EFilterType::Subtract: + return flip ? s_SubtractFlipPipeline : s_SubtractPipeline; case EFilterType::Multiply: return flip ? s_MultFlipPipeline : s_MultPipeline; + case EFilterType::InvDstMultiply: + return flip ? s_InvDstMultFlipPipeline : s_InvDstMultPipeline; default: return {}; } @@ -144,7 +195,9 @@ static boo::ObjToken SelectPipeline(EFilterType type, static boo::ObjToken s_AVtxFmt; static boo::ObjToken s_AAlphaPipeline; static boo::ObjToken s_AAddPipeline; +static boo::ObjToken s_ASubtractPipeline; static boo::ObjToken s_AMultPipeline; +static boo::ObjToken s_AInvDstMultPipeline; static boo::ObjToken SelectAlphaPipeline(EFilterType type) { @@ -154,8 +207,12 @@ static boo::ObjToken SelectAlphaPipeline(EFilterType type) return s_AAlphaPipeline; case EFilterType::Add: return s_AAddPipeline; + case EFilterType::Subtract: + return s_ASubtractPipeline; case EFilterType::Multiply: return s_AMultPipeline; + case EFilterType::InvDstMultiply: + return s_AInvDstMultPipeline; default: return {}; } @@ -219,9 +276,39 @@ CTexturedQuadFilter::Initialize(boo::GLDataFactory::Context& ctx) s_AddPipeline = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None); + s_AddGEqualPipeline = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::One, boo::Primitive::TriStrips, + boo::ZTest::GEqual, true, true, false, boo::CullMode::None); + s_AddLEqualPipeline = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::One, boo::Primitive::TriStrips, + boo::ZTest::LEqual, true, true, false, boo::CullMode::None); + s_SubtractPipeline = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::Subtract, boo::Primitive::TriStrips, + boo::ZTest::None, false, true, false, boo::CullMode::None); + s_SubtractGEqualPipeline = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::Subtract, boo::Primitive::TriStrips, + boo::ZTest::GEqual, true, true, false, boo::CullMode::None); + s_SubtractLEqualPipeline = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::Subtract, boo::Primitive::TriStrips, + boo::ZTest::LEqual, true, true, false, boo::CullMode::None); s_MultPipeline = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::Zero, boo::BlendFactor::SrcColor, boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None); + s_MultGEqualPipeline = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::Zero, + boo::BlendFactor::SrcColor, boo::Primitive::TriStrips, + boo::ZTest::GEqual, true, true, false, boo::CullMode::None); + s_MultLEqualPipeline = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::Zero, + boo::BlendFactor::SrcColor, boo::Primitive::TriStrips, + boo::ZTest::LEqual, true, true, false, boo::CullMode::None); + s_InvDstMultPipeline = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::Zero, + boo::BlendFactor::InvSrcColor, boo::Primitive::TriStrips, + boo::ZTest::None, false, true, false, boo::CullMode::None); + s_InvDstMultGEqualPipeline = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::Zero, + boo::BlendFactor::InvSrcColor, boo::Primitive::TriStrips, + boo::ZTest::GEqual, true, true, false, boo::CullMode::None); + s_InvDstMultLEqualPipeline = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::Zero, + boo::BlendFactor::InvSrcColor, boo::Primitive::TriStrips, + boo::ZTest::LEqual, true, true, false, boo::CullMode::None); s_AlphaFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None); @@ -234,9 +321,39 @@ CTexturedQuadFilter::Initialize(boo::GLDataFactory::Context& ctx) s_AddFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None); + s_AddGEqualFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::One, boo::Primitive::TriStrips, + boo::ZTest::GEqual, true, true, false, boo::CullMode::None); + s_AddLEqualFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::One, boo::Primitive::TriStrips, + boo::ZTest::LEqual, true, true, false, boo::CullMode::None); + s_SubtractFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::Subtract, boo::Primitive::TriStrips, + boo::ZTest::None, false, true, false, boo::CullMode::None); + s_SubtractGEqualFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::Subtract, boo::Primitive::TriStrips, + boo::ZTest::GEqual, true, true, false, boo::CullMode::None); + s_SubtractLEqualFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::Subtract, boo::Primitive::TriStrips, + boo::ZTest::LEqual, true, true, false, boo::CullMode::None); s_MultFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::Zero, boo::BlendFactor::SrcColor, boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None); + s_MultGEqualFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::Zero, + boo::BlendFactor::SrcColor, boo::Primitive::TriStrips, + boo::ZTest::GEqual, true, true, false, boo::CullMode::None); + s_MultLEqualFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::Zero, + boo::BlendFactor::SrcColor, boo::Primitive::TriStrips, + boo::ZTest::LEqual, true, true, false, boo::CullMode::None); + s_InvDstMultFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::Zero, + boo::BlendFactor::InvSrcColor, boo::Primitive::TriStrips, + boo::ZTest::None, false, true, false, boo::CullMode::None); + s_InvDstMultGEqualFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::Zero, + boo::BlendFactor::InvSrcColor, boo::Primitive::TriStrips, + boo::ZTest::GEqual, true, true, false, boo::CullMode::None); + s_InvDstMultLEqualFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::Zero, + boo::BlendFactor::InvSrcColor, boo::Primitive::TriStrips, + boo::ZTest::LEqual, true, true, false, boo::CullMode::None); return new CTexturedQuadFilterGLDataBindingFactory; } @@ -247,12 +364,32 @@ void CTexturedQuadFilter::Shutdown() s_AlphaGEqualPipeline.reset(); s_AlphaLEqualPipeline.reset(); s_AddPipeline.reset(); + s_AddGEqualPipeline.reset(); + s_AddLEqualPipeline.reset(); + s_SubtractPipeline.reset(); + s_SubtractGEqualPipeline.reset(); + s_SubtractLEqualPipeline.reset(); s_MultPipeline.reset(); + s_MultGEqualPipeline.reset(); + s_MultLEqualPipeline.reset(); + s_InvDstMultPipeline.reset(); + s_InvDstMultGEqualPipeline.reset(); + s_InvDstMultLEqualPipeline.reset(); s_AlphaFlipPipeline.reset(); s_AlphaGEqualFlipPipeline.reset(); s_AlphaLEqualFlipPipeline.reset(); s_AddFlipPipeline.reset(); + s_AddGEqualFlipPipeline.reset(); + s_AddLEqualFlipPipeline.reset(); + s_SubtractFlipPipeline.reset(); + s_SubtractGEqualFlipPipeline.reset(); + s_SubtractLEqualFlipPipeline.reset(); s_MultFlipPipeline.reset(); + s_MultGEqualFlipPipeline.reset(); + s_MultLEqualFlipPipeline.reset(); + s_InvDstMultFlipPipeline.reset(); + s_InvDstMultGEqualFlipPipeline.reset(); + s_InvDstMultLEqualFlipPipeline.reset(); } #if BOO_HAS_VULKAN @@ -277,9 +414,39 @@ CTexturedQuadFilter::Initialize(boo::VulkanDataFactory::Context& ctx) s_AddPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None); + s_AddGEqualPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::One, boo::Primitive::TriStrips, + boo::ZTest::GEqual, true, true, false, boo::CullMode::None); + s_AddLEqualPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::One, boo::Primitive::TriStrips, + boo::ZTest::LEqual, true, true, false, boo::CullMode::None); + s_SubtractPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::Subtract, boo::Primitive::TriStrips, + boo::ZTest::None, false, true, false, boo::CullMode::None); + s_SubtractGEqualPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::Subtract, boo::Primitive::TriStrips, + boo::ZTest::GEqual, true, true, false, boo::CullMode::None); + s_SubtractLEqualPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::Subtract, boo::Primitive::TriStrips, + boo::ZTest::LEqual, true, true, false, boo::CullMode::None); s_MultPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, boo::BlendFactor::Zero, boo::BlendFactor::SrcColor, boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None); + s_MultGEqualPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, boo::BlendFactor::Zero, + boo::BlendFactor::SrcColor, boo::Primitive::TriStrips, + boo::ZTest::GEqual, true, true, false, boo::CullMode::None); + s_MultLEqualPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, boo::BlendFactor::Zero, + boo::BlendFactor::SrcColor, boo::Primitive::TriStrips, + boo::ZTest::LEqual, true, true, false, boo::CullMode::None); + s_InvDstMultPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, boo::BlendFactor::Zero, + boo::BlendFactor::InvSrcColor, boo::Primitive::TriStrips, + boo::ZTest::None, false, true, false, boo::CullMode::None); + s_InvDstMultGEqualPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, boo::BlendFactor::Zero, + boo::BlendFactor::InvSrcColor, boo::Primitive::TriStrips, + boo::ZTest::GEqual, true, true, false, boo::CullMode::None); + s_InvDstMultLEqualPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, boo::BlendFactor::Zero, + boo::BlendFactor::InvSrcColor, boo::Primitive::TriStrips, + boo::ZTest::LEqual, true, true, false, boo::CullMode::None); s_AlphaFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None); @@ -292,9 +459,39 @@ CTexturedQuadFilter::Initialize(boo::VulkanDataFactory::Context& ctx) s_AddFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None); + s_AddGEqualFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::One, boo::Primitive::TriStrips, + boo::ZTest::GEqual, true, true, false, boo::CullMode::None); + s_AddLEqualFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::One, boo::Primitive::TriStrips, + boo::ZTest::LEqual, true, true, false, boo::CullMode::None); + s_SubtractFlipPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::Subtract, boo::Primitive::TriStrips, + boo::ZTest::None, false, true, false, boo::CullMode::None); + s_SubtractGEqualFlipPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::Subtract, boo::Primitive::TriStrips, + boo::ZTest::GEqual, true, true, false, boo::CullMode::None); + s_SubtractLEqualFlipPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::Subtract, boo::Primitive::TriStrips, + boo::ZTest::LEqual, true, true, false, boo::CullMode::None); s_MultFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, s_VtxFmt, boo::BlendFactor::Zero, boo::BlendFactor::SrcColor, boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None); + s_MultGEqualFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, s_VtxFmt, boo::BlendFactor::Zero, + boo::BlendFactor::SrcColor, boo::Primitive::TriStrips, + boo::ZTest::GEqual, true, true, false, boo::CullMode::None); + s_MultLEqualFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, s_VtxFmt, boo::BlendFactor::Zero, + boo::BlendFactor::SrcColor, boo::Primitive::TriStrips, + boo::ZTest::LEqual, true, true, false, boo::CullMode::None); + s_InvDstMultFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, s_VtxFmt, boo::BlendFactor::Zero, + boo::BlendFactor::InvSrcColor, boo::Primitive::TriStrips, + boo::ZTest::None, false, true, false, boo::CullMode::None); + s_InvDstMultGEqualFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, s_VtxFmt, boo::BlendFactor::Zero, + boo::BlendFactor::InvSrcColor, boo::Primitive::TriStrips, + boo::ZTest::GEqual, true, true, false, boo::CullMode::None); + s_InvDstMultLEqualFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, s_VtxFmt, boo::BlendFactor::Zero, + boo::BlendFactor::InvSrcColor, boo::Primitive::TriStrips, + boo::ZTest::LEqual, true, true, false, boo::CullMode::None); return new CTexturedQuadFilterVulkanDataBindingFactory; } @@ -306,12 +503,32 @@ void CTexturedQuadFilter::Shutdown() s_AlphaGEqualPipeline.reset(); s_AlphaLEqualPipeline.reset(); s_AddPipeline.reset(); + s_AddGEqualPipeline.reset(); + s_AddLEqualPipeline.reset(); + s_SubtractPipeline.reset(); + s_SubtractGEqualPipeline.reset(); + s_SubtractLEqualPipeline.reset(); s_MultPipeline.reset(); + s_MultGEqualPipeline.reset(); + s_MultLEqualPipeline.reset(); + s_InvDstMultPipeline.reset(); + s_InvDstMultGEqualPipeline.reset(); + s_InvDstMultLEqualPipeline.reset(); s_AlphaFlipPipeline.reset(); s_AlphaGEqualFlipPipeline.reset(); s_AlphaLEqualFlipPipeline.reset(); s_AddFlipPipeline.reset(); + s_AddGEqualFlipPipeline.reset(); + s_AddLEqualFlipPipeline.reset(); + s_SubtractFlipPipeline.reset(); + s_SubtractGEqualFlipPipeline.reset(); + s_SubtractLEqualFlipPipeline.reset(); s_MultFlipPipeline.reset(); + s_MultGEqualFlipPipeline.reset(); + s_MultLEqualFlipPipeline.reset(); + s_InvDstMultFlipPipeline.reset(); + s_InvDstMultGEqualFlipPipeline.reset(); + s_InvDstMultLEqualFlipPipeline.reset(); } #endif @@ -367,9 +584,15 @@ CTexturedQuadFilterAlpha::Initialize(boo::GLDataFactory::Context& ctx) s_AAddPipeline = ctx.newShaderPipeline(VSNoFlip, FSAlpha, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None); + s_ASubtractPipeline = ctx.newShaderPipeline(VSNoFlip, FSAlpha, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::Subtract, boo::Primitive::TriStrips, + boo::ZTest::None, false, true, false, boo::CullMode::None); s_AMultPipeline = ctx.newShaderPipeline(VSNoFlip, FSAlpha, 1, texNames, 1, uniNames, boo::BlendFactor::Zero, boo::BlendFactor::SrcColor, boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None); + s_AInvDstMultPipeline = ctx.newShaderPipeline(VSNoFlip, FSAlpha, 1, texNames, 1, uniNames, boo::BlendFactor::Zero, + boo::BlendFactor::InvSrcColor, boo::Primitive::TriStrips, + boo::ZTest::None, false, true, false, boo::CullMode::None); return new CTexturedQuadFilterAlphaGLDataBindingFactory; } @@ -378,7 +601,9 @@ void CTexturedQuadFilterAlpha::Shutdown() { s_AAlphaPipeline.reset(); s_AAddPipeline.reset(); + s_ASubtractPipeline.reset(); s_AMultPipeline.reset(); + s_AInvDstMultPipeline.reset(); } #if BOO_HAS_VULKAN @@ -397,9 +622,15 @@ CTexturedQuadFilterAlpha::Initialize(boo::VulkanDataFactory::Context& ctx) s_AAddPipeline = ctx.newShaderPipeline(VSNoFlip, FSAlpha, s_AVtxFmt, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None); + s_ASubtractPipeline = ctx.newShaderPipeline(VSNoFlip, FSAlpha, s_AVtxFmt, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::Subtract, boo::Primitive::TriStrips, + boo::ZTest::None, false, true, true, boo::CullMode::None); s_AMultPipeline = ctx.newShaderPipeline(VSNoFlip, FSAlpha, s_AVtxFmt, boo::BlendFactor::Zero, boo::BlendFactor::SrcColor, boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None); + s_AInvDstMultPipeline = ctx.newShaderPipeline(VSNoFlip, FSAlpha, s_AVtxFmt, boo::BlendFactor::Zero, + boo::BlendFactor::InvSrcColor, boo::Primitive::TriStrips, + boo::ZTest::None, false, true, true, boo::CullMode::None); return new CTexturedQuadFilterAlphaVulkanDataBindingFactory; } @@ -409,7 +640,9 @@ void CTexturedQuadFilterAlpha::Shutdown() s_AVtxFmt.reset(); s_AAlphaPipeline.reset(); s_AAddPipeline.reset(); + s_ASubtractPipeline.reset(); s_AMultPipeline.reset(); + s_AInvDstMultPipeline.reset(); } #endif diff --git a/Runtime/MP1/CFrontEndUI.cpp b/Runtime/MP1/CFrontEndUI.cpp index a23bdfbb5..51f11f919 100644 --- a/Runtime/MP1/CFrontEndUI.cpp +++ b/Runtime/MP1/CFrontEndUI.cpp @@ -2007,7 +2007,7 @@ CFrontEndUI::CFrontEndUI() m->ResetGameState(); g_GameState->SetCurrentWorldId(g_ResFactory->TranslateOriginalToNew(g_DefaultWorldTag.id)); - g_GameState->CurrentWorldState().SetAreaId(7); + g_GameState->CurrentWorldState().SetAreaId(4); g_GameState->GameOptions().ResetToDefaults(); g_GameState->WriteBackupBuf(); diff --git a/Runtime/World/CAi.cpp b/Runtime/World/CAi.cpp index 8c61679f3..f576ea4de 100644 --- a/Runtime/World/CAi.cpp +++ b/Runtime/World/CAi.cpp @@ -2,6 +2,8 @@ #include "Character/CModelData.hpp" #include "CStateManager.hpp" #include "CStateMachine.hpp" +#include "GameGlobalObjects.hpp" +#include "CSimplePool.hpp" namespace urde { @@ -22,7 +24,31 @@ CAi::CAi(TUniqueId uid, bool active, std::string_view name, const CEntityInfo& i actorParams, stepUp, stepDown) , x258_healthInfo(hInfo) , x260_damageVulnerability(dmgVuln) +, x2c8_stateMachine(g_SimplePool->GetObj({FOURCC('AFSM'), fsm})) { + _CreateShadow(); + + if (x94_simpleShadow) + { + CreateShadow(true); + x94_simpleShadow->SetAlwaysCalculateRadius(false); + } + + if (x90_actorLights) + x260_damageVulnerability.SetX38_25(true); +} + +void CAi::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) +{ + if (msg == EScriptObjectMessage::InitializedInArea) + { + CMaterialList exclude = GetMaterialFilter().GetExcludeList(); + CMaterialList include = GetMaterialFilter().GetIncludeList(); + include.Add(EMaterialTypes::AIBlock); + SetMaterialFilter(CMaterialFilter::MakeIncludeExclude(include, exclude)); + } + + CActor::AcceptScriptMsg(msg, uid, mgr); } CAiStateFunc CAi::GetStateFunc(const char* func) { return m_FuncMap->GetStateFunc(func); } diff --git a/Runtime/World/CAi.hpp b/Runtime/World/CAi.hpp index cf5167590..f58812143 100644 --- a/Runtime/World/CAi.hpp +++ b/Runtime/World/CAi.hpp @@ -48,7 +48,7 @@ public: const CStateMachine* GetStateMachine() const; - virtual void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) {} + virtual void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); virtual CHealthInfo* HealthInfo(CStateManager&) { return &x258_healthInfo; } virtual void Death(CStateManager&, const zeus::CVector3f&, EStateMsg)=0; virtual void KnockBack(const zeus::CVector3f&, CStateManager&, const CDamageInfo& info, EKnockBackType, bool, float)=0; diff --git a/Runtime/World/CDamageVulnerability.hpp b/Runtime/World/CDamageVulnerability.hpp index cf67f0f99..d9f6b2aa5 100644 --- a/Runtime/World/CDamageVulnerability.hpp +++ b/Runtime/World/CDamageVulnerability.hpp @@ -35,7 +35,9 @@ class CDamageVulnerability EVulnerability x2c_enemyWp3Lava; EVulnerability x30_enemyWp4; EVulnerability x34_unk1; + /* FIXME: What's going on here? */ EVulnerability x38_unk2; + bool x38_25 : 1; EVulnerability x3c_chargedPower; EVulnerability x40_chargedIce; @@ -79,6 +81,7 @@ public: static const CDamageVulnerability& ImmuneVulnerabilty() { return sImmuneVulnerability; } static const CDamageVulnerability& ReflectVulnerabilty() { return sReflectVulnerability; } static const CDamageVulnerability& PasshThroughVulnerabilty() { return sPassThroughVulnerability; } + void SetX38_25(bool) { x38_25 = true; } }; }