2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-08-10 20:59:05 +00:00

Working space warp effect for charge beam

This commit is contained in:
Jack Andersen 2018-02-12 20:46:59 -10:00
parent e263345b0a
commit 74ce62726d
12 changed files with 74 additions and 36 deletions

View File

@ -65,9 +65,10 @@ zeus::CVector3f CGameCamera::ConvertToScreenSpace(const zeus::CVector3f& v) cons
{ {
zeus::CVector3f rVec = x34_transform.transposeRotate(v - x34_transform.origin); zeus::CVector3f rVec = x34_transform.transposeRotate(v - x34_transform.origin);
if (rVec.x == 0.f && rVec.y == 0.f && rVec.z == 0.f) if (rVec.isZero())
return {-1.f, -1.f, 1.f}; return {-1.f, -1.f, 1.f};
rVec = zeus::CVector3f(rVec.x, rVec.z, -rVec.y);
zeus::CMatrix4f mtx = GetPerspectiveMatrix(); zeus::CMatrix4f mtx = GetPerspectiveMatrix();
return mtx.multiplyOneOverW(rVec); return mtx.multiplyOneOverW(rVec);
} }

View File

@ -13,7 +13,7 @@ namespace urde
CParticleDatabase::CParticleDatabase() CParticleDatabase::CParticleDatabase()
{ {
xb4_24_active = true; xb4_24_active = true;
xb4_25_drawingEnds = false; xb4_25_anySystemsDrawnWithModel = false;
} }
void CParticleDatabase::CacheParticleDesc(const SObjectTag &tag) void CParticleDatabase::CacheParticleDesc(const SObjectTag &tag)
@ -237,7 +237,7 @@ void CParticleDatabase::Update(float dt, const CPoseAsTransforms& pose, const CC
UpdateParticleGenDB(dt, pose, charInfo, xf, scale, stateMgr, x8c_firstDraw, false); UpdateParticleGenDB(dt, pose, charInfo, xf, scale, stateMgr, x8c_firstDraw, false);
UpdateParticleGenDB(dt, pose, charInfo, xf, scale, stateMgr, xa0_lastDraw, false); UpdateParticleGenDB(dt, pose, charInfo, xf, scale, stateMgr, xa0_lastDraw, false);
xb4_25_drawingEnds = (x50_firstDrawLoop.size() || x64_lastDrawLoop.size() || x8c_firstDraw.size() || xa0_lastDraw.size()); xb4_25_anySystemsDrawnWithModel = (x50_firstDrawLoop.size() || x64_lastDrawLoop.size() || x8c_firstDraw.size() || xa0_lastDraw.size());
} }
void CParticleDatabase::RenderParticleGenMap(const std::map<std::string, std::unique_ptr<CParticleGenInfo>>& map) void CParticleDatabase::RenderParticleGenMap(const std::map<std::string, std::unique_ptr<CParticleGenInfo>>& map)
@ -513,7 +513,7 @@ void CParticleDatabase::InsertParticleGen(bool oneShot, int flags, std::string_v
useMap->insert(std::make_pair(std::string(name), std::move(gen))); useMap->insert(std::make_pair(std::string(name), std::move(gen)));
if (flags & 0x60) if (flags & 0x60)
xb4_25_drawingEnds = true; xb4_25_anySystemsDrawnWithModel = true;
} }
} }

View File

@ -27,7 +27,7 @@ class CParticleDatabase
std::map<std::string, std::unique_ptr<CParticleGenInfo>> x8c_firstDraw; std::map<std::string, std::unique_ptr<CParticleGenInfo>> x8c_firstDraw;
std::map<std::string, std::unique_ptr<CParticleGenInfo>> xa0_lastDraw; std::map<std::string, std::unique_ptr<CParticleGenInfo>> xa0_lastDraw;
bool xb4_24_active : 1; bool xb4_24_active : 1;
bool xb4_25_drawingEnds : 1; bool xb4_25_anySystemsDrawnWithModel : 1;
static void SetModulationColorAllActiveEffectsForParticleDB(const zeus::CColor& color, static void SetModulationColorAllActiveEffectsForParticleDB(const zeus::CColor& color,
std::map<std::string, std::unique_ptr<CParticleGenInfo>>& map); std::map<std::string, std::unique_ptr<CParticleGenInfo>>& map);
@ -69,6 +69,7 @@ public:
const zeus::CVector3f& scale, CStateManager& mgr, TAreaId aid, bool oneShot, int lightId); const zeus::CVector3f& scale, CStateManager& mgr, TAreaId aid, bool oneShot, int lightId);
void InsertParticleGen(bool oneShot, int flags, std::string_view name, void InsertParticleGen(bool oneShot, int flags, std::string_view name,
std::unique_ptr<CParticleGenInfo>&& gen); std::unique_ptr<CParticleGenInfo>&& gen);
bool AreAnySystemsDrawnWithModel() const { return xb4_25_anySystemsDrawnWithModel; }
}; };
} }

View File

@ -141,6 +141,7 @@ void CSpaceWarpFilter::draw(const zeus::CVector3f& pt)
clipRect.x4_left += CGraphics::g_CroppedViewport.x4_left; clipRect.x4_left += CGraphics::g_CroppedViewport.x4_left;
clipRect.x8_top += CGraphics::g_CroppedViewport.x8_top; clipRect.x8_top += CGraphics::g_CroppedViewport.x8_top;
clipRect.x8_top = g_Viewport.xc_height - clipRect.x10_height - clipRect.x8_top;
CGraphics::ResolveSpareTexture(clipRect); CGraphics::ResolveSpareTexture(clipRect);
m_uniform.m_strength.x = m_uniform.m_matrix[0][0] * m_strength * 0.5f * m_uniform.m_strength.x = m_uniform.m_matrix[0][0] * m_strength * 0.5f *

View File

@ -48,7 +48,8 @@ BOO_GLSL_BINDING_HEAD
"TBINDING1 uniform sampler2D indTex;\n" "TBINDING1 uniform sampler2D indTex;\n"
"void main()\n" "void main()\n"
"{\n" "{\n"
" colorOut = texture(sceneTex, vtf.sceneUv + (texture(indTex, vtf.indUv).xy * vec2(2.0) - vec2(1.0 - 1.0 / 256.0)) * vtf.strength.xy);\n" " vec2 indUv = texture(indTex, vtf.indUv).xy * vec2(2.0) - vec2(1.0 - 1.0 / 256.0);\n"
" colorOut = vec4(texture(sceneTex, vtf.sceneUv + indUv * vtf.strength.xy).rgb, 1.0);\n"
"}\n"; "}\n";
URDE_DECL_SPECIALIZE_SHADER(CSpaceWarpFilter) URDE_DECL_SPECIALIZE_SHADER(CSpaceWarpFilter)

View File

@ -50,7 +50,8 @@ static const char* FS =
"\n" "\n"
"float4 main(in VertToFrag vtf) : SV_Target0\n" "float4 main(in VertToFrag vtf) : SV_Target0\n"
"{\n" "{\n"
" return sceneTex.Sample(samp, vtf.sceneUv + (indTex.Sample(samp, vtf.indUv).xy * float2(2.0, 2.0) - float2(1.0 - 1.0 / 256.0, 1.0 - 1.0 / 256.0)) * vtf.strength.xy);\n" " float2 indUv = indTex.Sample(samp, vtf.indUv).xy * float2(2.0, 2.0) - float2(1.0 - 1.0 / 256.0, 1.0 - 1.0 / 256.0);\n"
" return float4(sceneTex.Sample(samp, vtf.sceneUv + indUv * vtf.strength.xy).rgb, 1.0);\n"
"}\n"; "}\n";
URDE_DECL_SPECIALIZE_SHADER(CSpaceWarpFilter) URDE_DECL_SPECIALIZE_SHADER(CSpaceWarpFilter)

View File

@ -54,7 +54,8 @@ static const char* FS =
" texture2d<float> sceneTex [[ texture(0) ]],\n" " texture2d<float> sceneTex [[ texture(0) ]],\n"
" texture2d<float> indTex [[ texture(1) ]])\n" " texture2d<float> indTex [[ texture(1) ]])\n"
"{\n" "{\n"
" return sceneTex.sample(samp, vtf.sceneUv + (indTex.sample(samp, vtf.indUv).xy * float2(2.0) - float2(1.0 - 1.0 / 256.0)) * vtf.strength.xy);\n" " float2 indUv = indTex.sample(samp, vtf.indUv).xy * float2(2.0) - float2(1.0 - 1.0 / 256.0);\n"
" return float4(sceneTex.sample(samp, vtf.sceneUv + indUv * vtf.strength.xy).rgb, 1.0);\n"
"}\n"; "}\n";
URDE_DECL_SPECIALIZE_SHADER(CSpaceWarpFilter) URDE_DECL_SPECIALIZE_SHADER(CSpaceWarpFilter)

View File

@ -9,10 +9,11 @@ namespace urde
CWeapon::CWeapon(TUniqueId uid, TAreaId aid, bool active, TUniqueId owner, EWeaponType type, CWeapon::CWeapon(TUniqueId uid, TAreaId aid, bool active, TUniqueId owner, EWeaponType type,
std::string_view name, const zeus::CTransform& xf, const CMaterialFilter& filter, std::string_view name, const zeus::CTransform& xf, const CMaterialFilter& filter,
const CMaterialList& mList, const CDamageInfo&, EProjectileAttrib attribs, CModelData&& mData) const CMaterialList& mList, const CDamageInfo& dInfo, EProjectileAttrib attribs, CModelData&& mData)
: CActor(uid, active, name, CEntityInfo(aid, CEntity::NullConnectionList), xf, std::move(mData), mList, : CActor(uid, active, name, CEntityInfo(aid, CEntity::NullConnectionList), xf, std::move(mData), mList,
CActorParameters::None(), kInvalidUniqueId) CActorParameters::None(), kInvalidUniqueId),
, xf8_filter(filter) xe8_projectileAttribs(attribs), xec_ownerId(owner), xf0_weaponType(type), xf8_filter(filter),
x110_origDamageInfo(dInfo), x12c_curDamageInfo(dInfo)
{ {
} }

View File

@ -14,15 +14,13 @@ protected:
EProjectileAttrib xe8_projectileAttribs; EProjectileAttrib xe8_projectileAttribs;
TUniqueId xec_ownerId; TUniqueId xec_ownerId;
EWeaponType xf0_weaponType; EWeaponType xf0_weaponType;
u32 xf4_;
CMaterialFilter xf8_filter; CMaterialFilter xf8_filter;
u32 x10c_;
CDamageInfo x110_origDamageInfo; CDamageInfo x110_origDamageInfo;
CDamageInfo x12c_curDamageInfo; CDamageInfo x12c_curDamageInfo;
float x148_curTime; float x148_curTime = 0.f;
float x14c_damageFalloffSpeed; float x14c_damageFalloffSpeed = 0.f;
float x150_damageDuration; float x150_damageDuration = 0.f;
float x154_interferenceDuration; float x154_interferenceDuration = 0.f;
public: public:
CWeapon(TUniqueId uid, TAreaId aid, bool active, TUniqueId owner, EWeaponType type, CWeapon(TUniqueId uid, TAreaId aid, bool active, TUniqueId owner, EWeaponType type,
std::string_view name, const zeus::CTransform& xf, const CMaterialFilter& filter, std::string_view name, const zeus::CTransform& xf, const CMaterialFilter& filter,

View File

@ -45,10 +45,10 @@ CActor::CActor(TUniqueId uid, bool active, std::string_view name, const CEntityI
xe4_31_lightsDirty = true; xe4_31_lightsDirty = true;
xe5_27_useInSortedLists = true; xe5_27_useInSortedLists = true;
xe5_28_callTouch = true; xe5_28_callTouch = true;
xe5_29_globalTimeProvider = params.x58_24_; xe5_29_globalTimeProvider = params.x58_24_globalTimeProvider;
xe5_30_ = params.x58_26_; xe5_30_renderUnsorted = params.x58_26_renderUnsorted;
xe6_27_thermalVisorFlags = u8(params.x58_25_thermalHeat ? 2 : 1); xe6_27_thermalVisorFlags = u8(params.x58_25_thermalHeat ? 2 : 1);
xe6_29_prePostParticles = true; xe6_29_renderParticleDBInside = true;
xe6_31_targetableVisorFlags = params.GetVisorParameters().GetMask(); xe6_31_targetableVisorFlags = params.GetVisorParameters().GetMask();
xe7_27_enableRender = true; xe7_27_enableRender = true;
xe7_29_actorActive = active; xe7_29_actorActive = active;
@ -205,7 +205,7 @@ void CActor::AddToRenderer(const zeus::CFrustum& planes, const CStateManager& mg
if (!x64_modelData || x64_modelData->IsNull()) if (!x64_modelData || x64_modelData->IsNull())
return; return;
if (xe6_29_prePostParticles) if (xe6_29_renderParticleDBInside)
x64_modelData->RenderParticles(planes); x64_modelData->RenderParticles(planes);
if (!xe4_30_outOfFrustum) if (!xe4_30_outOfFrustum)
@ -270,11 +270,22 @@ void CActor::RenderInternal(const CStateManager& mgr) const
x64_modelData->Render(which, x34_transform, x90_actorLights.get(), xb4_drawFlags); x64_modelData->Render(which, x34_transform, x90_actorLights.get(), xb4_drawFlags);
} }
bool CActor::IsModelOpaque(const CStateManager& mgr) const
{
if (xe5_31_pointGeneratorParticles)
return false;
if (!x64_modelData || x64_modelData->IsNull())
return true;
if (xb4_drawFlags.x0_blendMode > 4)
return false;
return x64_modelData->IsDefinitelyOpaque(CModelData::GetRenderingModel(mgr));
}
void CActor::Render(const CStateManager& mgr) const void CActor::Render(const CStateManager& mgr) const
{ {
if (x64_modelData && !x64_modelData->IsNull()) if (x64_modelData && !x64_modelData->IsNull())
{ {
bool renderPrePostParticles = xe6_29_prePostParticles && x64_modelData && x64_modelData->HasAnimData(); bool renderPrePostParticles = xe6_29_renderParticleDBInside && x64_modelData && x64_modelData->HasAnimData();
if (renderPrePostParticles) if (renderPrePostParticles)
x64_modelData->AnimationData()->GetParticleDB().RenderSystemsToBeDrawnFirst(); x64_modelData->AnimationData()->GetParticleDB().RenderSystemsToBeDrawnFirst();
@ -306,8 +317,14 @@ void CActor::Render(const CStateManager& mgr) const
DrawTouchBounds(); DrawTouchBounds();
} }
bool CActor::CanRenderUnsorted(const CStateManager&) const bool CActor::CanRenderUnsorted(const CStateManager& mgr) const
{ {
if (x64_modelData && x64_modelData->HasAnimData() &&
x64_modelData->GetAnimationData()->GetParticleDB().AreAnySystemsDrawnWithModel() &&
xe6_29_renderParticleDBInside)
return false;
else if (xe5_30_renderUnsorted || IsModelOpaque(mgr))
return true;
return false; return false;
} }
@ -321,12 +338,15 @@ void CActor::CalculateRenderBounds()
CHealthInfo* CActor::HealthInfo(CStateManager&) { return nullptr; } CHealthInfo* CActor::HealthInfo(CStateManager&) { return nullptr; }
const CDamageVulnerability* CActor::GetDamageVulnerability() const { return nullptr; } const CDamageVulnerability* CActor::GetDamageVulnerability() const
{
return &CDamageVulnerability::NormalVulnerabilty();
}
const CDamageVulnerability* CActor::GetDamageVulnerability(const zeus::CVector3f&, const zeus::CVector3f&, const CDamageVulnerability* CActor::GetDamageVulnerability(const zeus::CVector3f&, const zeus::CVector3f&,
const CDamageInfo&) const const CDamageInfo&) const
{ {
return nullptr; return GetDamageVulnerability();
} }
rstl::optional_object<zeus::CAABox> CActor::GetTouchBounds() const { return {}; } rstl::optional_object<zeus::CAABox> CActor::GetTouchBounds() const { return {}; }
@ -339,7 +359,16 @@ zeus::CVector3f CActor::GetAimPosition(const CStateManager&, float) const { retu
zeus::CVector3f CActor::GetHomingPosition(const CStateManager& mgr, float f) const { return GetAimPosition(mgr, f); } zeus::CVector3f CActor::GetHomingPosition(const CStateManager& mgr, float f) const { return GetAimPosition(mgr, f); }
zeus::CVector3f CActor::GetScanObjectIndicatorPosition(const CStateManager&) const { return {}; } zeus::CVector3f CActor::GetScanObjectIndicatorPosition(const CStateManager& mgr) const
{
const CGameCamera* cam = mgr.GetCameraManager()->GetCurrentCamera(mgr);
zeus::CVector3f orbitPos = GetOrbitPosition(mgr);
float camToOrbitPos = (cam->GetTranslation() - orbitPos).magnitude();
zeus::CVector3f boundsExtent = x9c_renderBounds.max - x9c_renderBounds.min;
float distFac = std::min(std::max(boundsExtent.x, std::max(boundsExtent.y, boundsExtent.z)) * 0.5f,
camToOrbitPos - cam->GetNearClipDistance() - 0.1f);
return orbitPos - (orbitPos - cam->GetTranslation()).normalized() * distFac;
}
void CActor::RemoveEmitter() void CActor::RemoveEmitter()
{ {

View File

@ -65,11 +65,11 @@ protected:
bool xe5_27_useInSortedLists : 1; bool xe5_27_useInSortedLists : 1;
bool xe5_28_callTouch : 1; bool xe5_28_callTouch : 1;
bool xe5_29_globalTimeProvider : 1; bool xe5_29_globalTimeProvider : 1;
bool xe5_30_ : 1; bool xe5_30_renderUnsorted : 1;
bool xe5_31_pointGeneratorParticles : 1; bool xe5_31_pointGeneratorParticles : 1;
u8 xe6_24_fluidCounter : 3; u8 xe6_24_fluidCounter : 3;
u8 xe6_27_thermalVisorFlags : 2; // 1: thermal cold, 2: thermal hot u8 xe6_27_thermalVisorFlags : 2; // 1: thermal cold, 2: thermal hot
bool xe6_29_prePostParticles : 1; bool xe6_29_renderParticleDBInside : 1;
bool xe6_30_enablePitchBend : 1; bool xe6_30_enablePitchBend : 1;
u8 xe6_31_targetableVisorFlags : 4; u8 xe6_31_targetableVisorFlags : 4;
bool xe7_27_enableRender : 1; bool xe7_27_enableRender : 1;
@ -84,6 +84,7 @@ protected:
void UpdateSfxEmitters(); void UpdateSfxEmitters();
void DrawTouchBounds() const; void DrawTouchBounds() const;
void RenderInternal(const CStateManager& mgr) const; void RenderInternal(const CStateManager& mgr) const;
bool IsModelOpaque(const CStateManager& mgr) const;
public: public:
enum class EFluidState enum class EFluidState

View File

@ -21,9 +21,9 @@ class CActorParameters
{ {
struct struct
{ {
bool x58_24_ : 1; bool x58_24_globalTimeProvider : 1;
bool x58_25_thermalHeat : 1; bool x58_25_thermalHeat : 1;
bool x58_26_ : 1; bool x58_26_renderUnsorted : 1;
bool x58_27_noSortThermal : 1; bool x58_27_noSortThermal : 1;
}; };
u32 _dummy = 0; u32 _dummy = 0;
@ -33,19 +33,22 @@ class CActorParameters
float x64_thermalMag = 0.f; float x64_thermalMag = 0.f;
public: public:
CActorParameters() : x58_24_(true), x58_25_thermalHeat(false), x58_26_(false), x58_27_noSortThermal(false) {} CActorParameters() : x58_24_globalTimeProvider(true), x58_25_thermalHeat(false),
x58_26_renderUnsorted(false), x58_27_noSortThermal(false) {}
CActorParameters(const CLightParameters& lightParms, const CScannableParameters& scanParms, CActorParameters(const CLightParameters& lightParms, const CScannableParameters& scanParms,
const std::pair<CAssetId, CAssetId>& xrayAssets, const std::pair<CAssetId, CAssetId>& thermalAssets, const std::pair<CAssetId, CAssetId>& xrayAssets,
const CVisorParameters& visorParms, bool b1, bool thermalHeat, bool c, bool d) const std::pair<CAssetId, CAssetId>& thermalAssets,
const CVisorParameters& visorParms, bool globalTimeProvider, bool thermalHeat,
bool renderUnsorted, bool noSortThermal)
: x0_lightParms(lightParms) : x0_lightParms(lightParms)
, x40_scanParms(scanParms) , x40_scanParms(scanParms)
, x44_xrayAssets(xrayAssets) , x44_xrayAssets(xrayAssets)
, x4c_thermalAssets(thermalAssets) , x4c_thermalAssets(thermalAssets)
, x54_visorParms(visorParms) , x54_visorParms(visorParms)
, x58_24_(b1) , x58_24_globalTimeProvider(globalTimeProvider)
, x58_25_thermalHeat(thermalHeat) , x58_25_thermalHeat(thermalHeat)
, x58_26_(c) , x58_26_renderUnsorted(renderUnsorted)
, x58_27_noSortThermal(d) , x58_27_noSortThermal(noSortThermal)
{ {
} }
CActorParameters Scannable(const CScannableParameters& sParms) const CActorParameters Scannable(const CScannableParameters& sParms) const