2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-05-13 11:11:22 +00:00

Thermal visor fixes

This commit is contained in:
Jack Andersen 2019-02-24 22:14:59 -10:00
parent 5ebf465a53
commit 67b9882dbe
14 changed files with 36 additions and 15 deletions

View File

@ -24,7 +24,7 @@ CActorLights::CActorLights(u32 areaUpdateFramePeriod, const zeus::CVector3f& act
x298_24_dirty = true; x298_24_dirty = true;
x298_25_castShadows = true; x298_25_castShadows = true;
x298_28_inArea = (!disableWorldLights && maxAreaLights > 0) ? true : false; x298_28_inArea = !disableWorldLights && maxAreaLights > 0;
x298_29_ambienceGenerated = ambientChannelOverflow; x298_29_ambienceGenerated = ambientChannelOverflow;
x298_30_layer2 = layer2; x298_30_layer2 = layer2;
x298_31_disableWorldLights = disableWorldLights; x298_31_disableWorldLights = disableWorldLights;
@ -59,6 +59,7 @@ void CActorLights::BuildFakeLightList(const std::vector<CLight>& lights, const z
void CActorLights::BuildFaceLightList(const CStateManager& mgr, const CGameArea& area, const zeus::CAABox& aabb) { void CActorLights::BuildFaceLightList(const CStateManager& mgr, const CGameArea& area, const zeus::CAABox& aabb) {
zeus::CTransform fpTransform = mgr.GetCameraManager()->GetFirstPersonCamera()->GetTransform(); zeus::CTransform fpTransform = mgr.GetCameraManager()->GetFirstPersonCamera()->GetTransform();
x298_26_hasAreaLights = true;
x288_ambientColor = zeus::skBlack; x288_ambientColor = zeus::skBlack;
x144_dynamicLights.clear(); x144_dynamicLights.clear();
zeus::CColor accumColor = zeus::skBlack; zeus::CColor accumColor = zeus::skBlack;

View File

@ -1111,9 +1111,13 @@ void CBooRenderer::DoThermalBlendCold() {
m_thermColdFilter->draw(); m_thermColdFilter->draw();
CElementGen::SetMoveRedToAlphaBuffer(true); CElementGen::SetMoveRedToAlphaBuffer(true);
CDecal::SetMoveRedToAlphaBuffer(true); CDecal::SetMoveRedToAlphaBuffer(true);
m_thermalHotPass = true;
} }
void CBooRenderer::DoThermalBlendHot() { m_thermHotFilter->draw(); } void CBooRenderer::DoThermalBlendHot() {
m_thermHotFilter->draw();
m_thermalHotPass = false;
}
u32 CBooRenderer::GetStaticWorldDataSize() { return 0; } u32 CBooRenderer::GetStaticWorldDataSize() { return 0; }

View File

@ -160,6 +160,7 @@ class CBooRenderer final : public IRenderer {
bool x318_29_thermalVisor : 1; bool x318_29_thermalVisor : 1;
bool x318_30_inAreaDraw : 1; bool x318_30_inAreaDraw : 1;
bool x318_31_persistRGBA6 : 1; bool x318_31_persistRGBA6 : 1;
bool m_thermalHotPass : 1;
}; };
u16 dummy = 0; u16 dummy = 0;
}; };
@ -294,6 +295,7 @@ public:
float alpha) const; float alpha) const;
bool IsThermalVisorActive() const { return x318_29_thermalVisor; } bool IsThermalVisorActive() const { return x318_29_thermalVisor; }
bool IsThermalVisorHotPass() const { return m_thermalHotPass; }
}; };
} // namespace urde } // namespace urde

View File

@ -35,6 +35,8 @@ struct CModelFlags {
CModelFlags(u8 blendMode, u8 shadIdx, u16 flags, const zeus::CColor& col) CModelFlags(u8 blendMode, u8 shadIdx, u16 flags, const zeus::CColor& col)
: x0_blendMode(blendMode), x1_matSetIdx(shadIdx), x2_flags(flags), x4_color(col) { : x0_blendMode(blendMode), x1_matSetIdx(shadIdx), x2_flags(flags), x4_color(col) {
/* Blend mode will override this if the surface's original material is opaque */ /* Blend mode will override this if the surface's original material is opaque */
m_noZWrite = !(x2_flags & 0x2);
m_depthGreater = (x2_flags & 0x8);
} }
/* Flags /* Flags

View File

@ -530,7 +530,9 @@ static EExtendedShader ResolveExtendedShader(const MaterialSet::Material& data,
EExtendedShader extended = EExtendedShader::Flat; EExtendedShader extended = EExtendedShader::Flat;
if (flags.m_extendedShader == EExtendedShader::Lighting) { if (flags.m_extendedShader == EExtendedShader::Lighting) {
/* Transform lighting into thermal cold if the thermal visor is active */ /* Transform lighting into thermal cold if the thermal visor is active */
if (g_Renderer->IsThermalVisorActive()) if (g_Renderer->IsThermalVisorHotPass())
return EExtendedShader::LightingAlphaWrite;
else if (g_Renderer->IsThermalVisorActive())
return EExtendedShader::ThermalCold; return EExtendedShader::ThermalCold;
if (data.heclIr.m_blendSrc == boo::BlendFactor::One && data.heclIr.m_blendDst == boo::BlendFactor::Zero) { if (data.heclIr.m_blendSrc == boo::BlendFactor::One && data.heclIr.m_blendDst == boo::BlendFactor::Zero) {
/* Override shader if originally opaque (typical for FRME models) */ /* Override shader if originally opaque (typical for FRME models) */

View File

@ -91,7 +91,7 @@ static hecl::Backend::ExtensionSlot g_ExtensionSlots[] = {
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true}, hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true},
/* Forced additive shading */ /* Forced additive shading */
{1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One, {1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One,
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, true, false, true}, hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true},
/* Solid color */ /* Solid color */
{1, SolidBlockNames, 0, nullptr, hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::Zero, {1, SolidBlockNames, 0, nullptr, hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::Zero,
hecl::Backend::ZTest::LEqual, hecl::Backend::CullMode::Backface, false, false, false}, hecl::Backend::ZTest::LEqual, hecl::Backend::CullMode::Backface, false, false, false},
@ -148,7 +148,10 @@ static hecl::Backend::ExtensionSlot g_ExtensionSlots[] = {
/* Thermal cold shading */ /* Thermal cold shading */
{1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original, {1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Original, hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Original,
false, false, true, false, false, false, true}}; false, false, true, false, false, false, true},
/* Normal lit shading with alpha */
{1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface}};
extern const hecl::Backend::Function ExtensionLightingFuncsGLSL[]; extern const hecl::Backend::Function ExtensionLightingFuncsGLSL[];
extern const hecl::Backend::Function ExtensionPostFuncsGLSL[]; extern const hecl::Backend::Function ExtensionPostFuncsGLSL[];

View File

@ -36,6 +36,7 @@ enum EExtendedShader : uint8_t {
Disintegrate, Disintegrate,
ForcedAdditiveNoZWriteDepthGreater, ForcedAdditiveNoZWriteDepthGreater,
ThermalCold, ThermalCold,
LightingAlphaWrite,
MAX MAX
}; };

View File

@ -252,6 +252,7 @@ const hecl::Backend::Function ExtensionLightingFuncsGLSL[] = {
{}, {},
{LightingGLSL, "LightingFunc"}, {LightingGLSL, "LightingFunc"},
{}, {},
{LightingGLSL, "LightingFunc"},
}; };
const hecl::Backend::Function ExtensionPostFuncsGLSL[] = { const hecl::Backend::Function ExtensionPostFuncsGLSL[] = {
@ -278,6 +279,7 @@ const hecl::Backend::Function ExtensionPostFuncsGLSL[] = {
{DisintegratePostGLSL, "DisintegratePostFunc"}, {DisintegratePostGLSL, "DisintegratePostFunc"},
{MainPostGLSL, "MainPostFunc"}, {MainPostGLSL, "MainPostFunc"},
{ThermalColdPostGLSL, "ThermalColdPostFunc"}, {ThermalColdPostGLSL, "ThermalColdPostFunc"},
{MainPostGLSL, "MainPostFunc"},
}; };
} // namespace urde } // namespace urde

View File

@ -243,7 +243,8 @@ const hecl::Backend::Function ExtensionLightingFuncsHLSL[] = {{},
{LightingHLSL, "LightingFunc"}, {LightingHLSL, "LightingFunc"},
{}, {},
{LightingHLSL, "LightingFunc"}, {LightingHLSL, "LightingFunc"},
{}}; {},
{LightingHLSL, "LightingFunc"},};
const hecl::Backend::Function ExtensionPostFuncsHLSL[] = { const hecl::Backend::Function ExtensionPostFuncsHLSL[] = {
{}, {},
@ -269,6 +270,7 @@ const hecl::Backend::Function ExtensionPostFuncsHLSL[] = {
{DisintegratePostHLSL, "DisintegratePostFunc"}, {DisintegratePostHLSL, "DisintegratePostFunc"},
{MainPostHLSL, "MainPostFunc"}, {MainPostHLSL, "MainPostFunc"},
{ThermalColdPostHLSL, "ThermalColdPostFunc"}, {ThermalColdPostHLSL, "ThermalColdPostFunc"},
{MainPostHLSL, "MainPostFunc"},
}; };
} // namespace urde } // namespace urde

View File

@ -248,7 +248,8 @@ const hecl::Backend::Function ExtensionLightingFuncsMetal[] = {{},
{LightingMetal, "LightingFunc"}, {LightingMetal, "LightingFunc"},
{}, {},
{LightingMetal, "LightingFunc"}, {LightingMetal, "LightingFunc"},
{}}; {},
{LightingMetal, "LightingFunc"},};
const hecl::Backend::Function ExtensionPostFuncsMetal[] = { const hecl::Backend::Function ExtensionPostFuncsMetal[] = {
{}, {},
@ -274,6 +275,7 @@ const hecl::Backend::Function ExtensionPostFuncsMetal[] = {
{DisintegratePostMetal, "EXTDisintegratePostFunc"}, {DisintegratePostMetal, "EXTDisintegratePostFunc"},
{MainPostMetal, "MainPostFunc"}, {MainPostMetal, "MainPostFunc"},
{ThermalColdPostMetal, "ThermalColdPostFunc"}, {ThermalColdPostMetal, "ThermalColdPostFunc"},
{MainPostMetal, "MainPostFunc"},
}; };
} // namespace urde } // namespace urde

View File

@ -12,7 +12,7 @@ static const zeus::CTransform PreXf = zeus::CTransform::Scale(0.3f) * zeus::CTra
CSamusFaceReflection::CSamusFaceReflection(CStateManager& stateMgr) CSamusFaceReflection::CSamusFaceReflection(CStateManager& stateMgr)
: x0_modelData(CAnimRes(g_ResFactory->GetResourceIdByName("ACS_SamusFace")->id, 0, zeus::skOne3f, 0, true)) : x0_modelData(CAnimRes(g_ResFactory->GetResourceIdByName("ACS_SamusFace")->id, 0, zeus::skOne3f, 0, true))
, x4c_lights(std::make_unique<CActorLights>(8, zeus::skZero3f, 4, 4, false, 0, 0, 0.1f)) { , x4c_lights(std::make_unique<CActorLights>(8, zeus::skZero3f, 4, 4, false, false, false, 0.1f)) {
x60_lookDir = zeus::skForward; x60_lookDir = zeus::skForward;
CAnimPlaybackParms parms(0, -1, 1.f, true); CAnimPlaybackParms parms(0, -1, 1.f, true);
x0_modelData.AnimationData()->SetAnimation(parms, false); x0_modelData.AnimationData()->SetAnimation(parms, false);

View File

@ -78,7 +78,7 @@ const vec4 kRGBToYPrime = vec4(0.299, 0.587, 0.114, 0.0);
void main() void main()
{ {
vec4 noiseTexel = texelFetch(noiseTex, Lookup8BPP(vtf.noiseUv, vtf.randOff), 0); vec4 noiseTexel = texelFetch(noiseTex, Lookup8BPP(vtf.noiseUv, vtf.randOff), 0);
vec2 indCoord = (vtf.indMtx * vec3(noiseTexel.x - 0.5, noiseTexel.y - 0.5, 1.0)).xy; vec2 indCoord = (vtf.indMtx * vec3(noiseTexel.r - 0.5, noiseTexel.a - 0.5, 1.0)).xy;
float indScene = dot(texture(sceneTex, vtf.sceneUv + indCoord), kRGBToYPrime); float indScene = dot(texture(sceneTex, vtf.sceneUv + indCoord), kRGBToYPrime);
colorOut = vtf.colorReg0 * indScene + vtf.colorReg1 * noiseTexel + vtf.colorReg2; colorOut = vtf.colorReg0 * indScene + vtf.colorReg1 * noiseTexel + vtf.colorReg2;
colorOut.a = vtf.colorReg1.a + vtf.colorReg1.a * noiseTexel.a + vtf.colorReg2.a; colorOut.a = vtf.colorReg1.a + vtf.colorReg1.a * noiseTexel.a + vtf.colorReg2.a;
@ -158,7 +158,7 @@ static const float4 kRGBToYPrime = {0.299, 0.587, 0.114, 0.0};
float4 main(in VertToFrag vtf) : SV_Target0 float4 main(in VertToFrag vtf) : SV_Target0
{ {
float4 noiseTexel = noiseTex.Load(Lookup8BPP(vtf.noiseUv, vtf.randOff)); float4 noiseTexel = noiseTex.Load(Lookup8BPP(vtf.noiseUv, vtf.randOff));
float2 indCoord = mul(vtf.indMtx, float3(noiseTexel.x - 0.5, noiseTexel.y - 0.5, 1.0)).xy; float2 indCoord = mul(vtf.indMtx, float3(noiseTexel.r - 0.5, noiseTexel.a - 0.5, 1.0)).xy;
float indScene = dot(sceneTex.Sample(samp, vtf.sceneUv + indCoord), kRGBToYPrime); float indScene = dot(sceneTex.Sample(samp, vtf.sceneUv + indCoord), kRGBToYPrime);
float4 colorOut = vtf.colorReg0 * indScene + vtf.colorReg1 * noiseTexel + vtf.colorReg2; float4 colorOut = vtf.colorReg0 * indScene + vtf.colorReg1 * noiseTexel + vtf.colorReg2;
colorOut.a = vtf.colorReg1.a + vtf.colorReg1.a * noiseTexel.a + vtf.colorReg2.a; colorOut.a = vtf.colorReg1.a + vtf.colorReg1.a * noiseTexel.a + vtf.colorReg2.a;
@ -245,7 +245,7 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
texture2d<float> noiseTex [[ texture(1) ]]) texture2d<float> noiseTex [[ texture(1) ]])
{ {
float4 noiseTexel = noiseTex.read(Lookup8BPP(vtf.noiseUv, vtf.randOff)); float4 noiseTexel = noiseTex.read(Lookup8BPP(vtf.noiseUv, vtf.randOff));
float2 indCoord = (vtf.indMtx * float3(noiseTexel.x - 0.5, noiseTexel.y - 0.5, 1.0)).xy; float2 indCoord = (vtf.indMtx * float3(noiseTexel.r - 0.5, noiseTexel.a - 0.5, 1.0)).xy;
float indScene = dot(sceneTex.sample(samp, vtf.sceneUv + indCoord), kRGBToYPrime); float indScene = dot(sceneTex.sample(samp, vtf.sceneUv + indCoord), kRGBToYPrime);
float4 colorOut = vtf.colorReg0 * indScene + vtf.colorReg1 * noiseTexel + vtf.colorReg2; float4 colorOut = vtf.colorReg0 * indScene + vtf.colorReg1 * noiseTexel + vtf.colorReg2;
colorOut.a = vtf.colorReg1.a + vtf.colorReg1.a * noiseTexel.a + vtf.colorReg2.a; colorOut.a = vtf.colorReg1.a + vtf.colorReg1.a * noiseTexel.a + vtf.colorReg2.a;

View File

@ -46,7 +46,7 @@ void main()
{ {
float sceneSample = dot(texture(sceneTex, vtf.sceneUv), kRGBToYPrime); float sceneSample = dot(texture(sceneTex, vtf.sceneUv), kRGBToYPrime);
vec4 colorSample = texture(paletteTex, vec2(sceneSample / 17.0, 0.5)); vec4 colorSample = texture(paletteTex, vec2(sceneSample / 17.0, 0.5));
colorOut = vec4((colorSample * sceneSample).rgb, 0.0); colorOut = vec4(colorSample.rgb, 0.0);
} }
#vertex hlsl #vertex hlsl
@ -93,7 +93,7 @@ float4 main(in VertToFrag vtf) : SV_Target0
{ {
float sceneSample = dot(sceneTex.Sample(samp, vtf.sceneUv), kRGBToYPrime); float sceneSample = dot(sceneTex.Sample(samp, vtf.sceneUv), kRGBToYPrime);
float4 colorSample = paletteTex.Sample(samp, float2(sceneSample / 17.0, 0.5)); float4 colorSample = paletteTex.Sample(samp, float2(sceneSample / 17.0, 0.5));
return float4((colorSample * sceneSample).rgb, 0.0); return float4(colorSample.rgb, 0.0);
} }
#vertex metal #vertex metal
@ -140,5 +140,5 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
{ {
float sceneSample = dot(sceneTex.sample(samp, vtf.sceneUv), kRGBToYPrime); float sceneSample = dot(sceneTex.sample(samp, vtf.sceneUv), kRGBToYPrime);
float4 colorSample = paletteTex.sample(samp, float2(sceneSample / 17.0, 0.5)); float4 colorSample = paletteTex.sample(samp, float2(sceneSample / 17.0, 0.5));
return float4((colorSample * sceneSample).rgb, 0.0); return float4(colorSample.rgb, 0.0);
} }

2
hecl

@ -1 +1 @@
Subproject commit a1365b8b943b6ecc904acfbe7d65a734d78bcff0 Subproject commit 947155734274041bc7b3ab1bb8267d0491e48554