Add support for InvDstMultiply blending for shadows, initial CAi implementation

This commit is contained in:
Phillip Stephens 2018-09-06 20:37:39 -07:00
parent e46ec80b64
commit 1a372d2589
8 changed files with 271 additions and 7 deletions

View File

@ -21,7 +21,8 @@ enum class EFilterType
Blend, Blend,
Widescreen, Widescreen,
SceneAdd, SceneAdd,
NoColor NoColor,
InvDstMultiply
}; };
enum class EFilterShape enum class EFilterShape

View File

@ -39,7 +39,7 @@ void CSimpleShadow::Render(const TLockedToken<CTexture>& tex) const
CGraphics::SetModelMatrix(x0_xf); CGraphics::SetModelMatrix(x0_xf);
if (!m_filter || m_filter->GetTex().GetObj() != tex.GetObj()) 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; float radius = x34_radius * x30_scale;
CTexturedQuadFilter::Vert verts[] = CTexturedQuadFilter::Vert verts[] =

View File

@ -27,6 +27,7 @@ public:
bool Valid() const { return x48_24_collision; } bool Valid() const { return x48_24_collision; }
zeus::CAABox GetMaxShadowBox(const zeus::CAABox& aabb) const; zeus::CAABox GetMaxShadowBox(const zeus::CAABox& aabb) const;
zeus::CAABox GetBounds() const; zeus::CAABox GetBounds() const;
void SetAlwaysCalculateRadius(bool) { x48_25_alwaysCalculateRadius = true; }
float GetMaxObjectHeight() const { return x40_maxObjHeight; } float GetMaxObjectHeight() const { return x40_maxObjHeight; }
void SetUserAlpha(float a) { x38_userAlpha = a; } void SetUserAlpha(float a) { x38_userAlpha = a; }
const zeus::CTransform& GetTransform() const { return x0_xf; } const zeus::CTransform& GetTransform() const { return x0_xf; }

View File

@ -109,12 +109,32 @@ static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_AlphaGEqualPipeline; static boo::ObjToken<boo::IShaderPipeline> s_AlphaGEqualPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_AlphaLEqualPipeline; static boo::ObjToken<boo::IShaderPipeline> s_AlphaLEqualPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline; static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_AddGEqualPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_AddLEqualPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_SubtractPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_SubtractGEqualPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_SubtractLEqualPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline; static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_MultGEqualPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_MultLEqualPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_InvDstMultPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_InvDstMultGEqualPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_InvDstMultLEqualPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_AlphaFlipPipeline; static boo::ObjToken<boo::IShaderPipeline> s_AlphaFlipPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_AlphaGEqualFlipPipeline; static boo::ObjToken<boo::IShaderPipeline> s_AlphaGEqualFlipPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_AlphaLEqualFlipPipeline; static boo::ObjToken<boo::IShaderPipeline> s_AlphaLEqualFlipPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_AddFlipPipeline; static boo::ObjToken<boo::IShaderPipeline> s_AddFlipPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_AddGEqualFlipPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_AddLEqualFlipPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_SubtractFlipPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_SubtractGEqualFlipPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_SubtractLEqualFlipPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_MultFlipPipeline; static boo::ObjToken<boo::IShaderPipeline> s_MultFlipPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_MultGEqualFlipPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_MultLEqualFlipPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_InvDstMultFlipPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_InvDstMultGEqualFlipPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_InvDstMultLEqualFlipPipeline;
static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type, static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type,
CTexturedQuadFilter::ZTest zTest, bool flip) CTexturedQuadFilter::ZTest zTest, bool flip)
@ -122,20 +142,51 @@ static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type,
switch (zTest) switch (zTest)
{ {
case CTexturedQuadFilter::ZTest::GEqual: case CTexturedQuadFilter::ZTest::GEqual:
return flip ? s_AlphaGEqualFlipPipeline : s_AlphaGEqualPipeline; switch (type)
case CTexturedQuadFilter::ZTest::LEqual: {
return flip ? s_AlphaLEqualFlipPipeline : s_AlphaLEqualPipeline; 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: default:
break; break;
} }
switch (type) switch (type)
{ {
case EFilterType::Blend: case EFilterType::Blend:
return flip ? s_AlphaFlipPipeline : s_AlphaPipeline; return flip ? s_AlphaFlipPipeline : s_AlphaPipeline;
case EFilterType::Add: case EFilterType::Add:
return flip ? s_AddFlipPipeline : s_AddPipeline; return flip ? s_AddFlipPipeline : s_AddPipeline;
case EFilterType::Subtract:
return flip ? s_SubtractFlipPipeline : s_SubtractPipeline;
case EFilterType::Multiply: case EFilterType::Multiply:
return flip ? s_MultFlipPipeline : s_MultPipeline; return flip ? s_MultFlipPipeline : s_MultPipeline;
case EFilterType::InvDstMultiply:
return flip ? s_InvDstMultFlipPipeline : s_InvDstMultPipeline;
default: default:
return {}; return {};
} }
@ -144,7 +195,9 @@ static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type,
static boo::ObjToken<boo::IVertexFormat> s_AVtxFmt; static boo::ObjToken<boo::IVertexFormat> s_AVtxFmt;
static boo::ObjToken<boo::IShaderPipeline> s_AAlphaPipeline; static boo::ObjToken<boo::IShaderPipeline> s_AAlphaPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_AAddPipeline; static boo::ObjToken<boo::IShaderPipeline> s_AAddPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_ASubtractPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_AMultPipeline; static boo::ObjToken<boo::IShaderPipeline> s_AMultPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_AInvDstMultPipeline;
static boo::ObjToken<boo::IShaderPipeline> SelectAlphaPipeline(EFilterType type) static boo::ObjToken<boo::IShaderPipeline> SelectAlphaPipeline(EFilterType type)
{ {
@ -154,8 +207,12 @@ static boo::ObjToken<boo::IShaderPipeline> SelectAlphaPipeline(EFilterType type)
return s_AAlphaPipeline; return s_AAlphaPipeline;
case EFilterType::Add: case EFilterType::Add:
return s_AAddPipeline; return s_AAddPipeline;
case EFilterType::Subtract:
return s_ASubtractPipeline;
case EFilterType::Multiply: case EFilterType::Multiply:
return s_AMultPipeline; return s_AMultPipeline;
case EFilterType::InvDstMultiply:
return s_AInvDstMultPipeline;
default: default:
return {}; return {};
} }
@ -219,9 +276,39 @@ CTexturedQuadFilter::Initialize(boo::GLDataFactory::Context& ctx)
s_AddPipeline = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, s_AddPipeline = ctx.newShaderPipeline(VSNoFlip, FS, 1, 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);
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, s_MultPipeline = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::Zero,
boo::BlendFactor::SrcColor, boo::Primitive::TriStrips, boo::BlendFactor::SrcColor, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None); 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, s_AlphaFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None); 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, s_AddFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, 1, 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);
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, s_MultFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::Zero,
boo::BlendFactor::SrcColor, boo::Primitive::TriStrips, boo::BlendFactor::SrcColor, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None); 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; return new CTexturedQuadFilterGLDataBindingFactory;
} }
@ -247,12 +364,32 @@ void CTexturedQuadFilter::Shutdown<boo::GLDataFactory>()
s_AlphaGEqualPipeline.reset(); s_AlphaGEqualPipeline.reset();
s_AlphaLEqualPipeline.reset(); s_AlphaLEqualPipeline.reset();
s_AddPipeline.reset(); s_AddPipeline.reset();
s_AddGEqualPipeline.reset();
s_AddLEqualPipeline.reset();
s_SubtractPipeline.reset();
s_SubtractGEqualPipeline.reset();
s_SubtractLEqualPipeline.reset();
s_MultPipeline.reset(); s_MultPipeline.reset();
s_MultGEqualPipeline.reset();
s_MultLEqualPipeline.reset();
s_InvDstMultPipeline.reset();
s_InvDstMultGEqualPipeline.reset();
s_InvDstMultLEqualPipeline.reset();
s_AlphaFlipPipeline.reset(); s_AlphaFlipPipeline.reset();
s_AlphaGEqualFlipPipeline.reset(); s_AlphaGEqualFlipPipeline.reset();
s_AlphaLEqualFlipPipeline.reset(); s_AlphaLEqualFlipPipeline.reset();
s_AddFlipPipeline.reset(); s_AddFlipPipeline.reset();
s_AddGEqualFlipPipeline.reset();
s_AddLEqualFlipPipeline.reset();
s_SubtractFlipPipeline.reset();
s_SubtractGEqualFlipPipeline.reset();
s_SubtractLEqualFlipPipeline.reset();
s_MultFlipPipeline.reset(); s_MultFlipPipeline.reset();
s_MultGEqualFlipPipeline.reset();
s_MultLEqualFlipPipeline.reset();
s_InvDstMultFlipPipeline.reset();
s_InvDstMultGEqualFlipPipeline.reset();
s_InvDstMultLEqualFlipPipeline.reset();
} }
#if BOO_HAS_VULKAN #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, s_AddPipeline = ctx.newShaderPipeline(VSNoFlip, 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_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, s_MultPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, boo::BlendFactor::Zero,
boo::BlendFactor::SrcColor, boo::Primitive::TriStrips, boo::BlendFactor::SrcColor, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None); 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, s_AlphaFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None); 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, s_AddFlipPipeline = ctx.newShaderPipeline(VSFlip, 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_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, s_MultFlipPipeline = ctx.newShaderPipeline(VSFlip, FS, s_VtxFmt, boo::BlendFactor::Zero,
boo::BlendFactor::SrcColor, boo::Primitive::TriStrips, boo::BlendFactor::SrcColor, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None); 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; return new CTexturedQuadFilterVulkanDataBindingFactory;
} }
@ -306,12 +503,32 @@ void CTexturedQuadFilter::Shutdown<boo::VulkanDataFactory>()
s_AlphaGEqualPipeline.reset(); s_AlphaGEqualPipeline.reset();
s_AlphaLEqualPipeline.reset(); s_AlphaLEqualPipeline.reset();
s_AddPipeline.reset(); s_AddPipeline.reset();
s_AddGEqualPipeline.reset();
s_AddLEqualPipeline.reset();
s_SubtractPipeline.reset();
s_SubtractGEqualPipeline.reset();
s_SubtractLEqualPipeline.reset();
s_MultPipeline.reset(); s_MultPipeline.reset();
s_MultGEqualPipeline.reset();
s_MultLEqualPipeline.reset();
s_InvDstMultPipeline.reset();
s_InvDstMultGEqualPipeline.reset();
s_InvDstMultLEqualPipeline.reset();
s_AlphaFlipPipeline.reset(); s_AlphaFlipPipeline.reset();
s_AlphaGEqualFlipPipeline.reset(); s_AlphaGEqualFlipPipeline.reset();
s_AlphaLEqualFlipPipeline.reset(); s_AlphaLEqualFlipPipeline.reset();
s_AddFlipPipeline.reset(); s_AddFlipPipeline.reset();
s_AddGEqualFlipPipeline.reset();
s_AddLEqualFlipPipeline.reset();
s_SubtractFlipPipeline.reset();
s_SubtractGEqualFlipPipeline.reset();
s_SubtractLEqualFlipPipeline.reset();
s_MultFlipPipeline.reset(); s_MultFlipPipeline.reset();
s_MultGEqualFlipPipeline.reset();
s_MultLEqualFlipPipeline.reset();
s_InvDstMultFlipPipeline.reset();
s_InvDstMultGEqualFlipPipeline.reset();
s_InvDstMultLEqualFlipPipeline.reset();
} }
#endif #endif
@ -367,9 +584,15 @@ CTexturedQuadFilterAlpha::Initialize(boo::GLDataFactory::Context& ctx)
s_AAddPipeline = ctx.newShaderPipeline(VSNoFlip, FSAlpha, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, s_AAddPipeline = ctx.newShaderPipeline(VSNoFlip, FSAlpha, 1, 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);
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, s_AMultPipeline = ctx.newShaderPipeline(VSNoFlip, FSAlpha, 1, texNames, 1, uniNames, boo::BlendFactor::Zero,
boo::BlendFactor::SrcColor, boo::Primitive::TriStrips, boo::BlendFactor::SrcColor, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None); 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; return new CTexturedQuadFilterAlphaGLDataBindingFactory;
} }
@ -378,7 +601,9 @@ void CTexturedQuadFilterAlpha::Shutdown<boo::GLDataFactory>()
{ {
s_AAlphaPipeline.reset(); s_AAlphaPipeline.reset();
s_AAddPipeline.reset(); s_AAddPipeline.reset();
s_ASubtractPipeline.reset();
s_AMultPipeline.reset(); s_AMultPipeline.reset();
s_AInvDstMultPipeline.reset();
} }
#if BOO_HAS_VULKAN #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, s_AAddPipeline = ctx.newShaderPipeline(VSNoFlip, FSAlpha, s_AVtxFmt, 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, 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, s_AMultPipeline = ctx.newShaderPipeline(VSNoFlip, FSAlpha, s_AVtxFmt, 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, 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; return new CTexturedQuadFilterAlphaVulkanDataBindingFactory;
} }
@ -409,7 +640,9 @@ void CTexturedQuadFilterAlpha::Shutdown<boo::VulkanDataFactory>()
s_AVtxFmt.reset(); s_AVtxFmt.reset();
s_AAlphaPipeline.reset(); s_AAlphaPipeline.reset();
s_AAddPipeline.reset(); s_AAddPipeline.reset();
s_ASubtractPipeline.reset();
s_AMultPipeline.reset(); s_AMultPipeline.reset();
s_AInvDstMultPipeline.reset();
} }
#endif #endif

View File

@ -2007,7 +2007,7 @@ CFrontEndUI::CFrontEndUI()
m->ResetGameState(); m->ResetGameState();
g_GameState->SetCurrentWorldId(g_ResFactory->TranslateOriginalToNew(g_DefaultWorldTag.id)); 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->GameOptions().ResetToDefaults();
g_GameState->WriteBackupBuf(); g_GameState->WriteBackupBuf();

View File

@ -2,6 +2,8 @@
#include "Character/CModelData.hpp" #include "Character/CModelData.hpp"
#include "CStateManager.hpp" #include "CStateManager.hpp"
#include "CStateMachine.hpp" #include "CStateMachine.hpp"
#include "GameGlobalObjects.hpp"
#include "CSimplePool.hpp"
namespace urde namespace urde
{ {
@ -22,7 +24,31 @@ CAi::CAi(TUniqueId uid, bool active, std::string_view name, const CEntityInfo& i
actorParams, stepUp, stepDown) actorParams, stepUp, stepDown)
, x258_healthInfo(hInfo) , x258_healthInfo(hInfo)
, x260_damageVulnerability(dmgVuln) , 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); } CAiStateFunc CAi::GetStateFunc(const char* func) { return m_FuncMap->GetStateFunc(func); }

View File

@ -48,7 +48,7 @@ public:
const CStateMachine* GetStateMachine() const; const CStateMachine* GetStateMachine() const;
virtual void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) {} virtual void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
virtual CHealthInfo* HealthInfo(CStateManager&) { return &x258_healthInfo; } virtual CHealthInfo* HealthInfo(CStateManager&) { return &x258_healthInfo; }
virtual void Death(CStateManager&, const zeus::CVector3f&, EStateMsg)=0; virtual void Death(CStateManager&, const zeus::CVector3f&, EStateMsg)=0;
virtual void KnockBack(const zeus::CVector3f&, CStateManager&, const CDamageInfo& info, EKnockBackType, bool, float)=0; virtual void KnockBack(const zeus::CVector3f&, CStateManager&, const CDamageInfo& info, EKnockBackType, bool, float)=0;

View File

@ -35,7 +35,9 @@ class CDamageVulnerability
EVulnerability x2c_enemyWp3Lava; EVulnerability x2c_enemyWp3Lava;
EVulnerability x30_enemyWp4; EVulnerability x30_enemyWp4;
EVulnerability x34_unk1; EVulnerability x34_unk1;
/* FIXME: What's going on here? */
EVulnerability x38_unk2; EVulnerability x38_unk2;
bool x38_25 : 1;
EVulnerability x3c_chargedPower; EVulnerability x3c_chargedPower;
EVulnerability x40_chargedIce; EVulnerability x40_chargedIce;
@ -79,6 +81,7 @@ public:
static const CDamageVulnerability& ImmuneVulnerabilty() { return sImmuneVulnerability; } static const CDamageVulnerability& ImmuneVulnerabilty() { return sImmuneVulnerability; }
static const CDamageVulnerability& ReflectVulnerabilty() { return sReflectVulnerability; } static const CDamageVulnerability& ReflectVulnerabilty() { return sReflectVulnerability; }
static const CDamageVulnerability& PasshThroughVulnerabilty() { return sPassThroughVulnerability; } static const CDamageVulnerability& PasshThroughVulnerabilty() { return sPassThroughVulnerability; }
void SetX38_25(bool) { x38_25 = true; }
}; };
} }