mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-14 16:06:10 +00:00
More CCubeMaterial, more CGraphics, more aurora::gx
This commit is contained in:
@@ -76,17 +76,17 @@ void CCubeMaterial::SetCurrent(const CModelFlags& flags, const CCubeSurface& sur
|
||||
|
||||
u32 finalKColorCount = 0;
|
||||
if (matFlags & CCubeMaterialFlagBits::fKonstValues) {
|
||||
u32 konstCount = *reinterpret_cast<const u32*>(materialDataCur);
|
||||
u32 konstCount = SBig(*reinterpret_cast<const u32*>(materialDataCur));
|
||||
finalKColorCount = konstCount;
|
||||
materialDataCur += 4;
|
||||
for (u32 i = 0; i < konstCount; ++i) {
|
||||
u32 kColor = *reinterpret_cast<const u32*>(materialDataCur);
|
||||
u32 kColor = SBig(*reinterpret_cast<const u32*>(materialDataCur));
|
||||
materialDataCur += 4;
|
||||
// TODO set KColor
|
||||
aurora::gfx::set_tev_k_color(static_cast<GX::TevKColorID>(i), kColor);
|
||||
}
|
||||
}
|
||||
|
||||
u32 blendFactors = *reinterpret_cast<const u32*>(materialDataCur);
|
||||
u32 blendFactors = SBig(*reinterpret_cast<const u32*>(materialDataCur));
|
||||
materialDataCur += 4;
|
||||
if (g_Renderer->IsInAreaDraw()) {
|
||||
// TODO blackout fog, additive blend
|
||||
@@ -128,25 +128,27 @@ void CCubeMaterial::SetCurrent(const CModelFlags& flags, const CCubeSurface& sur
|
||||
finalTevCount = firstTev + 1;
|
||||
u32 ccFlags = SBig(*reinterpret_cast<const u32*>(materialDataCur + 8));
|
||||
finalCCFlags = ccFlags;
|
||||
u32 outputReg = ccFlags >> 9 & 0x3;
|
||||
if (outputReg == 1) { // TevReg0
|
||||
auto outputReg = static_cast<GX::TevRegID>(ccFlags >> 9 & 0x3);
|
||||
if (outputReg == GX::TEVREG0) {
|
||||
materialDataCur += 20;
|
||||
texMapTexCoordFlags += 1;
|
||||
finalCCFlags = SBig(*reinterpret_cast<const u32*>(materialDataCur + 8));
|
||||
// Set TevReg0 = 0xc0c0c0c0
|
||||
aurora::gfx::set_tev_reg_color(GX::TEVREG0, 0xc0c0c0c0);
|
||||
}
|
||||
finalACFlags = SBig(*reinterpret_cast<const u32*>(materialDataCur + 12));
|
||||
HandleTev(firstTev, materialDataCur, texMapTexCoordFlags, CCubeModel::sRenderModelShadow);
|
||||
HandleTev(firstTev, reinterpret_cast<const u32*>(materialDataCur), texMapTexCoordFlags,
|
||||
CCubeModel::sRenderModelShadow);
|
||||
usesTevReg2 = false;
|
||||
} else {
|
||||
finalTevCount = firstTev + matTevCount;
|
||||
for (u32 i = firstTev; i < finalTevCount; ++i) {
|
||||
HandleTev(i, materialDataCur, texMapTexCoordFlags, CCubeModel::sRenderModelShadow && i == firstTev);
|
||||
HandleTev(i, reinterpret_cast<const u32*>(materialDataCur), texMapTexCoordFlags,
|
||||
CCubeModel::sRenderModelShadow && i == firstTev);
|
||||
u32 ccFlags = SBig(*reinterpret_cast<const u32*>(materialDataCur + 8));
|
||||
finalCCFlags = ccFlags;
|
||||
finalACFlags = SBig(*reinterpret_cast<const u32*>(materialDataCur + 12));
|
||||
u32 outputReg = ccFlags >> 9 & 0x3;
|
||||
if (outputReg == 3) { // TevReg2
|
||||
auto outputReg = static_cast<GX::TevRegID>(ccFlags >> 9 & 0x3);
|
||||
if (outputReg == GX::TEVREG2) {
|
||||
usesTevReg2 = true;
|
||||
}
|
||||
materialDataCur += 20;
|
||||
@@ -310,10 +312,34 @@ u32 CCubeMaterial::HandleColorChannels(u32 chanCount, u32 firstChan) {
|
||||
return chanCount;
|
||||
}
|
||||
|
||||
void CCubeMaterial::HandleTev(u32 tevCur, const u8* materialDataCur, const u32* texMapTexCoordFlags,
|
||||
void CCubeMaterial::HandleTev(u32 tevCur, const u32* materialDataCur, const u32* texMapTexCoordFlags,
|
||||
bool shadowMapsEnabled) {
|
||||
u32 colorArgs = shadowMapsEnabled ? 0x7a04f : SBig(*materialDataCur);
|
||||
// CGX::SetStandardDirectTev_Compressed
|
||||
const u32 colorArgs = shadowMapsEnabled ? 0x7a04f : SBig(materialDataCur[0]);
|
||||
const u32 alphaArgs = SBig(materialDataCur[1]);
|
||||
const u32 colorOps = SBig(materialDataCur[2]);
|
||||
const u32 alphaOps = SBig(materialDataCur[3]);
|
||||
|
||||
// GXSetTevDirect(tevCur);
|
||||
const CTevCombiners::ColorPass colPass{colorArgs};
|
||||
const CTevCombiners::AlphaPass alphaPass{alphaArgs};
|
||||
const CTevCombiners::CTevOp colorOp{colorOps};
|
||||
const CTevCombiners::CTevOp alphaOp{alphaOps};
|
||||
// TODO does this actually change anything?
|
||||
// if (colorOps == alphaOps && ((colorOps & 0x1FF) == 0x100)) {
|
||||
// colorOp = {true, GX::TEV_ADD, GX::TB_ZERO, GX::CS_SCALE_1, colorOp.x10_regId};
|
||||
// alphaOp = {true, GX::TEV_ADD, GX::TB_ZERO, GX::CS_SCALE_1, colorOp.x10_regId};
|
||||
// }
|
||||
aurora::gfx::update_tev_stage(static_cast<ERglTevStage>(tevCur), colPass, alphaPass, colorOp, alphaOp);
|
||||
|
||||
u32 tmtcFlags = SBig(*texMapTexCoordFlags);
|
||||
u32 matFlags = SBig(materialDataCur[4]);
|
||||
aurora::gfx::set_tev_order(static_cast<GX::TevStageID>(tevCur), static_cast<GX::TexCoordID>(tmtcFlags & 0xFF),
|
||||
static_cast<GX::TexMapID>(tmtcFlags >> 8 & 0xFF),
|
||||
static_cast<GX::ChannelID>(matFlags & 0xFF));
|
||||
aurora::gfx::set_tev_k_color_sel(static_cast<GX::TevStageID>(tevCur),
|
||||
static_cast<GX::TevKColorSel>(matFlags >> 0x8 & 0xFF));
|
||||
aurora::gfx::set_tev_k_alpha_sel(static_cast<GX::TevStageID>(tevCur),
|
||||
static_cast<GX::TevKAlphaSel>(matFlags >> 0x10 & 0xFF));
|
||||
}
|
||||
|
||||
u32 CCubeMaterial::HandleAnimatedUV(const u32* uvAnim, u32 texMtx, u32 pttTexMtx) {
|
||||
@@ -409,17 +435,27 @@ u32 CCubeMaterial::HandleReflection(bool usesTevReg2, u32 indTexSlot, u32 r5, u3
|
||||
} else {
|
||||
// GX_CC_KONST
|
||||
}
|
||||
// set reflection kcolor
|
||||
aurora::gfx::set_tev_k_color(static_cast<GX::TevKColorID>(finalKColorCount),
|
||||
zeus::CColor{sReflectionAlpha, sReflectionAlpha});
|
||||
aurora::gfx::set_tev_k_color_sel(static_cast<GX::TevStageID>(finalTevCount),
|
||||
static_cast<GX::TevKColorSel>(GX::TEV_KCSEL_K0 + finalKColorCount));
|
||||
|
||||
const auto stage = static_cast<GX::TevStageID>(finalTevCount + out);
|
||||
// tex = g_Renderer->GetRealReflection
|
||||
// tex.Load(texCount, 0)
|
||||
|
||||
// TODO
|
||||
|
||||
finalACFlags = 0;
|
||||
finalCCFlags = 0;
|
||||
|
||||
// aurora::gfx::set_tev_order(stage, ...)
|
||||
|
||||
return out + 1;
|
||||
}
|
||||
|
||||
void CCubeMaterial::DoPassthru(u32 finalTevCount) {
|
||||
// TODO
|
||||
aurora::gfx::disable_tev_stage(static_cast<ERglTevStage>(finalTevCount));
|
||||
}
|
||||
|
||||
void CCubeMaterial::DoModelShadow(u32 texCount, u32 tcgCount) {
|
||||
|
||||
@@ -96,7 +96,7 @@ private:
|
||||
static void SetupBlendMode(u32 blendFactors, const CModelFlags& flags, bool alphaTest);
|
||||
static void HandleDepth(CModelFlagsFlags modelFlags, CCubeMaterialFlags matFlags);
|
||||
static u32 HandleColorChannels(u32 chanCount, u32 firstChan);
|
||||
static void HandleTev(u32 tevCur, const u8* materialDataCur, const u32* texMapTexCoordFlags, bool shadowMapsEnabled);
|
||||
static void HandleTev(u32 tevCur, const u32* materialDataCur, const u32* texMapTexCoordFlags, bool shadowMapsEnabled);
|
||||
static u32 HandleAnimatedUV(const u32* uvAnim, u32 texMtx, u32 pttTexMtx);
|
||||
static void HandleTransparency(u32& finalTevCount, u32& finalKColorCount, const CModelFlags& modelFlags,
|
||||
u32 blendFactors, u32& finalCCFlags, u32& finalACFlags);
|
||||
|
||||
@@ -472,14 +472,11 @@ void CCubeRenderer::DoThermalBlendHot() {}
|
||||
u32 CCubeRenderer::GetStaticWorldDataSize() { return 0; }
|
||||
|
||||
void CCubeRenderer::SetGXRegister1Color(const zeus::CColor& color) {
|
||||
CGraphics::g_ColorRegs[1] = color;
|
||||
aurora::gfx::set_gx_reg1_color(color);
|
||||
aurora::gfx::set_tev_reg_color(GX::TevRegID::TEVREG1, color);
|
||||
}
|
||||
|
||||
void CCubeRenderer::SetWorldLightFadeLevel(float level) { x2fc_tevReg1Color = zeus::CColor(level, level, level, 1.f); }
|
||||
|
||||
void CCubeRenderer::SetWorldLightMultiplyColor(const zeus::CColor& color) { CGraphics::g_ColorRegs[2] = color; }
|
||||
|
||||
void CCubeRenderer::PrepareDynamicLights(const std::vector<CLight>& lights) {}
|
||||
void CCubeRenderer::AllocatePhazonSuitMaskTexture() {}
|
||||
void CCubeRenderer::DrawPhazonSuitIndirectEffect(const zeus::CColor& nonIndirectMod,
|
||||
@@ -511,4 +508,13 @@ void CCubeRenderer::SetupCGraphicsState() {
|
||||
// CGX::SetChanCtrl(EChannelId::Channel1, false, GX::SRC_REG, GX::LIGHT_NULL, GX::DF_NONE, GX::AF_NONE);
|
||||
CCubeMaterial::EnsureTevsDirect();
|
||||
}
|
||||
|
||||
void CCubeRenderer::SetupRendererStates(bool depthWrite) {
|
||||
CGraphics::DisableAllLights();
|
||||
CGraphics::SetModelMatrix({});
|
||||
CGraphics::SetAmbientColor(zeus::skBlack);
|
||||
CGraphics::SetDepthWriteMode(true, ERglEnum::LEqual, depthWrite);
|
||||
CCubeMaterial::ResetCachedMaterials();
|
||||
aurora::gfx::set_tev_reg_color(GX::TEVREG1, x2fc_tevReg1Color);
|
||||
}
|
||||
} // namespace metaforce
|
||||
|
||||
@@ -195,10 +195,10 @@ public:
|
||||
u32 GetStaticWorldDataSize() override;
|
||||
void SetGXRegister1Color(const zeus::CColor& color) override;
|
||||
void SetWorldLightFadeLevel(float level) override;
|
||||
void SetWorldLightMultiplyColor(const zeus::CColor& color) override;
|
||||
void PrepareDynamicLights(const std::vector<CLight>& lights) override;
|
||||
|
||||
// Non-virtual functions
|
||||
void SetupRendererStates(bool depthWrite);
|
||||
void AllocatePhazonSuitMaskTexture();
|
||||
void DrawPhazonSuitIndirectEffect(const zeus::CColor& nonIndirectMod, const TLockedToken<CTexture>& indTex,
|
||||
const zeus::CColor& indirectMod, float blurRadius, float scale, float offX,
|
||||
@@ -212,7 +212,6 @@ public:
|
||||
void RenderBucketItems(const CAreaListItem* lights);
|
||||
void DrawRenderBucketsDebug() {}
|
||||
|
||||
void SetupRendererStates(bool b) {}
|
||||
// Getters
|
||||
[[nodiscard]] bool IsInAreaDraw() const { return x318_30_inAreaDraw; }
|
||||
[[nodiscard]] bool IsReflectionDirty() const { return x318_24_refectionDirty; }
|
||||
|
||||
@@ -12,15 +12,12 @@
|
||||
namespace metaforce {
|
||||
CGraphics::CProjectionState CGraphics::g_Proj;
|
||||
CFogState CGraphics::g_Fog;
|
||||
std::array<zeus::CColor, 3> CGraphics::g_ColorRegs{};
|
||||
float CGraphics::g_ProjAspect = 1.f;
|
||||
u32 CGraphics::g_NumLightsActive = 0;
|
||||
u32 CGraphics::g_NumBreakpointsWaiting = 0;
|
||||
u32 CGraphics::g_FlippingState;
|
||||
bool CGraphics::g_LastFrameUsedAbove = false;
|
||||
bool CGraphics::g_InterruptLastFrameUsedAbove = false;
|
||||
ERglLightBits CGraphics::g_LightActive = ERglLightBits::None;
|
||||
ERglLightBits CGraphics::g_LightsWereOn = ERglLightBits::None;
|
||||
std::bitset<aurora::gfx::MaxLights> CGraphics::g_LightActive{};
|
||||
zeus::CTransform CGraphics::g_GXModelView;
|
||||
zeus::CTransform CGraphics::g_GXModelViewInvXpose;
|
||||
zeus::CTransform CGraphics::g_GXModelMatrix = zeus::CTransform();
|
||||
@@ -60,33 +57,52 @@ const std::array<zeus::CMatrix3f, 6> CGraphics::skCubeBasisMats{{
|
||||
}};
|
||||
|
||||
void CGraphics::DisableAllLights() {
|
||||
g_NumLightsActive = 0;
|
||||
g_LightActive = ERglLightBits::None;
|
||||
// TODO: turn lights off for real
|
||||
g_LightActive.reset();
|
||||
aurora::gfx::set_light_state(g_LightActive);
|
||||
}
|
||||
|
||||
void CGraphics::LoadLight(ERglLight light, const CLight& info) {
|
||||
// TODO: load light for real
|
||||
const auto lightId = static_cast<GX::LightID>(1 << light);
|
||||
switch (info.GetType()) {
|
||||
case ELightType::LocalAmbient:
|
||||
aurora::gfx::load_light_ambient(lightId, info.GetColor());
|
||||
break;
|
||||
case ELightType::Point:
|
||||
case ELightType::Spot:
|
||||
case ELightType::Custom:
|
||||
case ELightType::Directional: {
|
||||
aurora::gfx::Light lightOut{
|
||||
.pos = CGraphics::g_CameraMatrix * info.GetPosition(),
|
||||
.dir = (CGraphics::g_CameraMatrix.basis * info.GetDirection()).normalized(),
|
||||
.color = info.GetColor(),
|
||||
.linAtt = {info.GetAttenuationConstant(), info.GetAttenuationLinear(), info.GetAttenuationQuadratic()},
|
||||
.angAtt = {info.GetAngleAttenuationConstant(), info.GetAngleAttenuationLinear(),
|
||||
info.GetAngleAttenuationQuadratic()},
|
||||
};
|
||||
if (info.GetType() == ELightType::Directional) {
|
||||
lightOut.pos = (-lightOut.dir) * 1048576.f;
|
||||
}
|
||||
aurora::gfx::load_light(lightId, lightOut);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGraphics::EnableLight(ERglLight light) {
|
||||
ERglLightBits lightBit = ERglLightBits(1 << int(light));
|
||||
if ((lightBit & g_LightActive) == ERglLightBits::None) {
|
||||
g_LightActive |= lightBit;
|
||||
++g_NumLightsActive;
|
||||
// TODO: turn light on for real
|
||||
if (!g_LightActive.test(light)) {
|
||||
g_LightActive.set(light);
|
||||
aurora::gfx::set_light_state(g_LightActive);
|
||||
}
|
||||
g_LightsWereOn = g_LightActive;
|
||||
}
|
||||
|
||||
void CGraphics::SetLightState(ERglLightBits lightState) {
|
||||
// TODO: set state for real
|
||||
void CGraphics::SetLightState(std::bitset<aurora::gfx::MaxLights> lightState) {
|
||||
g_LightActive = lightState;
|
||||
g_NumLightsActive = zeus::PopCount(lightState);
|
||||
aurora::gfx::set_light_state(g_LightActive);
|
||||
}
|
||||
|
||||
void CGraphics::SetAmbientColor(const zeus::CColor& col) {
|
||||
// TODO: set for real
|
||||
aurora::gfx::set_chan_amb_color(GX::COLOR0A0, col);
|
||||
aurora::gfx::set_chan_amb_color(GX::COLOR1A1, col);
|
||||
}
|
||||
|
||||
void CGraphics::SetFog(ERglFogMode mode, float startz, float endz, const zeus::CColor& color) {
|
||||
@@ -150,13 +166,53 @@ void CGraphics::EndScene() {
|
||||
UpdateFPSCounter();
|
||||
}
|
||||
|
||||
void CGraphics::Render2D(const CTexture& tex, u32 x, u32 y, u32 w, u32 h, const zeus::CColor& col) {
|
||||
void CGraphics::Render2D(CTexture& tex, u32 x, u32 y, u32 w, u32 h, const zeus::CColor& col) {
|
||||
const auto oldProj = g_Proj;
|
||||
CGraphics::SetOrtho(-g_Viewport.x8_width / 2, g_Viewport.x8_width / 2, g_Viewport.xc_height / 2,
|
||||
-g_Viewport.xc_height / 2, -1.f, -10.f);
|
||||
// TODO
|
||||
const auto oldCull = g_cullMode;
|
||||
const auto oldLights = g_LightActive;
|
||||
SetOrtho(-g_Viewport.x10_halfWidth, g_Viewport.x10_halfWidth, g_Viewport.x14_halfHeight, -g_Viewport.x14_halfHeight,
|
||||
-1.f, -10.f);
|
||||
// disable Y/Z swap TODO do we need to do this elsewhere?
|
||||
aurora::gfx::update_model_view(zeus::CMatrix4f{}, zeus::CMatrix4f{});
|
||||
DisableAllLights();
|
||||
SetCullMode(ERglCullMode::None);
|
||||
tex.Load(GX::TEXMAP0, EClampMode::Repeat);
|
||||
|
||||
// float hPad, vPad;
|
||||
// if (CGraphics::GetViewportAspect() >= 1.78f) {
|
||||
// hPad = 1.78f / CGraphics::GetViewportAspect();
|
||||
// vPad = 1.78f / 1.33f;
|
||||
// } else {
|
||||
// hPad = 1.f;
|
||||
// vPad = CGraphics::GetViewportAspect() / 1.33f;
|
||||
// }
|
||||
// TODO make this right
|
||||
float scaledX = static_cast<float>(x) / 640.f * static_cast<float>(g_Viewport.x8_width);
|
||||
float scaledY = static_cast<float>(y) / 448.f * static_cast<float>(g_Viewport.xc_height);
|
||||
float scaledW = static_cast<float>(w) / 640.f * static_cast<float>(g_Viewport.x8_width);
|
||||
float scaledH = static_cast<float>(h) / 448.f * static_cast<float>(g_Viewport.xc_height);
|
||||
|
||||
float x1 = scaledX - g_Viewport.x10_halfWidth;
|
||||
float y1 = scaledY - g_Viewport.x14_halfHeight;
|
||||
float x2 = x1 + scaledW;
|
||||
float y2 = y1 + scaledH;
|
||||
StreamBegin(GX::TRIANGLESTRIP);
|
||||
StreamColor(col);
|
||||
StreamTexcoord(0.f, 0.f);
|
||||
StreamVertex(x1, y1, 1.f);
|
||||
StreamTexcoord(1.f, 0.f);
|
||||
StreamVertex(x2, y1, 1.f);
|
||||
StreamTexcoord(0.f, 1.f);
|
||||
StreamVertex(x1, y2, 1.f);
|
||||
StreamTexcoord(1.f, 1.f);
|
||||
StreamVertex(x2, y2, 1.f);
|
||||
StreamEnd();
|
||||
|
||||
SetLightState(g_LightActive);
|
||||
g_Proj = oldProj;
|
||||
FlushProjection();
|
||||
SetModelMatrix({});
|
||||
SetCullMode(oldCull);
|
||||
}
|
||||
|
||||
bool CGraphics::BeginRender2D(const CTexture& tex) { return false; }
|
||||
@@ -249,13 +305,12 @@ zeus::CMatrix4f CGraphics::GetPerspectiveProjectionMatrix() {
|
||||
float rpl = g_Proj.x8_right + g_Proj.x4_left;
|
||||
float tmb = g_Proj.xc_top - g_Proj.x10_bottom;
|
||||
float tpb = g_Proj.xc_top + g_Proj.x10_bottom;
|
||||
float fpn = g_Proj.x18_far + g_Proj.x14_near;
|
||||
float fmn = g_Proj.x18_far - g_Proj.x14_near;
|
||||
// clang-format off
|
||||
return {
|
||||
2.f / rml, 0.f, 0.f, -rpl / rml,
|
||||
0.f, 2.f / tmb, 0.f, -tpb / tmb,
|
||||
0.f, 0.f, -2.f / fmn, -fpn / fmn,
|
||||
0.f, 0.f, -1.f / fmn, -g_Proj.x14_near / fmn,
|
||||
0.f, 0.f, 0.f, 1.f
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
@@ -25,20 +25,7 @@ extern CVar* g_disableLighting;
|
||||
class CLight;
|
||||
class CTimeProvider;
|
||||
|
||||
enum class ERglLight : u8 { Zero = 0, One, Two, Three, Four, Five, Six, Seven };
|
||||
|
||||
enum class ERglLightBits : u8 {
|
||||
None = 0,
|
||||
Zero = 1,
|
||||
One = 1 << 1,
|
||||
Two = 1 << 2,
|
||||
Three = 1 << 3,
|
||||
Four = 1 << 4,
|
||||
Five = 1 << 5,
|
||||
Six = 1 << 6,
|
||||
Seven = 1 << 7
|
||||
};
|
||||
ENABLE_BITWISE_ENUM(ERglLightBits)
|
||||
using ERglLight = u8;
|
||||
|
||||
struct SViewport {
|
||||
u32 x0_left;
|
||||
@@ -119,15 +106,12 @@ public:
|
||||
static zeus::CVector2f g_CachedDepthRange;
|
||||
static CFogState g_Fog;
|
||||
static SViewport g_Viewport;
|
||||
static std::array<zeus::CColor, 3> g_ColorRegs;
|
||||
static float g_ProjAspect;
|
||||
static u32 g_NumLightsActive;
|
||||
static u32 g_NumBreakpointsWaiting;
|
||||
static u32 g_FlippingState;
|
||||
static bool g_LastFrameUsedAbove;
|
||||
static bool g_InterruptLastFrameUsedAbove;
|
||||
static ERglLightBits g_LightActive;
|
||||
static ERglLightBits g_LightsWereOn;
|
||||
static std::bitset<aurora::gfx::MaxLights> g_LightActive;
|
||||
static zeus::CTransform g_GXModelView;
|
||||
static zeus::CTransform g_GXModelViewInvXpose;
|
||||
static zeus::CTransform g_GXModelMatrix;
|
||||
@@ -147,7 +131,7 @@ public:
|
||||
static void DisableAllLights();
|
||||
static void LoadLight(ERglLight light, const CLight& info);
|
||||
static void EnableLight(ERglLight light);
|
||||
static void SetLightState(ERglLightBits lightState);
|
||||
static void SetLightState(std::bitset<aurora::gfx::MaxLights> lightState);
|
||||
static void SetAmbientColor(const zeus::CColor& col);
|
||||
static void SetFog(ERglFogMode mode, float startz, float endz, const zeus::CColor& color);
|
||||
static void SetDepthWriteMode(bool test, ERglEnum comp, bool write);
|
||||
@@ -155,7 +139,7 @@ public:
|
||||
static void SetCullMode(ERglCullMode);
|
||||
static void BeginScene();
|
||||
static void EndScene();
|
||||
static void Render2D(const CTexture& tex, u32 x, u32 y, u32 w, u32 h, const zeus::CColor& col);
|
||||
static void Render2D(CTexture& tex, u32 x, u32 y, u32 w, u32 h, const zeus::CColor& col);
|
||||
static bool BeginRender2D(const CTexture& tex);
|
||||
static void DoRender2D(const CTexture& tex, s32 x, s32 y, s32 w1, s32 w2, s32 w3, s32 w4, s32 w5,
|
||||
const zeus::CColor& col);
|
||||
|
||||
@@ -227,7 +227,7 @@ bool CModel::IsLoaded(u32 matIdx) {
|
||||
VerifyCurrentShader(matIdx);
|
||||
const auto& textures = *x28_modelInst->x1c_textures;
|
||||
if (textures.empty()) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
for (const auto& token : textures) {
|
||||
if (token.IsNull() && !token.IsLoaded()) {
|
||||
|
||||
@@ -366,36 +366,24 @@ void CMoviePlayer::Rewind() {
|
||||
}
|
||||
|
||||
void CMoviePlayer::Draw() {
|
||||
if (GetIsFullyCached()) {
|
||||
g_Renderer->SetDepthReadWrite(false, false);
|
||||
g_Renderer->SetViewportOrtho(false, -4096.f, 4096.f);
|
||||
const auto vpHeight = CGraphics::GetViewportHeight();
|
||||
const auto vpWidth = CGraphics::GetViewportWidth();
|
||||
const auto vpTop = CGraphics::GetViewportTop();
|
||||
const auto vpLeft = CGraphics::GetViewportLeft();
|
||||
const auto [width, height] = GetVideoDimensions();
|
||||
const auto centerX = (width - vpWidth) / 2;
|
||||
const auto centerY = (height - vpHeight) / 2;
|
||||
DrawFrame(vpLeft - centerX, vpLeft + vpWidth + centerX, vpTop - centerY, vpTop + vpHeight + centerY);
|
||||
}
|
||||
}
|
||||
|
||||
void CMoviePlayer::DrawFrame(u32 left, u32 right, u32 top, u32 bottom) {
|
||||
DrawFrame({static_cast<float>(left), 0.f, static_cast<float>(bottom)},
|
||||
{static_cast<float>(right), 0.f, static_cast<float>(bottom)},
|
||||
{static_cast<float>(left), 0.f, static_cast<float>(top)},
|
||||
{static_cast<float>(right), 0.f, static_cast<float>(top)});
|
||||
}
|
||||
|
||||
void CMoviePlayer::DrawFrame(const zeus::CVector3f& v1, const zeus::CVector3f& v2, const zeus::CVector3f& v3,
|
||||
const zeus::CVector3f& v4) {
|
||||
if (xd0_drawTexSlot == UINT32_MAX)
|
||||
if (xd0_drawTexSlot == UINT32_MAX || !GetIsFullyCached()) {
|
||||
return;
|
||||
}
|
||||
SCOPED_GRAPHICS_DEBUG_GROUP("CMoviePlayer::DrawFrame", zeus::skYellow);
|
||||
|
||||
/* Correct movie aspect ratio */
|
||||
float hPad, vPad;
|
||||
if (CGraphics::GetViewportAspect() >= 1.78f) {
|
||||
hPad = 1.78f / CGraphics::GetViewportAspect();
|
||||
vPad = 1.78f / 1.33f;
|
||||
} else {
|
||||
hPad = 1.f;
|
||||
vPad = CGraphics::GetViewportAspect() / 1.33f;
|
||||
}
|
||||
|
||||
/* draw appropriate field */
|
||||
CTHPTextureSet& tex = x80_textures[xd0_drawTexSlot];
|
||||
aurora::gfx::queue_movie_player(tex.Y[m_deinterlace ? (xfc_fieldIndex != 0) : 0], tex.U, tex.V, v1, v2, v3, v4);
|
||||
aurora::gfx::queue_movie_player(tex.Y[m_deinterlace ? (xfc_fieldIndex != 0) : 0], tex.U, tex.V, hPad, vPad);
|
||||
|
||||
/* ensure second field is being displayed by VI to signal advance
|
||||
* (faked in metaforce with continuous xor) */
|
||||
|
||||
@@ -110,9 +110,6 @@ private:
|
||||
float m_vpad;
|
||||
|
||||
void DecodeFromRead(const void* data);
|
||||
void DrawFrame(u32 left, u32 right, u32 top, u32 bottom);
|
||||
void DrawFrame(const zeus::CVector3f& v1, const zeus::CVector3f& v2, const zeus::CVector3f& v3,
|
||||
const zeus::CVector3f& v4);
|
||||
void PostDVDReadRequestIfNeeded();
|
||||
void ReadCompleted();
|
||||
|
||||
|
||||
@@ -457,6 +457,8 @@ enum TexMapID {
|
||||
TEXMAP6,
|
||||
TEXMAP7,
|
||||
MAX_TEXMAP,
|
||||
TEXMAP_NULL = 0xFF,
|
||||
TEX_DISABLE = 0x100,
|
||||
};
|
||||
|
||||
enum TevStageID {
|
||||
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
virtual u32 GetStaticWorldDataSize() = 0;
|
||||
virtual void SetGXRegister1Color(const zeus::CColor& color) = 0;
|
||||
virtual void SetWorldLightFadeLevel(float level) = 0;
|
||||
virtual void SetWorldLightMultiplyColor(const zeus::CColor& color) = 0;
|
||||
// Something
|
||||
virtual void PrepareDynamicLights(const std::vector<CLight>& lights) = 0;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user