2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 16:24:55 +00:00

CModelShaders: Split Thermal into ThermalModel, ThermalStatic extended shaders

This semi-hacky approach will be replaced with future hsh work
This commit is contained in:
2020-12-18 06:07:53 -05:00
parent 1e0bdce5a3
commit 168eb6ac39
11 changed files with 59 additions and 19 deletions

View File

@@ -1126,7 +1126,7 @@ void CBooRenderer::DrawSpaceWarp(const zeus::CVector3f& pt, float strength) {
void CBooRenderer::DrawThermalModel(const CModel& model, const zeus::CColor& mulCol, const zeus::CColor& addCol) {
SCOPED_GRAPHICS_DEBUG_GROUP("CBooRenderer::DrawThermalModel", zeus::skPurple);
CModelFlags flags;
flags.m_extendedShader = EExtendedShader::Thermal;
flags.m_extendedShader = EExtendedShader::ThermalModel;
flags.x4_color = mulCol;
flags.addColor = addCol;
model.UpdateLastFrame();
@@ -1181,6 +1181,7 @@ void CBooRenderer::SetThermal(bool thermal, float level, const zeus::CColor& col
x2f4_thermColor = color;
CDecal::SetMoveRedToAlphaBuffer(false);
CElementGen::SetMoveRedToAlphaBuffer(false);
m_thermalHotPass = false;
}
void CBooRenderer::SetThermalColdScale(float scale) { x2f8_thermColdScale = zeus::clamp(0.f, scale, 1.f); }

View File

@@ -30,6 +30,7 @@ struct CModelFlags {
u8 x1_matSetIdx = 0;
EExtendedShader m_extendedShader = EExtendedShader::Lighting;
bool m_noCull = false;
bool m_noZTest = false;
bool m_noZWrite = false;
bool m_depthGreater = false;
u16 x2_flags = 0; /* Flags */
@@ -46,7 +47,7 @@ struct CModelFlags {
}
/* Flags
0x1: depth equal
0x1: depth lequal
0x2: depth update
0x4: render without texture lock
0x8: depth greater

View File

@@ -368,7 +368,10 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance(int sharedLayoutBuf) {
EExtendedShader idx{};
for (const auto& pipeline : *pipelines) {
if (idx == EExtendedShader::Thermal) {
if (idx == EExtendedShader::ThermalModel ||
idx == EExtendedShader::ThermalModelNoZTestNoZWrite ||
idx == EExtendedShader::ThermalStatic ||
idx == EExtendedShader::ThermalStaticNoZWrite) {
texs[8] = g_Renderer->x220_sphereRamp.get();
} else if (idx == EExtendedShader::MorphBallShadow) {
texs[8] = g_Renderer->m_ballShadowId.get();
@@ -576,9 +579,11 @@ static EExtendedShader ResolveExtendedShader(const MaterialSet::Material& data,
EExtendedShader extended = EExtendedShader::Flat;
if (intermediateExtended == EExtendedShader::Lighting) {
/* Transform lighting into thermal cold if the thermal visor is active */
/* Transform lighting into thermal if the thermal visor is active */
if (g_Renderer->IsThermalVisorHotPass())
return noZWrite ? EExtendedShader::LightingAlphaWriteNoZTestNoZWrite : EExtendedShader::LightingAlphaWrite;
return flags.m_noZTest
? EExtendedShader::LightingAlphaWriteNoZTestNoZWrite
: (noZWrite ? EExtendedShader::ThermalStaticNoZWrite : EExtendedShader::ThermalStatic);
else if (g_Renderer->IsThermalVisorActive())
return EExtendedShader::ThermalCold;
if (data.blendMode == MaterialSet::Material::BlendMaterial::BlendMode::Opaque) {
@@ -621,6 +626,8 @@ static EExtendedShader ResolveExtendedShader(const MaterialSet::Material& data,
} else {
extended = EExtendedShader::Lighting;
}
} else if (intermediateExtended == EExtendedShader::ThermalModel) {
extended = flags.m_noZTest ? EExtendedShader::ThermalModelNoZTestNoZWrite : EExtendedShader::ThermalModel;
} else if (intermediateExtended < EExtendedShader::MAX) {
extended = intermediateExtended;
}
@@ -810,7 +817,10 @@ void CBooModel::UVAnimationBuffer::Update(u8*& bufOut, const MaterialSet* matSet
}
std::optional<std::array<zeus::CMatrix4f, 2>> specialMtxOut;
if (flags.m_extendedShader == EExtendedShader::Thermal) {
if (flags.m_extendedShader == EExtendedShader::ThermalModel ||
flags.m_extendedShader == EExtendedShader::ThermalModelNoZTestNoZWrite ||
flags.m_extendedShader == EExtendedShader::ThermalStatic ||
flags.m_extendedShader == EExtendedShader::ThermalStaticNoZWrite) {
/* Special Mode0 matrix for exclusive Thermal Visor use */
specialMtxOut.emplace();
@@ -1022,7 +1032,8 @@ boo::ObjToken<boo::IGraphicsBufferD> CBooModel::UpdateUniformData(const CModelFl
u8* dataOut = reinterpret_cast<u8*>(inst->m_uniformBuffer->map(m_uniformDataSize));
u8* dataCur = dataOut;
if (flags.m_extendedShader == EExtendedShader::Thermal) /* Thermal Model (same as UV Mode 0) */
if (flags.m_extendedShader == EExtendedShader::ThermalModel ||
flags.m_extendedShader == EExtendedShader::ThermalModelNoZTestNoZWrite) /* Thermal Model (same as UV Mode 0) */
{
CModelShaders::ThermalUniform& thermalOut = *reinterpret_cast<CModelShaders::ThermalUniform*>(dataCur);
thermalOut.mulColor = flags.x4_color;

View File

@@ -86,9 +86,18 @@ static std::array<hecl::Backend::ExtensionSlot, size_t(EExtendedShader::MAX)> g_
/* Normal lit shading */
{0, nullptr, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true},
/* Thermal Visor shading */
/* Thermal model shading */
{1, ThermalTextures.data(), hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::One,
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, false, true},
/* Thermal model shading without Z-test or Z-write */
{1, ThermalTextures.data(), hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::One,
hecl::Backend::ZTest::None, hecl::Backend::CullMode::Backface, true, false, false, true},
/* Thermal static shading */
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One,
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, false, true, false, false, true},
/* Thermal static shading without Z-write */
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One,
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, true, false, false, true, false, false, false},
/* Forced alpha shading */
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true},
@@ -166,7 +175,10 @@ static std::array<hecl::Backend::ExtensionSlot, size_t(EExtendedShader::MAX)> g_
constexpr std::array<const char*, size_t(EExtendedShader::MAX)> ShaderMacros{
"URDE_LIGHTING",
"URDE_LIGHTING",
"URDE_THERMAL_HOT",
"URDE_THERMAL_MODEL",
"URDE_THERMAL_MODEL",
"URDE_THERMAL_STATIC",
"URDE_THERMAL_STATIC",
"URDE_LIGHTING",
"URDE_LIGHTING",
"URDE_SOLID",

View File

@@ -24,7 +24,10 @@ class CLight;
enum class EExtendedShader : uint8_t {
Flat,
Lighting,
Thermal,
ThermalModel,
ThermalModelNoZTestNoZWrite,
ThermalStatic,
ThermalStaticNoZWrite,
ForcedAlpha,
ForcedAdditive,
SolidColor,

View File

@@ -2,6 +2,7 @@
#include <array>
#include "Runtime/Graphics/CBooRenderer.hpp"
#include "Runtime/Graphics/CGraphics.hpp"
#include "Runtime/Graphics/CTexture.hpp"