mirror of https://github.com/AxioDL/metaforce.git
CWorldShadow OpenGL fixes; discord-rpc integration
This commit is contained in:
parent
030e80d843
commit
669b3d6942
|
@ -28,3 +28,9 @@
|
|||
[submodule "cotire"]
|
||||
path = cotire
|
||||
url = https://github.com/sakra/cotire.git
|
||||
[submodule "discord-rpc"]
|
||||
path = discord-rpc
|
||||
url = https://github.com/discordapp/discord-rpc.git
|
||||
[submodule "rapidjson"]
|
||||
path = rapidjson
|
||||
url = https://github.com/Tencent/rapidjson.git
|
||||
|
|
|
@ -130,6 +130,12 @@ if(USE_LD_GOLD AND ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_
|
|||
endif()
|
||||
endif()
|
||||
|
||||
# Add discord-rpc here
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/rapidjson/include)
|
||||
set(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/discord-rpc)
|
||||
add_subdirectory(discord-rpc/src)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/discord-rpc/include)
|
||||
|
||||
set(HECL_DLPACKAGE ${URDE_DLPACKAGE})
|
||||
|
||||
set(BOO_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/hecl/extern/boo/include)
|
||||
|
|
|
@ -102,7 +102,7 @@ target_link_libraries(urde
|
|||
hecl-full hecl-blender-addon
|
||||
athena-core nod logvisor athena-libyaml amuse boo
|
||||
${PNG_LIB} libjpeg-turbo squish xxhash zeus
|
||||
kabufuda jbus ${ZLIB_LIBRARIES} ${LZO_LIB}
|
||||
kabufuda jbus discord-rpc ${ZLIB_LIBRARIES} ${LZO_LIB}
|
||||
${BOO_SYS_LIBS})
|
||||
if(COMMAND add_sanitizers)
|
||||
add_sanitizers(urde)
|
||||
|
|
|
@ -143,6 +143,11 @@ struct Application : boo::IApplicationCallback
|
|||
return m_cvarCommons.getAnisotropy();
|
||||
}
|
||||
|
||||
bool getDeepColor() const
|
||||
{
|
||||
return m_cvarCommons.getDeepColor();
|
||||
}
|
||||
|
||||
void quit(hecl::Console* con = nullptr, const std::vector<std::string>& arg = std::vector<std::string>())
|
||||
{
|
||||
m_running = false;
|
||||
|
@ -214,7 +219,7 @@ int main(int argc, const boo::SystemChar** argv)
|
|||
urde::Application appCb;
|
||||
int ret = boo::ApplicationRun(boo::IApplication::EPlatformType::Auto,
|
||||
appCb, _S("urde"), _S("URDE"), argc, argv, appCb.getGraphicsApi(),
|
||||
appCb.getSamples(), appCb.getAnisotropy(), false);
|
||||
appCb.getSamples(), appCb.getAnisotropy(), appCb.getDeepColor(), false);
|
||||
//printf("IM DYING!!\n");
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "World/CScriptWater.hpp"
|
||||
#include "World/CScriptDoor.hpp"
|
||||
#include "Input/ControlMapper.hpp"
|
||||
#include "MP1/MP1.hpp"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
|
@ -205,7 +206,7 @@ CStateManager::CStateManager(const std::weak_ptr<CRelayTracker>& relayTracker,
|
|||
x90c_loaderFuncs[int(EScriptObjectType::ShadowProjector)] = ScriptLoader::LoadShadowProjector;
|
||||
x90c_loaderFuncs[int(EScriptObjectType::EnergyBall)] = ScriptLoader::LoadEnergyBall;
|
||||
|
||||
CGameCollision::InitCollision();
|
||||
//CGameCollision::InitCollision();
|
||||
ControlMapper::ResetCommandFilters();
|
||||
x8f0_shadowTex = g_SimplePool->GetObj("DefaultShadow");
|
||||
}
|
||||
|
@ -1837,6 +1838,8 @@ void CStateManager::UpdateGraphicsTiming(float dt)
|
|||
|
||||
void CStateManager::Update(float dt)
|
||||
{
|
||||
MP1::CMain::UpdateDiscordPresence(GetWorld()->IGetStringTableAssetId());
|
||||
|
||||
CElementGen::SetGlobalSeed(x8d8_updateFrameIdx);
|
||||
CParticleElectric::SetGlobalSeed(x8d8_updateFrameIdx);
|
||||
CDecal::SetGlobalSeed(x8d8_updateFrameIdx);
|
||||
|
|
|
@ -125,7 +125,7 @@ public:
|
|||
private:
|
||||
CBooModel* m_next = nullptr;
|
||||
CBooModel* m_prev = nullptr;
|
||||
size_t m_uniUpdateCount = 0;
|
||||
int m_uniUpdateCount = 0;
|
||||
TToken<CModel> m_modelTok;
|
||||
CModel* m_model;
|
||||
std::vector<CBooSurface>* x0_surfaces;
|
||||
|
|
|
@ -754,13 +754,13 @@ void CBooModel::UVAnimationBuffer::ProcessAnimation(u8*& bufOut, const UVAnimati
|
|||
case UVAnimation::Mode::HStrip:
|
||||
{
|
||||
float value = anim.vals[0] * anim.vals[2] * (anim.vals[3] + CGraphics::GetSecondsMod900());
|
||||
texMtxOut.vec[3].x = (float)(short)(float)(anim.vals[1] * fmod(value, 1.0f)) * anim.vals[2];
|
||||
texMtxOut.vec[3].x = (float)(short)(anim.vals[1] * fmod(value, 1.0f)) * anim.vals[2];
|
||||
break;
|
||||
}
|
||||
case UVAnimation::Mode::VStrip:
|
||||
{
|
||||
float value = anim.vals[0] * anim.vals[2] * (anim.vals[3] + CGraphics::GetSecondsMod900());
|
||||
texMtxOut.vec[3].y = (float)(short)(float)(anim.vals[1] * fmod(value, 1.0f)) * anim.vals[2];
|
||||
texMtxOut.vec[3].y = (float)(short)(anim.vals[1] * fmod(value, 1.0f)) * anim.vals[2];
|
||||
break;
|
||||
}
|
||||
case UVAnimation::Mode::Model:
|
||||
|
@ -792,7 +792,7 @@ void CBooModel::UVAnimationBuffer::ProcessAnimation(u8*& bufOut, const UVAnimati
|
|||
postMtxOut = zeus::CTransform(zeus::CMatrix3f(halfA, 0.0, 0.0,
|
||||
0.0, 0.0, halfA,
|
||||
0.0, 0.0, 0.0),
|
||||
zeus::CVector3f(xy, z, 1.0)).toMatrix4f();
|
||||
zeus::CVector3f(xy, z, 1.0)).toMatrix4f();
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
|
@ -997,15 +997,33 @@ boo::ObjToken<boo::IGraphicsBufferD> CBooModel::UpdateUniformData(const CModelFl
|
|||
}
|
||||
|
||||
const ModelInstance* inst;
|
||||
if (m_instances.size() <= m_uniUpdateCount)
|
||||
if (sharedLayoutBuf >= 0)
|
||||
{
|
||||
inst = const_cast<CBooModel*>(this)->PushNewModelInstance(sharedLayoutBuf);
|
||||
if (!inst)
|
||||
return nullptr;
|
||||
if (m_instances.size() <= sharedLayoutBuf)
|
||||
{
|
||||
do
|
||||
{
|
||||
inst = const_cast<CBooModel*>(this)->PushNewModelInstance(m_instances.size());
|
||||
if (!inst)
|
||||
return nullptr;
|
||||
} while (m_instances.size() <= sharedLayoutBuf);
|
||||
}
|
||||
else
|
||||
inst = &m_instances[sharedLayoutBuf];
|
||||
const_cast<CBooModel*>(this)->m_uniUpdateCount = sharedLayoutBuf + 1;
|
||||
}
|
||||
else
|
||||
inst = &m_instances[m_uniUpdateCount];
|
||||
++const_cast<CBooModel*>(this)->m_uniUpdateCount;
|
||||
{
|
||||
if (m_instances.size() <= m_uniUpdateCount)
|
||||
{
|
||||
inst = const_cast<CBooModel*>(this)->PushNewModelInstance(sharedLayoutBuf);
|
||||
if (!inst)
|
||||
return nullptr;
|
||||
}
|
||||
else
|
||||
inst = &m_instances[m_uniUpdateCount];
|
||||
++const_cast<CBooModel*>(this)->m_uniUpdateCount;
|
||||
}
|
||||
|
||||
if (inst->m_geomUniformBuffer)
|
||||
m_geomLayout->Update(flags, cskr, pose, x4_matSet, inst->m_geomUniformBuffer);
|
||||
|
@ -1139,7 +1157,7 @@ SShader::BuildShader(const hecl::HMDLMeta& meta, const MaterialSet::Material& ma
|
|||
reflectionType = hecl::Backend::ReflectionType::None;
|
||||
hecl::Runtime::ShaderTag tag(mat.heclIr,
|
||||
meta.colorCount, meta.uvCount, meta.weightCount,
|
||||
meta.weightCount * 4, 8, boo::Primitive(meta.topology),
|
||||
meta.weightCount * 4, boo::Primitive(meta.topology),
|
||||
reflectionType, true, true, true);
|
||||
return CModelShaders::g_ModelShaders->buildExtendedShader
|
||||
(tag, mat.heclIr, "CMDL", *CGraphics::g_BooFactory);
|
||||
|
|
|
@ -81,6 +81,9 @@ static const char* LightingShadowGLSL =
|
|||
"\n"
|
||||
"vec4 LightingShadowFunc(vec4 mvPosIn, vec4 mvNormIn)\n"
|
||||
"{\n"
|
||||
" vec2 shadowUV = vtf.extTcgs[0];\n"
|
||||
" shadowUV.y = 1.0 - shadowUV.y;\n"
|
||||
" \n"
|
||||
" vec4 ret = ambient;\n"
|
||||
" \n"
|
||||
" vec3 delta = mvPosIn.xyz - lights[0].pos.xyz;\n"
|
||||
|
@ -93,7 +96,7 @@ static const char* LightingShadowGLSL =
|
|||
" lights[0].angAtt[1] * angDot +\n"
|
||||
" lights[0].angAtt[0];\n"
|
||||
" ret += lights[0].color * clamp(angAtt, 0.0, 1.0) * att * clamp(dot(normalize(-delta), mvNormIn.xyz), 0.0, 1.0) *\n"
|
||||
" texture(extTex7, vtf.extTcgs[0]).r;\n"
|
||||
" texture(extTex7, shadowUV).r;\n"
|
||||
" \n"
|
||||
" for (int i=1 ; i<" _XSTR(URDE_MAX_LIGHTS) " ; ++i)\n"
|
||||
" {\n"
|
||||
|
|
|
@ -93,7 +93,7 @@ static const char* LightingShadowMetal =
|
|||
" lu.lights[0].angAtt[1] * angDot +\n"
|
||||
" lu.lights[0].angAtt[0];\n"
|
||||
" ret += lu.lights[0].color * saturate(angAtt) * att * saturate(dot(normalize(-delta), mvNormIn.xyz)) *\n"
|
||||
" extTex7.sample(clampSamp, vtf.extTcgs0);\n"
|
||||
" extTex7.sample(clampSamp, vtf.extTcgs0).r;\n"
|
||||
" \n"
|
||||
" for (int i=1 ; i<" _XSTR(URDE_MAX_LIGHTS) " ; ++i)\n"
|
||||
" {\n"
|
||||
|
|
|
@ -48,7 +48,8 @@ void CWorldShadowShader::blendPreviousShadow()
|
|||
{
|
||||
if (!m_prevQuad)
|
||||
m_prevQuad.emplace(EFilterType::Blend, m_tex.get());
|
||||
m_prevQuad->draw({1.f, 0.85f}, 1.f);
|
||||
zeus::CRectangle rect(0.f, 1.f, 1.f, -1.f);
|
||||
m_prevQuad->draw({1.f, 0.85f}, 1.f, rect);
|
||||
}
|
||||
|
||||
void CWorldShadowShader::resolveTexture()
|
||||
|
|
|
@ -54,6 +54,8 @@
|
|||
#include "CDependencyGroup.hpp"
|
||||
#include "MP1OriginalIDs.hpp"
|
||||
|
||||
#include <discord-rpc.h>
|
||||
|
||||
namespace urde
|
||||
{
|
||||
URDE_DECL_SPECIALIZE_SHADER(CParticleSwooshShaders)
|
||||
|
@ -437,12 +439,94 @@ void CMain::StreamNewGameState(CBitStreamReader& r, u32 idx)
|
|||
g_GameState->HintOptions().SetNextHintTime();
|
||||
}
|
||||
|
||||
static logvisor::Module DiscordLog("Discord");
|
||||
static const char* DISCORD_APPLICATION_ID = "402571593815031819";
|
||||
static int64_t DiscordStartTime;
|
||||
static CAssetId DiscordWorldSTRG;
|
||||
static TLockedToken<CStringTable> DiscordWorldSTRGObj;
|
||||
static std::string DiscordWorldName;
|
||||
static u32 DiscordItemPercent = 0xffffffff;
|
||||
static std::string DiscordState;
|
||||
|
||||
void CMain::InitializeDiscord()
|
||||
{
|
||||
DiscordStartTime = time(0);
|
||||
DiscordEventHandlers handlers = {};
|
||||
handlers.ready = HandleDiscordReady;
|
||||
handlers.disconnected = HandleDiscordDisconnected;
|
||||
handlers.errored = HandleDiscordErrored;
|
||||
Discord_Initialize(DISCORD_APPLICATION_ID, &handlers, 1, nullptr);
|
||||
}
|
||||
|
||||
void CMain::ShutdownDiscord()
|
||||
{
|
||||
DiscordWorldSTRGObj = TLockedToken<CStringTable>();
|
||||
Discord_Shutdown();
|
||||
}
|
||||
|
||||
void CMain::UpdateDiscordPresence(CAssetId worldSTRG)
|
||||
{
|
||||
bool updated = false;
|
||||
|
||||
if (worldSTRG != DiscordWorldSTRG)
|
||||
{
|
||||
DiscordWorldSTRG = worldSTRG;
|
||||
DiscordWorldSTRGObj = g_SimplePool->GetObj(SObjectTag{FOURCC('STRG'), worldSTRG});
|
||||
}
|
||||
if (DiscordWorldSTRGObj.IsLoaded())
|
||||
{
|
||||
DiscordWorldName = hecl::Char16ToUTF8(DiscordWorldSTRGObj->GetString(0));
|
||||
DiscordWorldSTRGObj = TLockedToken<CStringTable>();
|
||||
updated = true;
|
||||
}
|
||||
|
||||
if (g_GameState)
|
||||
{
|
||||
if (CPlayerState* pState = g_GameState->GetPlayerState().get())
|
||||
{
|
||||
u32 itemPercent = u32(std::ceil(pState->CalculateItemCollectionRate() * 100.f /
|
||||
pState->GetPickupTotal()));
|
||||
if (DiscordItemPercent != itemPercent)
|
||||
{
|
||||
DiscordItemPercent = itemPercent;
|
||||
DiscordState = hecl::Format("%d%%", itemPercent);
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (updated)
|
||||
{
|
||||
DiscordRichPresence discordPresence = {};
|
||||
discordPresence.state = DiscordState.c_str();
|
||||
discordPresence.details = DiscordWorldName.c_str();
|
||||
discordPresence.startTimestamp = DiscordStartTime;
|
||||
Discord_UpdatePresence(&discordPresence);
|
||||
}
|
||||
}
|
||||
|
||||
void CMain::HandleDiscordReady()
|
||||
{
|
||||
DiscordLog.report(logvisor::Info, "Discord Ready");
|
||||
}
|
||||
|
||||
void CMain::HandleDiscordDisconnected(int errorCode, const char* message)
|
||||
{
|
||||
DiscordLog.report(logvisor::Warning, "Discord Disconnected: %s", message);
|
||||
}
|
||||
|
||||
void CMain::HandleDiscordErrored(int errorCode, const char* message)
|
||||
{
|
||||
DiscordLog.report(logvisor::Error, "Discord Error: %s", message);
|
||||
}
|
||||
|
||||
void CMain::Init(const hecl::Runtime::FileStoreManager& storeMgr,
|
||||
hecl::CVarManager* cvarMgr,
|
||||
boo::IWindow* window,
|
||||
boo::IAudioVoiceEngine* voiceEngine,
|
||||
amuse::IBackendVoiceAllocator& backend)
|
||||
{
|
||||
InitializeDiscord();
|
||||
m_mainWindow = window;
|
||||
m_cvarMgr = cvarMgr;
|
||||
m_console = std::make_unique<hecl::Console>(m_cvarMgr);
|
||||
|
@ -524,6 +608,9 @@ bool CMain::Proc()
|
|||
*/
|
||||
x160_24_finished = true;
|
||||
}
|
||||
|
||||
Discord_RunCallbacks();
|
||||
|
||||
return x160_24_finished;
|
||||
}
|
||||
|
||||
|
@ -606,6 +693,7 @@ void CMain::Shutdown()
|
|||
TMultiBlendShader<CRandomStaticFilter>::Shutdown();
|
||||
CFluidPlaneShader::Shutdown();
|
||||
CGraphics::ShutdownBoo();
|
||||
ShutdownDiscord();
|
||||
}
|
||||
|
||||
boo::IWindow* CMain::GetMainWindow() const
|
||||
|
|
|
@ -262,6 +262,11 @@ private:
|
|||
bool m_needsWarmupClear = false;
|
||||
|
||||
void InitializeSubsystems(const hecl::Runtime::FileStoreManager& storeMgr);
|
||||
static void InitializeDiscord();
|
||||
static void ShutdownDiscord();
|
||||
static void HandleDiscordReady();
|
||||
static void HandleDiscordDisconnected(int errorCode, const char* message);
|
||||
static void HandleDiscordErrored(int errorCode, const char* message);
|
||||
|
||||
public:
|
||||
CMain(IFactory* resFactory, CSimplePool* resStore,
|
||||
|
@ -276,6 +281,8 @@ public:
|
|||
void SetMFGameBuilt(bool b) { x160_25_mfGameBuilt = b; }
|
||||
void SetScreenFading(bool b) { x160_26_screenFading = b; }
|
||||
|
||||
static void UpdateDiscordPresence(CAssetId worldSTRG = {});
|
||||
|
||||
//int RsMain(int argc, const boo::SystemChar* argv[]);
|
||||
void Init(const hecl::Runtime::FileStoreManager& storeMgr,
|
||||
hecl::CVarManager* cvarManager,
|
||||
|
|
|
@ -2922,9 +2922,9 @@ void CPlayer::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CState
|
|||
CActor::AcceptScriptMsg(msg, sender, mgr);
|
||||
}
|
||||
|
||||
void CPlayer::SetVisorSteam(float f1, float f2, float f3, CAssetId txtr, bool affectsThermal)
|
||||
void CPlayer::SetVisorSteam(float targetAlpha, float alphaInDur, float alphaOutDur, CAssetId txtr, bool affectsThermal)
|
||||
{
|
||||
x7a0_visorSteam.SetSteam(f1, f2, f3, txtr, affectsThermal);
|
||||
x7a0_visorSteam.SetSteam(targetAlpha, alphaInDur, alphaOutDur, txtr, affectsThermal);
|
||||
}
|
||||
|
||||
static const u16 skLeftStepSounds[] =
|
||||
|
|
|
@ -18,6 +18,14 @@ void CWorldShadow::EnableModelProjectedShadow(const zeus::CTransform& pos, s32 l
|
|||
texTransform = (texTransform * zeus::CTransform::Scale(float(M_SQRT2) * x64_objHalfExtent * f1)).inverse();
|
||||
texTransform = zeus::CTransform::Translate(0.5f, 0.f, 0.5f) * texTransform;
|
||||
CBooModel::EnableShadowMaps(m_shader.GetTexture().get(), texTransform);
|
||||
|
||||
#if CWORLDSHADOW_FEEDBACK
|
||||
if (!m_feedback)
|
||||
m_feedback.emplace(EFilterType::Blend, m_shader.GetTexture().get());
|
||||
|
||||
zeus::CRectangle rect(0.4f, 0.4f, 0.2f, 0.2f);
|
||||
m_feedback->draw(zeus::CColor::skWhite, 1.f, rect);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CWorldShadow::DisableModelProjectedShadow()
|
||||
|
@ -78,9 +86,6 @@ void CWorldShadow::BuildLightShadowTexture(const CStateManager& mgr, TAreaId aid
|
|||
x34_model = zeus::lookAt(centerPoint - zeus::CVector3f(0.f, 0.f, 0.1f), light.GetPosition());
|
||||
CGraphics::SetModelMatrix(x34_model);
|
||||
|
||||
m_shadowViewProj = CGraphics::GetPerspectiveProjectionMatrix(false) *
|
||||
CGraphics::g_CameraMatrix.toMatrix4f();
|
||||
|
||||
float extent = float(M_SQRT2) * x64_objHalfExtent;
|
||||
/* Depth test and write */
|
||||
/* Color white 100% alpha */
|
||||
|
@ -98,7 +103,7 @@ void CWorldShadow::BuildLightShadowTexture(const CStateManager& mgr, TAreaId aid
|
|||
CGraphics::SetModelMatrix(x34_model);
|
||||
/* No depth test or write */
|
||||
/* Color white 25% alpha */
|
||||
//m_shader.lightenShadow();
|
||||
m_shader.lightenShadow();
|
||||
}
|
||||
|
||||
if (motionBlur && !x88_blurReset)
|
||||
|
@ -106,7 +111,7 @@ void CWorldShadow::BuildLightShadowTexture(const CStateManager& mgr, TAreaId aid
|
|||
/* No depth test or write */
|
||||
/* Color white 85% alpha */
|
||||
/* Draw in shadow texture */
|
||||
//m_shader.blendPreviousShadow();
|
||||
m_shader.blendPreviousShadow();
|
||||
}
|
||||
|
||||
x88_blurReset = false;
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include "zeus/CAABox.hpp"
|
||||
#include "Graphics/Shaders/CWorldShadowShader.hpp"
|
||||
|
||||
#define CWORLDSHADOW_FEEDBACK 0
|
||||
|
||||
namespace urde
|
||||
{
|
||||
class CStateManager;
|
||||
|
@ -20,7 +22,9 @@ class CWorldShadow
|
|||
TAreaId x80_aid;
|
||||
s32 x84_lightIdx = -1;
|
||||
bool x88_blurReset = true;
|
||||
zeus::CMatrix4f m_shadowViewProj;
|
||||
#if CWORLDSHADOW_FEEDBACK
|
||||
std::experimental::optional<CTexturedQuadFilter> m_feedback;
|
||||
#endif
|
||||
public:
|
||||
CWorldShadow(u32 w, u32 h, bool rgba8);
|
||||
void EnableModelProjectedShadow(const zeus::CTransform& pos, s32 lightIdx, float f1);
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subproject commit b85758ec19ab37a317662eb93d7208eaae129e84
|
2
hecl
2
hecl
|
@ -1 +1 @@
|
|||
Subproject commit b9f410a2f87eb837ffc5937ed6a7cc637d91ac79
|
||||
Subproject commit 49cd887849d90aa17751d4388309c624aa6599a3
|
2
hecl-gui
2
hecl-gui
|
@ -1 +1 @@
|
|||
Subproject commit b9a0bec10b812738cbfdaa14ebef2e570b8c800d
|
||||
Subproject commit 3b70f8267645ba99f44e2f2a9f58a2fad7a27c36
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 2fb78f9cee01996f020d5af7592b37c5a0693b31
|
Loading…
Reference in New Issue