diff --git a/Editor/ViewManager.cpp b/Editor/ViewManager.cpp index 24b22a597..3f88bdfe8 100644 --- a/Editor/ViewManager.cpp +++ b/Editor/ViewManager.cpp @@ -32,7 +32,7 @@ void ViewManager::BuildTestPART(urde::IObjectStore& objStore) SObjectTag samusCharSet = m_projManager.TagFromPath(_S("MP1/Shared/ANCS_77289A4A.blend")); SObjectTag platModel = m_projManager.TagFromPath(_S("MP1/Shared/CMDL_6FA561D0.blend")); SObjectTag bgModel = m_projManager.TagFromPath(_S("MP1/Shared/CMDL_BC34D54C.blend")); - CAnimRes samusAnimRes(samusCharSet.id, 2, zeus::CVector3f{2.f, 2.f, 2.f}, 0, true); + CAnimRes samusAnimRes(samusCharSet.id, 2, zeus::CVector3f{2.f, 2.f, 2.f}, 1, true); g_GameState->GetWorldTransitionManager()->EnableTransition(samusAnimRes, platModel.id, zeus::CVector3f::skOne, bgModel.id, zeus::CVector3f::skOne, true); @@ -173,8 +173,13 @@ void ViewManager::ParticleView::draw(boo::IGraphicsCommandQueue *gfxQ) m_vm.m_moviePlayer->DrawFrame(); } + if (m_frame == 300) + g_GameState->GetWorldTransitionManager()->PleaseStopSoon(); + g_GameState->GetWorldTransitionManager()->Update(1.f / 60.f); g_GameState->GetWorldTransitionManager()->Draw(); + + ++m_frame; } specter::View* ViewManager::BuildSpaceViews() diff --git a/Editor/ViewManager.hpp b/Editor/ViewManager.hpp index 81ea511c5..57ba8095e 100644 --- a/Editor/ViewManager.hpp +++ b/Editor/ViewManager.hpp @@ -57,6 +57,7 @@ class ViewManager : public specter::IViewManager CCameraBlurFilter m_camBlur; CRandom16 m_random; float m_theta = 0.f; + unsigned m_frame = 0; public: ParticleView(ViewManager& vm, specter::ViewResources& res, specter::View& parent, TLockedToken& xrayPalette) diff --git a/Runtime/Character/CAnimData.cpp b/Runtime/Character/CAnimData.cpp index 6c1fa1042..b1c09d32d 100644 --- a/Runtime/Character/CAnimData.cpp +++ b/Runtime/Character/CAnimData.cpp @@ -46,7 +46,8 @@ CAnimData::CAnimData(ResId id, const std::weak_ptr& ctx, const std::shared_ptr& animMgr, const std::shared_ptr& transMgr, - const TLockedToken& charFactory) + const TLockedToken& charFactory, + int drawInstCount) : x0_charFactory(charFactory), xc_charInfo(character), xcc_layoutData(layout), @@ -58,7 +59,8 @@ CAnimData::CAnimData(ResId id, x204_charIdx(charIdx), x208_defaultAnim(defaultAnim), x224_pose(layout->GetSegIdList().GetList().size()), - x2fc_poseBuilder(layout) + x2fc_poseBuilder(layout), + m_drawInstCount(drawInstCount) { x220_25_loop = loop; @@ -620,12 +622,12 @@ void CAnimData::AdvanceAnim(CCharAnimTime& time, zeus::CVector3f& offset, zeus:: void CAnimData::SetXRayModel(const TLockedToken& model, const TLockedToken& skinRules) { - xf4_xrayModel = std::make_shared(model, skinRules, xd8_modelData->GetLayoutInfo(), 0); + xf4_xrayModel = std::make_shared(model, skinRules, xd8_modelData->GetLayoutInfo(), 0, m_drawInstCount); } void CAnimData::SetInfraModel(const TLockedToken& model, const TLockedToken& skinRules) { - xf8_infraModel = std::make_shared(model, skinRules, xd8_modelData->GetLayoutInfo(), 0); + xf8_infraModel = std::make_shared(model, skinRules, xd8_modelData->GetLayoutInfo(), 0, m_drawInstCount); } void CAnimData::PoseSkinnedModel(CSkinnedModel& model, const CPoseAsTransforms& pose, diff --git a/Runtime/Character/CAnimData.hpp b/Runtime/Character/CAnimData.hpp index b2b6bced9..2807ec9f7 100644 --- a/Runtime/Character/CAnimData.hpp +++ b/Runtime/Character/CAnimData.hpp @@ -136,6 +136,8 @@ class CAnimData static rstl::reserved_vector g_ParticlePOINodes; static rstl::reserved_vector g_SoundPOINodes; + int m_drawInstCount; + public: CAnimData(ResId, const CCharacterInfo& character, @@ -146,7 +148,8 @@ public: const std::weak_ptr& ctx, const std::shared_ptr& animMgr, const std::shared_ptr& transMgr, - const TLockedToken& charFactory); + const TLockedToken& charFactory, + int drawInstCount); ResId GetEventResourceIdForAnimResourceId(ResId) const; void AddAdditiveSegData(const CSegIdList& list, CSegStatementSet& stSet); diff --git a/Runtime/Character/CCharacterFactory.cpp b/Runtime/Character/CCharacterFactory.cpp index c9a51379b..d670f2eed 100644 --- a/Runtime/Character/CCharacterFactory.cpp +++ b/Runtime/Character/CCharacterFactory.cpp @@ -25,7 +25,7 @@ CFactoryFnReturn CCharacterFactory::CDummyFactory::Build(const SObjectTag& tag, const CCharacterInfo& charInfo = *static_cast&>(*params.GetObj()).GetParam(); - switch (tag.type.toUint32()) + switch (tag.type.toUint32() & 0x1) { case 0: return TToken::GetIObjObjectFor( @@ -33,14 +33,14 @@ CFactoryFnReturn CCharacterFactory::CDummyFactory::Build(const SObjectTag& tag, charInfo.GetModelId(), charInfo.GetSkinRulesId(), charInfo.GetCharLayoutInfoId(), - 0)); + 0, tag.type.toUint32() >> 16)); case 1: return TToken::GetIObjObjectFor( std::make_unique(*g_SimplePool, charInfo.GetIceModelId(), charInfo.GetIceSkinRulesId(), charInfo.GetCharLayoutInfoId(), - 0)); + 0, tag.type.toUint32() >> 16)); default: break; } @@ -107,23 +107,25 @@ std::unique_ptr CCharacterFactory::CDummyFactory::LoadResourcePartSync(con std::unique_ptr CCharacterFactory::CreateCharacter(int charIdx, bool loop, const TLockedToken& factory, - int defaultAnim) const + int defaultAnim, int drawInsts) const { const CCharacterInfo& charInfo = x4_charInfoDB[charIdx]; CVParamTransfer charParm(new TObjOwnerParam(&charInfo)); TToken skinnedModel = - const_cast(this)->x70_cacheResPool.GetObj({FourCC(), charInfo.GetModelId()}, charParm); + const_cast(this)->x70_cacheResPool.GetObj + ({FourCC(drawInsts << 16), charInfo.GetModelId()}, charParm); rstl::optional_object> iceModel; if (charInfo.GetIceModelId() != 0xffffffff && charInfo.GetIceSkinRulesId() != 0xffffffff) - iceModel.emplace(const_cast(this)->x70_cacheResPool.GetObj({FourCC(1), charInfo.GetIceModelId()}, charParm)); + iceModel.emplace(const_cast(this)->x70_cacheResPool.GetObj + ({FourCC((drawInsts << 16) | 1), charInfo.GetIceModelId()}, charParm)); return std::make_unique(x68_selfId, charInfo, defaultAnim, charIdx, loop, x14_charLayoutInfoDB[charIdx], skinnedModel, iceModel, x24_sysContext, x28_animMgr, x2c_transMgr, - factory); + factory, drawInsts); } ResId CCharacterFactory::GetEventResourceIdForAnimResourceId(ResId id) const diff --git a/Runtime/Character/CCharacterFactory.hpp b/Runtime/Character/CCharacterFactory.hpp index 3a42443c8..495f6a7d1 100644 --- a/Runtime/Character/CCharacterFactory.hpp +++ b/Runtime/Character/CCharacterFactory.hpp @@ -64,7 +64,7 @@ public: std::unique_ptr CreateCharacter(int charIdx, bool loop, const TLockedToken& factory, - int defaultAnim) const; + int defaultAnim, int drawInsts) const; ResId GetEventResourceIdForAnimResourceId(ResId animId) const; const CCharacterInfo& GetCharInfo(int charIdx) const { return x4_charInfoDB[charIdx]; } diff --git a/Runtime/Character/CModelData.cpp b/Runtime/Character/CModelData.cpp index c11ac68cb..b744cbcd4 100644 --- a/Runtime/Character/CModelData.cpp +++ b/Runtime/Character/CModelData.cpp @@ -22,20 +22,21 @@ CModelData::~CModelData() {} CModelData::CModelData() {} CModelData CModelData::CModelDataNull() {return CModelData();} -CModelData::CModelData(const CStaticRes& res) -: x0_scale(res.GetScale()) +CModelData::CModelData(const CStaticRes& res, int instCount) +: x0_scale(res.GetScale()), m_drawInstCount(instCount) { x1c_normalModel = g_SimplePool->GetObj({SBIG('CMDL'), res.GetId()}); if (!x1c_normalModel) Log.report(logvisor::Fatal, "unable to find CMDL %08X", res.GetId()); - m_normalModelInst = x1c_normalModel->MakeNewInstance(0); + m_normalModelInst = x1c_normalModel->MakeNewInstance(0, instCount); } -CModelData::CModelData(const CAnimRes& res) -: x0_scale(res.GetScale()) +CModelData::CModelData(const CAnimRes& res, int instCount) +: x0_scale(res.GetScale()), m_drawInstCount(instCount) { TToken factory = g_CharFactoryBuilder->GetFactory(res); - x10_animData = factory->CreateCharacter(res.GetCharacterNodeId(), res.CanLoop(), factory, res.GetDefaultAnim()); + x10_animData = factory->CreateCharacter(res.GetCharacterNodeId(), res.CanLoop(), factory, + res.GetDefaultAnim(), instCount); } SAdvancementDeltas CModelData::GetAdvancementDeltas(const CCharAnimTime& a, @@ -115,7 +116,7 @@ void CModelData::SetXRayModel(const std::pair& modelSkin) x2c_xrayModel = g_SimplePool->GetObj({SBIG('CMDL'), modelSkin.first}); if (!x2c_xrayModel) Log.report(logvisor::Fatal, "unable to find CMDL %08X", modelSkin.first); - m_xrayModelInst = x2c_xrayModel->MakeNewInstance(0); + m_xrayModelInst = x2c_xrayModel->MakeNewInstance(0, m_drawInstCount); } } } @@ -138,7 +139,7 @@ void CModelData::SetInfraModel(const std::pair& modelSkin) x3c_infraModel = g_SimplePool->GetObj({SBIG('CMDL'), modelSkin.first}); if (!x3c_infraModel) Log.report(logvisor::Fatal, "unable to find CMDL %08X", modelSkin.first); - m_infraModelInst = x3c_infraModel->MakeNewInstance(0); + m_infraModelInst = x3c_infraModel->MakeNewInstance(0, m_drawInstCount); } } } diff --git a/Runtime/Character/CModelData.hpp b/Runtime/Character/CModelData.hpp index b2f822da6..137603a39 100644 --- a/Runtime/Character/CModelData.hpp +++ b/Runtime/Character/CModelData.hpp @@ -87,6 +87,8 @@ class CModelData std::unique_ptr m_xrayModelInst; std::unique_ptr m_infraModelInst; + int m_drawInstCount; + public: enum class EWhichModel { @@ -98,8 +100,8 @@ public: void SetSortThermal(bool v) { x14_25_sortThermal = v; } ~CModelData(); - CModelData(const CStaticRes& res); - CModelData(const CAnimRes& res); + CModelData(const CStaticRes& res, int instCount=1); + CModelData(const CAnimRes& res, int instCount=1); CModelData(CModelData&&) = default; CModelData& operator=(CModelData&&) = default; CModelData(); diff --git a/Runtime/Graphics/CModel.hpp b/Runtime/Graphics/CModel.hpp index 5f8f98b73..b6b6e3218 100644 --- a/Runtime/Graphics/CModel.hpp +++ b/Runtime/Graphics/CModel.hpp @@ -72,7 +72,7 @@ public: struct SShader { std::vector> x0_textures; - std::vector> m_shaders; + std::vector> m_shaders; MaterialSet m_matSet; int m_matSetIdx; SShader(int idx) : m_matSetIdx(idx) {} @@ -87,7 +87,7 @@ private: std::vector* x0_surfaces; const MaterialSet* x4_matSet; int m_matSetIdx = -1; - const std::vector>* m_pipelines; + const std::vector>* m_pipelines; boo::IVertexFormat* m_vtxFmt; boo::IGraphicsBufferS* x8_vbo; boo::IGraphicsBufferS* xc_ibo; @@ -132,7 +132,7 @@ public: ~CBooModel(); CBooModel(TToken& token, std::vector* surfaces, SShader& shader, boo::IVertexFormat* vtxFmt, boo::IGraphicsBufferS* vbo, boo::IGraphicsBufferS* ibo, - size_t weightVecCount, size_t skinBankCount, const zeus::CAABox& aabb); + size_t weightVecCount, size_t skinBankCount, const zeus::CAABox& aabb, int numInsts); static void MakeTexuresFromMats(const MaterialSet& matSet, std::vector>& toksOut, @@ -203,7 +203,7 @@ public: const zeus::CAABox& GetAABB() const {return m_aabb;} CBooModel& GetInstance() {return *x28_modelInst;} const CBooModel& GetInstance() const {return *x28_modelInst;} - std::unique_ptr MakeNewInstance(int shaderIdx); + std::unique_ptr MakeNewInstance(int shaderIdx, int subInsts); }; CFactoryFnReturn FModelFactory(const urde::SObjectTag& tag, diff --git a/Runtime/Graphics/CModelBoo.cpp b/Runtime/Graphics/CModelBoo.cpp index fa4226deb..895fd403f 100644 --- a/Runtime/Graphics/CModelBoo.cpp +++ b/Runtime/Graphics/CModelBoo.cpp @@ -36,7 +36,7 @@ CBooModel::~CBooModel() CBooModel::CBooModel(TToken& token, std::vector* surfaces, SShader& shader, boo::IVertexFormat* vtxFmt, boo::IGraphicsBufferS* vbo, boo::IGraphicsBufferS* ibo, - size_t weightVecCount, size_t skinBankCount, const zeus::CAABox& aabb) + size_t weightVecCount, size_t skinBankCount, const zeus::CAABox& aabb, int instCount) : m_model(token), x0_surfaces(surfaces), x4_matSet(&shader.m_matSet), m_matSetIdx(shader.m_matSetIdx), m_pipelines(&shader.m_shaders), m_vtxFmt(vtxFmt), x8_vbo(vbo), xc_ibo(ibo), m_weightVecCount(weightVecCount), m_skinBankCount(skinBankCount), x1c_textures(shader.x0_textures), x20_aabb(aabb), @@ -69,6 +69,10 @@ CBooModel::CBooModel(TToken& token, std::vector* surfaces, x38_firstUnsortedSurface = &*it; } } + + m_instances.reserve(instCount); + for (int i=0 ; i& pipelines = m_pipelines->at(surf.m_data.matIdx); + const std::shared_ptr& pipelines = m_pipelines->at(surf.m_data.matIdx); newInst.m_shaderDataBindings.emplace_back(); std::vector& extendeds = newInst.m_shaderDataBindings.back(); - extendeds.reserve(pipelines.size()); + extendeds.reserve(pipelines->m_pipelines.size()); int idx = 0; - for (boo::IShaderPipeline* pipeline : pipelines) + for (boo::IShaderPipeline* pipeline : pipelines->m_pipelines) { extendeds.push_back( ctx.newShaderDataBinding(pipeline, m_vtxFmt, @@ -657,12 +661,12 @@ static const u8* MemoryFromPartData(const u8*& dataCur, const s32*& secSizeCur) return ret; } -std::unique_ptr CModel::MakeNewInstance(int shaderIdx) +std::unique_ptr CModel::MakeNewInstance(int shaderIdx, int subInsts) { if (shaderIdx >= x18_matSets.size()) shaderIdx = 0; return std::make_unique(m_selfToken, &x8_surfaces, x18_matSets[shaderIdx], - m_vtxFmt, m_vbo, m_ibo, m_weightVecCount, m_skinBankCount, m_aabb); + m_vtxFmt, m_vbo, m_ibo, m_weightVecCount, m_skinBankCount, m_aabb, subInsts); } CModel::CModel(std::unique_ptr&& in, u32 /* dataLen */, IObjectStore* store, CObjectReference* selfRef) @@ -705,25 +709,25 @@ CModel::CModel(std::unique_ptr&& in, u32 /* dataLen */, IObjectStore* stor const u8* iboData = MemoryFromPartData(dataCur, secSizeCur); const u8* surfInfo = MemoryFromPartData(dataCur, secSizeCur); + for (CBooModel::SShader& matSet : x18_matSets) + { + matSet.m_shaders.reserve(matSet.m_matSet.materials.size()); + for (const MaterialSet::Material& mat : matSet.m_matSet.materials) + { + hecl::Runtime::ShaderTag tag(mat.heclIr, + hmdlMeta.colorCount, hmdlMeta.uvCount, hmdlMeta.weightCount, + hmdlMeta.weightCount * 4, 8, boo::Primitive(hmdlMeta.topology), + true, true, true); + matSet.m_shaders.push_back(CModelShaders::g_ModelShaders->buildExtendedShader + (tag, mat.heclIr, "CMDL", *CGraphics::g_BooFactory)); + } + } + m_gfxToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool { m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, vboData, hmdlMeta.vertStride, hmdlMeta.vertCount); m_ibo = ctx.newStaticBuffer(boo::BufferUse::Index, iboData, 4, hmdlMeta.indexCount); m_vtxFmt = hecl::Runtime::HMDLData::NewVertexFormat(ctx, hmdlMeta, m_vbo, m_ibo); - - for (CBooModel::SShader& matSet : x18_matSets) - { - matSet.m_shaders.reserve(matSet.m_matSet.materials.size()); - for (const MaterialSet::Material& mat : matSet.m_matSet.materials) - { - hecl::Runtime::ShaderTag tag(mat.heclIr, - hmdlMeta.colorCount, hmdlMeta.uvCount, hmdlMeta.weightCount, - hmdlMeta.weightCount * 4, 8, boo::Primitive(hmdlMeta.topology), - true, true, true); - matSet.m_shaders.push_back(CModelShaders::g_ModelShaders->buildExtendedShader(tag, mat.heclIr, "CMDL", ctx)); - } - } - return true; }); @@ -743,7 +747,7 @@ CModel::CModel(std::unique_ptr&& in, u32 /* dataLen */, IObjectStore* stor const float* aabbPtr = reinterpret_cast(data.get() + 0xc); m_aabb = zeus::CAABox(hecl::SBig(aabbPtr[0]), hecl::SBig(aabbPtr[1]), hecl::SBig(aabbPtr[2]), hecl::SBig(aabbPtr[3]), hecl::SBig(aabbPtr[4]), hecl::SBig(aabbPtr[5])); - x28_modelInst = MakeNewInstance(0); + x28_modelInst = MakeNewInstance(0, 1); } void CBooModel::SShader::UnlockTextures() diff --git a/Runtime/Graphics/CSkinnedModel.cpp b/Runtime/Graphics/CSkinnedModel.cpp index ccc1be6bb..493cbfcd7 100644 --- a/Runtime/Graphics/CSkinnedModel.cpp +++ b/Runtime/Graphics/CSkinnedModel.cpp @@ -8,7 +8,7 @@ static logvisor::Module Log("urde::CSkinnedModel"); CSkinnedModel::CSkinnedModel(TLockedToken model, TLockedToken skinRules, TLockedToken layoutInfo, - int shaderIdx) + int shaderIdx, int drawInsts) : x4_model(model), x10_skinRules(skinRules), x1c_layoutInfo(layoutInfo) { if (!model) @@ -17,16 +17,16 @@ CSkinnedModel::CSkinnedModel(TLockedToken model, Log.report(logvisor::Fatal, "bad skin token provided to CSkinnedModel"); if (!layoutInfo) Log.report(logvisor::Fatal, "bad character layout token provided to CSkinnedModel"); - m_modelInst = model->MakeNewInstance(shaderIdx); + m_modelInst = model->MakeNewInstance(shaderIdx, drawInsts); } CSkinnedModel::CSkinnedModel(IObjectStore& store, ResId model, ResId skinRules, ResId layoutInfo, - int shaderIdx) + int shaderIdx, int drawInsts) : CSkinnedModel(store.GetObj(SObjectTag{FOURCC('CMDL'), model}), store.GetObj(SObjectTag{FOURCC('CSKR'), skinRules}), store.GetObj(SObjectTag{FOURCC('CINF'), layoutInfo}), - shaderIdx) + shaderIdx, drawInsts) { } @@ -46,8 +46,8 @@ void CSkinnedModel::Draw(const CModelFlags& drawFlags) const CMorphableSkinnedModel::CMorphableSkinnedModel(IObjectStore& store, ResId model, ResId skinRules, ResId layoutInfo, - int shaderIdx) -: CSkinnedModel(store, model, skinRules, layoutInfo, shaderIdx) + int shaderIdx, int drawInsts) +: CSkinnedModel(store, model, skinRules, layoutInfo, shaderIdx, drawInsts) { } diff --git a/Runtime/Graphics/CSkinnedModel.hpp b/Runtime/Graphics/CSkinnedModel.hpp index 15a353ca3..a69c26a4f 100644 --- a/Runtime/Graphics/CSkinnedModel.hpp +++ b/Runtime/Graphics/CSkinnedModel.hpp @@ -30,9 +30,9 @@ public: CSkinnedModel(TLockedToken model, TLockedToken skinRules, TLockedToken layoutInfo, - int shaderIdx); + int shaderIdx, int drawInsts); CSkinnedModel(IObjectStore& store, ResId model, ResId skinRules, - ResId layoutInfo, int shaderIdx); + ResId layoutInfo, int shaderIdx, int drawInsts); const TLockedToken& GetModel() const {return x4_model;} const std::unique_ptr& GetModelInst() const {return m_modelInst;} @@ -50,7 +50,7 @@ class CMorphableSkinnedModel : public CSkinnedModel { public: CMorphableSkinnedModel(IObjectStore& store, ResId model, ResId skinRules, - ResId layoutInfo, int shaderIdx); + ResId layoutInfo, int shaderIdx, int drawInsts); }; } diff --git a/Runtime/Graphics/Shaders/CModelShaders.hpp b/Runtime/Graphics/Shaders/CModelShaders.hpp index 0c215c72f..7b9f3541c 100644 --- a/Runtime/Graphics/Shaders/CModelShaders.hpp +++ b/Runtime/Graphics/Shaders/CModelShaders.hpp @@ -52,32 +52,36 @@ public: CModelShaders(const hecl::Runtime::FileStoreManager& storeMgr, boo::IGraphicsDataFactory* gfxFactory); - boo::IShaderPipeline* buildShader(const hecl::Runtime::ShaderTag& tag, const std::string& source, - const std::string& diagName, - boo::IGraphicsDataFactory::Context& ctx) + std::shared_ptr buildShader(const hecl::Runtime::ShaderTag& tag, + const std::string& source, + const std::string& diagName, + boo::IGraphicsDataFactory& factory) { - return m_shaderCache.buildShader(tag, source, diagName, ctx); + return m_shaderCache.buildShader(tag, source, diagName, factory); } - boo::IShaderPipeline* buildShader(const hecl::Runtime::ShaderTag& tag, const hecl::Frontend::IR& ir, - const std::string& diagName, - boo::IGraphicsDataFactory::Context& ctx) + std::shared_ptr buildShader(const hecl::Runtime::ShaderTag& tag, + const hecl::Frontend::IR& ir, + const std::string& diagName, + boo::IGraphicsDataFactory& factory) { - return m_shaderCache.buildShader(tag, ir, diagName, ctx); + return m_shaderCache.buildShader(tag, ir, diagName, factory); } - std::vector buildExtendedShader(const hecl::Runtime::ShaderTag& tag, const std::string& source, - const std::string& diagName, - boo::IGraphicsDataFactory::Context& ctx) + std::shared_ptr buildExtendedShader(const hecl::Runtime::ShaderTag& tag, + const std::string& source, + const std::string& diagName, + boo::IGraphicsDataFactory& factory) { - return m_shaderCache.buildExtendedShader(tag, source, diagName, ctx); + return m_shaderCache.buildExtendedShader(tag, source, diagName, factory); } - std::vector buildExtendedShader(const hecl::Runtime::ShaderTag& tag, const hecl::Frontend::IR& ir, - const std::string& diagName, - boo::IGraphicsDataFactory::Context& ctx) + std::shared_ptr buildExtendedShader(const hecl::Runtime::ShaderTag& tag, + const hecl::Frontend::IR& ir, + const std::string& diagName, + boo::IGraphicsDataFactory& factory) { - return m_shaderCache.buildExtendedShader(tag, ir, diagName, ctx); + return m_shaderCache.buildExtendedShader(tag, ir, diagName, factory); } }; diff --git a/Runtime/Graphics/Shaders/CTexturedQuadFilter.cpp b/Runtime/Graphics/Shaders/CTexturedQuadFilter.cpp index b1a20cc58..8719f28ce 100644 --- a/Runtime/Graphics/Shaders/CTexturedQuadFilter.cpp +++ b/Runtime/Graphics/Shaders/CTexturedQuadFilter.cpp @@ -9,18 +9,7 @@ CTexturedQuadFilter::CTexturedQuadFilter(CCameraFilterPass::EFilterType type, bo { m_token = CGraphics::g_BooFactory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool { - struct Vert - { - zeus::CVector2f m_pos; - zeus::CVector2f m_uv; - } verts[4] = - { - {{-1.0, -1.0}, {0.0, 0.0}}, - {{-1.0, 1.0}, {0.0, 1.0}}, - {{ 1.0, -1.0}, {1.0, 0.0}}, - {{ 1.0, 1.0}, {1.0, 1.0}}, - }; - m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts, 32, 4); + m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, 32, 4); m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1); m_dataBind = TMultiBlendShader::BuildShaderDataBinding(ctx, type, *this); return true; @@ -36,6 +25,20 @@ CTexturedQuadFilter::CTexturedQuadFilter(CCameraFilterPass::EFilterType type, void CTexturedQuadFilter::draw(const zeus::CColor& color, float uvScale) { + float xFac = CGraphics::g_CroppedViewport.xc_width / float(CGraphics::g_ViewportResolution.x); + float yFac = CGraphics::g_CroppedViewport.x10_height / float(CGraphics::g_ViewportResolution.y); + float xBias = CGraphics::g_CroppedViewport.x4_left / float(CGraphics::g_ViewportResolution.x); + float yBias = CGraphics::g_CroppedViewport.x8_top / float(CGraphics::g_ViewportResolution.y); + + Vert verts[4] = + { + {{-1.0, -1.0}, {xBias, yBias}}, + {{-1.0, 1.0}, {xBias, yBias + yFac}}, + {{ 1.0, -1.0}, {xBias + xFac, yBias}}, + {{ 1.0, 1.0}, {xBias + xFac, yBias + yFac}}, + }; + m_vbo->load(verts, sizeof(verts)); + m_uniform.m_color = color; m_uniform.m_uvScale = uvScale; m_uniBuf->load(&m_uniform, sizeof(m_uniform)); diff --git a/Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp b/Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp index b160223b8..53d232d89 100644 --- a/Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp +++ b/Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp @@ -17,6 +17,12 @@ class CTexturedQuadFilter friend struct CTexturedQuadFilterMetalDataBindingFactory; friend struct CTexturedQuadFilterD3DDataBindingFactory; + struct Vert + { + zeus::CVector2f m_pos; + zeus::CVector2f m_uv; + }; + struct Uniform { zeus::CColor m_color; @@ -25,7 +31,7 @@ class CTexturedQuadFilter TLockedToken m_tex; boo::ITexture* m_booTex; boo::GraphicsDataToken m_token; - boo::IGraphicsBufferS* m_vbo; + boo::IGraphicsBufferD* m_vbo; boo::IGraphicsBufferD* m_uniBuf; boo::IShaderDataBinding* m_dataBind = nullptr; Uniform m_uniform; diff --git a/Runtime/Graphics/Shaders/CTexturedQuadFilterGLSL.cpp b/Runtime/Graphics/Shaders/CTexturedQuadFilterGLSL.cpp index 8f70b4405..a569864ac 100644 --- a/Runtime/Graphics/Shaders/CTexturedQuadFilterGLSL.cpp +++ b/Runtime/Graphics/Shaders/CTexturedQuadFilterGLSL.cpp @@ -45,7 +45,7 @@ BOO_GLSL_BINDING_HEAD "TBINDING0 uniform sampler2D tex;\n" "void main()\n" "{\n" -" colorOut = vtf.color * texture(tex, vtf.uv);\n" +" colorOut = vtf.color * vec4(texture(tex, vtf.uv).rgb, 1.0);\n" "}\n"; URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter) diff --git a/Runtime/World/CPlayer.cpp b/Runtime/World/CPlayer.cpp index a2161dfde..266aa92af 100644 --- a/Runtime/World/CPlayer.cpp +++ b/Runtime/World/CPlayer.cpp @@ -10,7 +10,7 @@ namespace urde static CModelData MakePlayerAnimRes(ResId resId, const zeus::CVector3f& scale) { - return CAnimRes(resId, 0, scale, 0, true); + return {CAnimRes(resId, 0, scale, 0, true), 1}; } CPlayer::CPlayer(TUniqueId uid, const zeus::CTransform& xf, const zeus::CAABox& aabb, unsigned int resId, diff --git a/Runtime/World/CWorldTransManager.cpp b/Runtime/World/CWorldTransManager.cpp index 1cf8f9706..9f161f44f 100644 --- a/Runtime/World/CWorldTransManager.cpp +++ b/Runtime/World/CWorldTransManager.cpp @@ -240,8 +240,9 @@ void CWorldTransManager::DrawEnabled() rect.xc_width = CGraphics::g_ViewportResolution.x; rect.x10_height = CGraphics::g_ViewportResolution.y; CGraphics::ResolveSpareTexture(rect); + CGraphics::g_BooMainCommandQueue->clearTarget(true, true); DrawSecondPass(); - m_dissolve.draw(zeus::CColor{1.f, 1.f, 1.f, t}, 1.f); + m_dissolve.draw(zeus::CColor{1.f, 1.f, 1.f, 1.f - t}, 1.f); } CWideScreenFilter::SetViewportToFull(); @@ -287,8 +288,8 @@ void CWorldTransManager::TouchModels() x4_modelData->x14c_beamModel.IsLoaded() && x4_modelData->x14c_beamModel.GetObj()) { - x4_modelData->x68_beamModelData = CStaticRes(x4_modelData->x14c_beamModel.GetObjectTag()->id, - x4_modelData->x0_samusRes.GetScale()); + x4_modelData->x68_beamModelData = {CStaticRes(x4_modelData->x14c_beamModel.GetObjectTag()->id, + x4_modelData->x0_samusRes.GetScale()), 2}; } if (x4_modelData->x1c_samusModelData.IsNull() && @@ -300,7 +301,7 @@ void CWorldTransManager::TouchModels() CAnimRes animRes(x4_modelData->x0_samusRes.GetId(), GetSuitCharIdx(), x4_modelData->x0_samusRes.GetScale(), x4_modelData->x0_samusRes.GetDefaultAnim(), true); - x4_modelData->x1c_samusModelData = animRes; + x4_modelData->x1c_samusModelData = {animRes, 2}; CAnimPlaybackParms aData(animRes.GetDefaultAnim(), -1, 1.f, true); x4_modelData->x1c_samusModelData.AnimationData()->SetAnimation(aData, false); @@ -347,7 +348,7 @@ void CWorldTransManager::EnableTransition(const CAnimRes& samusRes, if (platRes != -1) { - x4_modelData->xb4_platformModelData = CStaticRes(platRes, platScale); + x4_modelData->xb4_platformModelData = {CStaticRes(platRes, platScale), 2}; x4_modelData->xb4_platformModelData.Touch(CModelData::EWhichModel::Normal, 0); } diff --git a/hecl b/hecl index df53b858f..88fade1d0 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit df53b858ffc9a06f9cf833908a93587c003179f2 +Subproject commit 88fade1d0df7b34a38e9415adbb04a7eaf838f42