mirror of https://github.com/AxioDL/metaforce.git
CModelShaders: Split Thermal into ThermalModel, ThermalStatic extended shaders
This semi-hacky approach will be replaced with future hsh work
This commit is contained in:
parent
1e0bdce5a3
commit
168eb6ac39
|
@ -292,7 +292,7 @@ void CModelData::RenderThermal(const zeus::CColor& mulColor, const zeus::CColor&
|
|||
CModelFlags drawFlags = flags;
|
||||
drawFlags.x4_color *= mulColor;
|
||||
drawFlags.addColor = addColor;
|
||||
drawFlags.m_extendedShader = EExtendedShader::Thermal;
|
||||
drawFlags.m_extendedShader = EExtendedShader::ThermalModel;
|
||||
|
||||
if (x10_animData) {
|
||||
CSkinnedModel& model = PickAnimatedModel(EWhichModel::ThermalHot);
|
||||
|
|
|
@ -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); }
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -24,7 +24,10 @@ class CLight;
|
|||
enum class EExtendedShader : uint8_t {
|
||||
Flat,
|
||||
Lighting,
|
||||
Thermal,
|
||||
ThermalModel,
|
||||
ThermalModelNoZTestNoZWrite,
|
||||
ThermalStatic,
|
||||
ThermalStaticNoZWrite,
|
||||
ForcedAlpha,
|
||||
ForcedAdditive,
|
||||
SolidColor,
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <array>
|
||||
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
#include "Runtime/Graphics/CTexture.hpp"
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ vec3 LightingFunc() {
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(URDE_THERMAL_HOT)
|
||||
#if defined(URDE_THERMAL_MODEL)
|
||||
vec3 LightingFunc() {
|
||||
return vec3(1.0);
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ UBINDING2 uniform ThermalUniform {
|
|||
};
|
||||
#endif
|
||||
|
||||
#if defined(URDE_THERMAL_COLD)
|
||||
#if defined(URDE_THERMAL_COLD) || defined(URDE_THERMAL_STATIC)
|
||||
vec3 LightingFunc() {
|
||||
return vec3(1.0);
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ vec4 PostFunc(vec4 colorIn) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(URDE_THERMAL_HOT)
|
||||
#if defined(URDE_THERMAL_MODEL)
|
||||
vec4 PostFunc(vec4 colorIn) {
|
||||
return texture(extTex0, vtf.extUvs[0]).rrrr * tmulColor + taddColor;
|
||||
}
|
||||
|
@ -280,6 +280,12 @@ vec4 PostFunc(vec4 colorIn) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(URDE_THERMAL_STATIC)
|
||||
vec4 PostFunc(vec4 colorIn) {
|
||||
return colorIn;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(URDE_SOLID)
|
||||
vec4 PostFunc(vec4 colorIn) {
|
||||
return solidColor;
|
||||
|
|
|
@ -145,7 +145,7 @@ float3 LightingFunc(in VertToFrag vtf) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(URDE_THERMAL_HOT)
|
||||
#if defined(URDE_THERMAL_MODEL)
|
||||
float3 LightingFunc(in VertToFrag vtf) {
|
||||
return float3(1.0, 1.0, 1.0);
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ float4 PostFunc(in VertToFrag vtf, float4 colorIn) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(URDE_THERMAL_HOT)
|
||||
#if defined(URDE_THERMAL_MODEL)
|
||||
float4 PostFunc(in VertToFrag vtf, float4 colorIn) {
|
||||
return extTex0.Sample(samp, vtf.extUvs[0]).rrrr * tmulColor + taddColor;
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ float3 LightingFunc(thread VertToFrag& vtf, constant LightingUniform& lu, textur
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(URDE_THERMAL_HOT)
|
||||
#if defined(URDE_THERMAL_MODEL)
|
||||
struct LightingUniform {
|
||||
float4 tmulColor;
|
||||
float4 taddColor;
|
||||
|
@ -251,7 +251,7 @@ float4 PostFunc(thread VertToFrag& vtf, constant LightingUniform& lu,
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(URDE_THERMAL_HOT)
|
||||
#if defined(URDE_THERMAL_MODEL)
|
||||
float4 PostFunc(thread VertToFrag& vtf, constant LightingUniform& lu,
|
||||
texture2d<float> extTex0, texture2d<float> extTex1, texture2d<float> extTex2,
|
||||
sampler samp, sampler clampSamp, sampler clampEdgeSamp, float4 colorIn) {
|
||||
|
|
|
@ -265,7 +265,12 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
|||
#srcfac one
|
||||
#dstfac zero
|
||||
#colorwrite false
|
||||
#depthtest gequal
|
||||
#alphawrite true
|
||||
#depthwrite false
|
||||
#culling none
|
||||
#depthtest none
|
||||
#primitive tristrips
|
||||
#overwritealpha true
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn;
|
||||
|
|
Loading…
Reference in New Issue