CGraphics: Handle Point type in LoadLight

Also removes shadowRender parameter from
DrawUnsortedGeometry, it's now unused.
This commit is contained in:
Luke Street 2022-05-12 01:57:24 -04:00
parent 4e06ea1bb5
commit 712a26ab93
4 changed files with 27 additions and 54 deletions

View File

@ -286,10 +286,11 @@ void CCubeRenderer::RemoveStaticGeometry(const std::vector<CMetroidModelInstance
} }
} }
void CCubeRenderer::DrawUnsortedGeometry(s32 areaIdx, s32 mask, s32 targetMask, bool shadowRender) { void CCubeRenderer::DrawUnsortedGeometry(s32 areaIdx, s32 mask, s32 targetMask) {
SCOPED_GRAPHICS_DEBUG_GROUP( SCOPED_GRAPHICS_DEBUG_GROUP(
fmt::format(FMT_STRING("CCubeRenderer::DrawUnsortedGeometry areaIdx={} mask={} targetMask={} shadowRender={}"), fmt::format(FMT_STRING("CCubeRenderer::DrawUnsortedGeometry areaIdx={} mask={} targetMask={}"), areaIdx, mask,
areaIdx, mask, targetMask, shadowRender).c_str(), targetMask)
.c_str(),
zeus::skBlue); zeus::skBlue);
SetupRendererStates(true); SetupRendererStates(true);

View File

@ -112,7 +112,7 @@ public:
void EnablePVS(const CPVSVisSet& set, u32 areaIdx) override; void EnablePVS(const CPVSVisSet& set, u32 areaIdx) override;
void DisablePVS() override; void DisablePVS() override;
void RemoveStaticGeometry(const std::vector<CMetroidModelInstance>* geometry) override; void RemoveStaticGeometry(const std::vector<CMetroidModelInstance>* geometry) override;
void DrawUnsortedGeometry(s32 areaIdx, s32 mask, s32 targetMask, bool shadowRender = false) override; void DrawUnsortedGeometry(s32 areaIdx, s32 mask, s32 targetMask) override;
void DrawSortedGeometry(s32 areaIdx, s32 mask, s32 targetMask) override; void DrawSortedGeometry(s32 areaIdx, s32 mask, s32 targetMask) override;
void DrawStaticGeometry(s32 areaIdx, s32 mask, s32 targetMask) override; void DrawStaticGeometry(s32 areaIdx, s32 mask, s32 targetMask) override;
void DrawAreaGeometry(s32 areaIdx, s32 mask, s32 targetMask) override; void DrawAreaGeometry(s32 areaIdx, s32 mask, s32 targetMask) override;

View File

@ -82,69 +82,41 @@ void CGraphics::DisableAllLights() {
void CGraphics::LoadLight(ERglLight light, const CLight& info) { void CGraphics::LoadLight(ERglLight light, const CLight& info) {
const auto lightId = static_cast<GX::LightID>(1 << light); const auto lightId = static_cast<GX::LightID>(1 << light);
#if 1 auto& obj = g_LightObjs[light];
zeus::CVector3f pos = info.GetPosition(); zeus::CVector3f pos = info.GetPosition();
zeus::CVector3f dir = info.GetDirection(); zeus::CVector3f dir = info.GetDirection();
if (info.GetType() == ELightType::Directional) { const auto type = info.GetType();
return; if (type == ELightType::Directional) {
dir = -(g_CameraMatrix.buildMatrix3f() * dir); dir = -(g_CameraMatrix.buildMatrix3f() * dir);
GXInitLightPos(&g_LightObjs[static_cast<u32>(light)], dir.x() * 1048576.f, dir.y() * 1048576.f, GXInitLightPos(&obj, dir.x() * 1048576.f, dir.y() * 1048576.f, dir.z() * 1048576.f);
dir.z() * 1048576.f); GXInitLightAttn(&obj, 1.f, 0.f, 0.f, 1.f, 0.f, 0.f);
GXInitLightAttn(&g_LightObjs[static_cast<u32>(light)], 1.f, 0.f, 0.f, 1.f, 0.f, 0.f); } else if (type == ELightType::Spot) {
} else if (info.GetType() == ELightType::Spot) {
pos = g_CameraMatrix * pos; pos = g_CameraMatrix * pos;
GX::LightObj* obj = &g_LightObjs[static_cast<u32>(light)]; GXInitLightPos(&obj, pos.x(), pos.y(), pos.z());
GXInitLightPos(obj, pos.x(), pos.y(), pos.z());
dir = g_CameraMatrix.buildMatrix3f() * dir; dir = g_CameraMatrix.buildMatrix3f() * dir;
GXInitLightDir(obj, dir.x(), dir.y(), dir.z()); GXInitLightDir(&obj, dir.x(), dir.y(), dir.z());
GXInitLightAttn(obj, 1.f, 0.f, 0.f, info.GetAttenuationConstant(), info.GetAttenuationLinear(), GXInitLightAttn(&obj, 1.f, 0.f, 0.f, info.GetAttenuationConstant(), info.GetAttenuationLinear(),
info.GetAttenuationQuadratic()); info.GetAttenuationQuadratic());
GXInitLightSpot(obj, info.GetSpotCutoff(), GX::SP_COS2); GXInitLightSpot(&obj, info.GetSpotCutoff(), GX::SP_COS2);
} else if (info.GetType() == ELightType::Custom) { } else if (type == ELightType::Custom) {
pos = g_CameraMatrix * pos; pos = g_CameraMatrix * pos;
GX::LightObj* obj = &g_LightObjs[static_cast<u32>(light)]; GXInitLightPos(&obj, pos.x(), pos.y(), pos.z());
GXInitLightPos(obj, pos.x(), pos.y(), pos.z());
dir = g_CameraMatrix.buildMatrix3f() * dir; dir = g_CameraMatrix.buildMatrix3f() * dir;
GXInitLightDir(obj, dir.x(), dir.y(), dir.z()); GXInitLightDir(&obj, dir.x(), dir.y(), dir.z());
GXInitLightAttn(obj, info.GetAngleAttenuationConstant(), info.GetAngleAttenuationLinear(), GXInitLightAttn(&obj, info.GetAngleAttenuationConstant(), info.GetAngleAttenuationLinear(),
info.GetAngleAttenuationQuadratic(), info.GetAttenuationConstant(), info.GetAttenuationLinear(), info.GetAngleAttenuationQuadratic(), info.GetAttenuationConstant(), info.GetAttenuationLinear(),
info.GetAttenuationQuadratic()); info.GetAttenuationQuadratic());
} else if (info.GetType() == ELightType::LocalAmbient) { } else if (type == ELightType::LocalAmbient || type == ELightType::Point) {
pos = g_CameraMatrix * pos; pos = g_CameraMatrix * pos;
GXInitLightPos(&g_LightObjs[static_cast<u32>(light)], pos.x(), pos.y(), pos.z()); GXInitLightPos(&obj, pos.x(), pos.y(), pos.z());
GXInitLightAttn(&g_LightObjs[static_cast<u32>(light)], 1.f, 0.f, 0.f, info.GetAttenuationConstant(), GXInitLightAttn(&obj, 1.f, 0.f, 0.f, info.GetAttenuationConstant(), info.GetAttenuationLinear(),
info.GetAttenuationLinear(), info.GetAttenuationQuadratic()); info.GetAttenuationQuadratic());
} }
g_LightTypes[static_cast<u32>(light)] = info.GetType(); g_LightTypes[light] = type;
GX::Color col(info.GetColor().r(), info.GetColor().g(), info.GetColor().b()); GX::Color col(info.GetColor().r(), info.GetColor().g(), info.GetColor().b());
GXInitLightColor(&g_LightObjs[static_cast<u32>(light)], col); GXInitLightColor(&obj, col);
GXLoadLightObjImm(&g_LightObjs[static_cast<u32>(light)], lightId); GXLoadLightObjImm(&obj, lightId);
#else
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;
}
}
#endif
} }
void CGraphics::EnableLight(ERglLight light) { void CGraphics::EnableLight(ERglLight light) {

View File

@ -46,7 +46,7 @@ public:
virtual void EnablePVS(const CPVSVisSet& set, u32 areaIdx) = 0; virtual void EnablePVS(const CPVSVisSet& set, u32 areaIdx) = 0;
virtual void DisablePVS() = 0; virtual void DisablePVS() = 0;
virtual void RemoveStaticGeometry(const std::vector<CMetroidModelInstance>* geometry) = 0; virtual void RemoveStaticGeometry(const std::vector<CMetroidModelInstance>* geometry) = 0;
virtual void DrawUnsortedGeometry(s32 areaIdx, s32 mask, s32 targetMask, bool shadowRender = false) = 0; virtual void DrawUnsortedGeometry(s32 areaIdx, s32 mask, s32 targetMask) = 0;
virtual void DrawSortedGeometry(s32 areaIdx, s32 mask, s32 targetMask) = 0; virtual void DrawSortedGeometry(s32 areaIdx, s32 mask, s32 targetMask) = 0;
virtual void DrawStaticGeometry(s32 areaIdx, s32 mask, s32 targetMask) = 0; virtual void DrawStaticGeometry(s32 areaIdx, s32 mask, s32 targetMask) = 0;
virtual void DrawAreaGeometry(s32 areaIdx, s32 mask, s32 targetMask) = 0; virtual void DrawAreaGeometry(s32 areaIdx, s32 mask, s32 targetMask) = 0;