More CCubeRenderer imps

This commit is contained in:
Phillip Stephens 2022-02-27 13:17:44 -08:00
parent 805065b6f2
commit 004d78100f
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
5 changed files with 123 additions and 17 deletions

View File

@ -220,7 +220,8 @@ void CCubeRenderer::DrawSortedGeometry(int areaIdx, int mask, int targetMask) {}
void CCubeRenderer::DrawStaticGeometry(int areaIdx, int mask, int targetMask) {}
void CCubeRenderer::DrawAreaGeometry(int areaIdx, int mask, int targetMask) {}
void CCubeRenderer::PostRenderFogs() {}
void CCubeRenderer::SetModelMatrix(const zeus::CTransform& xf) {}
void CCubeRenderer::SetModelMatrix(const zeus::CTransform& xf) { CGraphics::SetModelMatrix(xf); }
void CCubeRenderer::AddParticleGen(CParticleGen& gen) {
auto bounds = gen.GetBounds();
@ -265,18 +266,84 @@ void CCubeRenderer::AddDrawable(void* obj, const zeus::CVector3f& pos, const zeu
Buckets::Insert(pos, aabb, EDrawableType(mode + 2), obj, xb0_viewPlane, 0);
}
}
void CCubeRenderer::SetDrawableCallback(IRenderer::TDrawableCallback cb, void* ctx) {}
void CCubeRenderer::SetWorldViewpoint(const zeus::CTransform& xf) {}
void CCubeRenderer::SetPerspective(float fovy, float aspect, float znear, float zfar) {}
void CCubeRenderer::SetPerspective(float fovy, float width, float height, float znear, float zfar) {}
void CCubeRenderer::SetDrawableCallback(IRenderer::TDrawableCallback cb, void* ctx) {
xa8_drawableCallback = cb;
xac_drawableCallbackUserData = ctx;
}
void CCubeRenderer::SetWorldViewpoint(const zeus::CTransform& xf) {
CGraphics::SetViewPointMatrix(xf);
auto front = xf.frontVector();
xb0_viewPlane = zeus::CPlane(front, front.dot(xf.origin));
}
void CCubeRenderer::SetPerspective(float fovy, float aspect, float znear, float zfar) {
CGraphics::SetPerspective(fovy, aspect, znear, zfar);
}
void CCubeRenderer::SetPerspective(float fovy, float width, float height, float znear, float zfar) {
CGraphics::SetPerspective(fovy, width / height, znear, zfar);
}
std::pair<zeus::CVector2f, zeus::CVector2f> CCubeRenderer::SetViewportOrtho(bool centered, float znear, float zfar) {
return std::pair<zeus::CVector2f, zeus::CVector2f>();
}
void CCubeRenderer::SetClippingPlanes(const zeus::CFrustum& frustum) {}
void CCubeRenderer::SetViewport(int left, int bottom, int width, int height) {}
void CCubeRenderer::BeginScene() {}
void CCubeRenderer::EndScene() {}
void CCubeRenderer::SetDebugOption(IRenderer::EDebugOption, int) {}
void CCubeRenderer::SetClippingPlanes(const zeus::CFrustum& frustum) { x44_frustumPlanes = frustum; }
void CCubeRenderer::SetViewport(int left, int bottom, int width, int height) {
CGraphics::SetViewport(left, bottom, width, height);
CGraphics::SetScissor(left, bottom, width, height);
}
void CCubeRenderer::BeginScene() {
CGraphics::SetUseVideoFilter(true);
CGraphics::SetViewport(0, 0, CGraphics::g_Viewport.x8_width, CGraphics::g_Viewport.xc_height);
CGraphics::SetClearColor(zeus::skClear);
CGraphics::SetCullMode(ERglCullMode::Front);
CGraphics::SetDepthWriteMode(true, ERglEnum::LEqual, true);
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::InvSrcAlpha,
ERglLogicOp::Clear);
CGraphics::SetPerspective(75.f, CGraphics::g_Viewport.x8_width / CGraphics::g_Viewport.xc_height, 1.f, 4096.f);
CGraphics::SetModelMatrix(zeus::CTransform());
if (x310_phazonSuitMaskCountdown != 0) {
--x310_phazonSuitMaskCountdown;
if (x310_phazonSuitMaskCountdown == 0) {
x314_phazonSuitMask.reset();
}
}
if (!x318_31_persistRGBA6) {
x318_26_requestRGBA6 = false;
}
// GXSetPixelFmt(x318_26_requestRGBA6, GX_ZC_LINEAR);
// GXSetAlphaUpdate(true);
// GXSetDstAlpha(true, 0);
CGraphics::BeginScene();
}
void CCubeRenderer::EndScene() {
x318_31_persistRGBA6 = !CGraphics::g_IsBeginSceneClearFb;
CGraphics::EndScene();
if (x2dc_reflectionAge < 2) {
++x2dc_reflectionAge;
} else {
x14c_reflectionTex.reset();
};
}
void CCubeRenderer::SetDebugOption(IRenderer::EDebugOption option, int value) {
if (option == EDebugOption::PVSState) {
xc8_pvs->SetState(EPVSVisSetState(value));
return;
}
if (option == EDebugOption::PVSMode) {
xc0_pvsMode = EPVSMode(value);
}
if (option == EDebugOption::FogDisabled) {
x318_28_disableFog = true;
}
}
void CCubeRenderer::BeginPrimitive(IRenderer::EPrimitiveType, int) {}
void CCubeRenderer::BeginLines(int) {}
void CCubeRenderer::BeginLineStrip(int) {}
@ -308,9 +375,12 @@ void CCubeRenderer::SetThermalColdScale(float scale) {}
void CCubeRenderer::DoThermalBlendCold() {}
void CCubeRenderer::DoThermalBlendHot() {}
u32 CCubeRenderer::GetStaticWorldDataSize() { return 0; }
void CCubeRenderer::SetGXRegister1Color(const zeus::CColor& color) {}
void CCubeRenderer::SetWorldLightFadeLevel(float level) {}
void CCubeRenderer::SetWorldLightMultiplyColor(const zeus::CColor& color) {}
void CCubeRenderer::SetGXRegister1Color(const zeus::CColor& color) {
CGraphics::g_ColorRegs[1] = color;
// GXSetTevColor(GX_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,

View File

@ -65,7 +65,7 @@ private:
bool xdc_{};
u32 xe0_pvsAreaIdx = UINT32_MAX;
CTexture xe4_blackTex{ETexelFormat::RGB565, 4, 4, 1};
u32 x14c_ = 0;
std::unique_ptr<CTexture> x14c_reflectionTex;
CTexture x150_reflectionTex{ETexelFormat::IA8, 32, 32, 1};
CTexture x1b8_fogVolumeRamp{ETexelFormat::I8, 256, 256, 1};
CTexture x220_sphereRamp{ETexelFormat::I8, 32, 32, 1};
@ -82,7 +82,7 @@ private:
zeus::CColor x2fc_tevReg1Color{1.f, 0.f, 1.f, 1.f};
std::vector<CLight> x300_dynamicLights;
u32 x310_phazonSuitMaskCountdown = 0;
CTexture* x314_phazonSuitMask = nullptr;
std::unique_ptr<CTexture> x314_phazonSuitMask;
bool x318_24_refectionDirty : 1 = false;
bool x318_25_drawWireframe : 1 = false;
bool x318_26_requestRGBA6 : 1 = false;
@ -129,7 +129,7 @@ public:
void SetPerspective(float fovy, float width, float height, float znear, float zfar) override;
std::pair<zeus::CVector2f, zeus::CVector2f> SetViewportOrtho(bool centered, float znear, float zfar) override;
void SetClippingPlanes(const zeus::CFrustum& frustum) override;
void SetViewport(int left, int bottom, int width, int height) override;
void SetViewport(int left, int right, int width, int height) override;
void SetDepthReadWrite(bool read, bool write) override {
CGraphics::SetDepthWriteMode(read, ERglEnum::LEqual, write);
}

View File

@ -30,7 +30,11 @@ zeus::CTransform CGraphics::g_GXViewPointMatrix;
zeus::CTransform CGraphics::g_CameraMatrix;
SClipScreenRect CGraphics::g_CroppedViewport;
bool CGraphics::g_IsGXModelMatrixIdentity = true;
SViewport g_Viewport = {
zeus::CColor CGraphics::g_ClearColor = zeus::skClear;
float CGraphics::g_ClearDepthValue = 1.f;
bool CGraphics::g_IsBeginSceneClearFb = true;
SViewport CGraphics::g_Viewport = {
0, 0, 640, 480, 640 / 2.f, 480 / 2.f, 0.0f,
};
u32 CGraphics::g_FrameCounter = 0;
@ -121,6 +125,7 @@ void CGraphics::BeginScene() {
}
void CGraphics::EndScene() {
//CGX::SetZMode(true, GX_LEQUAL, true);
/* Spinwait until g_NumBreakpointsWaiting is 0 */
/* ++g_NumBreakpointsWaiting; */
/* GXCopyDisp to g_CurrenFrameBuf with clear enabled */
@ -484,6 +489,28 @@ void CGraphics::UpdateFPSCounter() {
}
}
static bool g_UseVideoFilter = false;
void CGraphics::SetUseVideoFilter(bool filter) {
g_UseVideoFilter = filter;
// GXSetCopyFilter(CGraphics::mRenderModeObj.aa, CGraphics::mRenderModeObj.sample_pattern, filter,
// CGraphics::mRenderModeObj.vfilter);
}
void CGraphics::SetClearColor(const zeus::CColor& color) {
g_ClearColor = color;
// GXSetCopyClear(g_ClearColor, g_ClearDepthValue);
}
void CGraphics::SetCopyClear(const zeus::CColor& color, float depth) {
g_ClearColor = color;
g_ClearDepthValue = depth; // 1.6777215E7 * depth; Metroid Prime needed this to convert float [0,1] depth into 24 bit
// range, we no longer have this requirement
// GXSetCopyClear(g_ClearColor, g_ClearDepthValue);
}
void CGraphics::SetIsBeginSceneClearFb(bool clear) {
g_IsBeginSceneClearFb = clear;
}
// boo::IGraphicsDataFactory::Platform CGraphics::g_BooPlatform = boo::IGraphicsDataFactory::Platform::Null;
// boo::IGraphicsDataFactory* CGraphics::g_BooFactory = nullptr;
// boo::IGraphicsCommandQueue* CGraphics::g_BooMainCommandQueue = nullptr;

View File

@ -181,6 +181,7 @@ public:
static CProjectionState g_Proj;
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;
@ -199,6 +200,9 @@ public:
static zeus::CTransform g_CameraMatrix;
static SClipScreenRect g_CroppedViewport;
static bool g_IsGXModelMatrixIdentity;
static zeus::CColor g_ClearColor;
static float g_ClearDepthValue; // Was a 24bit value, we use a float range from [0,1]
static bool g_IsBeginSceneClearFb;
static ERglEnum g_depthFunc;
static ERglCullMode g_cullMode;
@ -254,6 +258,10 @@ public:
static u32 GetFrameCounter() { return g_FrameCounter; }
static u32 GetFPS() { return g_Framerate; }
static void UpdateFPSCounter();
static void SetUseVideoFilter(bool);
static void SetClearColor(const zeus::CColor& color);
static void SetCopyClear(const zeus::CColor& color, float depth);
static void SetIsBeginSceneClearFb(bool clear);
// static boo::IGraphicsDataFactory::Platform g_BooPlatform;
// static const char* g_BooPlatformName;

View File

@ -22,6 +22,7 @@ public:
EPVSVisSetState GetVisible(u32 idx) const;
void SetFromMemory(u32 numBits, u32 numLights, const u8* leafPtr);
void SetTestPoint(const CPVSVisOctree& octree, const zeus::CVector3f&);
void SetState(EPVSVisSetState state) { x0_state = state; }
};
} // namespace metaforce