2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 13:44:56 +00:00

Metal fixes

This commit is contained in:
Jack Andersen
2019-03-03 18:45:22 -10:00
parent 54f0724de5
commit ed4ebf0af1
8 changed files with 27 additions and 32 deletions

View File

@@ -146,7 +146,7 @@ static hecl::Backend::ExtensionSlot g_ExtensionSlots[] = {
{1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One,
hecl::Backend::ZTest::Greater, hecl::Backend::CullMode::None, true, false, true},
/* Thermal cold shading */
{1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
{0, nullptr, 0, nullptr, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Original,
false, false, true, false, false, false, true},
/* Normal lit shading with alpha */

View File

@@ -17,25 +17,25 @@ extern const hecl::Backend::Function ExtensionPostFuncsMetal[];
"};\n"
#define FOG_ALGORITHM_METAL \
" float fogZ, temp;\n" \
" float fogZ;\n" \
" float fogF = saturate((lu.fog.A / (lu.fog.B - (1.0 - vtf.mvpPos.z))) - lu.fog.C);\n" \
" switch (lu.fog.mode)\n" \
" {\n" \
" case 2:\n" \
" fogZ = (-vtf.mvPos.z - lu.fog.start) * lu.fog.rangeScale;\n" \
" fogZ = fogF;\n" \
" break;\n" \
" case 4:\n" \
" fogZ = 1.0 - exp2(-8.0 * (-vtf.mvPos.z - lu.fog.start) * lu.fog.rangeScale);\n" \
" fogZ = 1.0 - exp2(-8.0 * fogF);\n" \
" break;\n" \
" case 5:\n" \
" temp = (-vtf.mvPos.z - lu.fog.start) * lu.fog.rangeScale;\n" \
" fogZ = 1.0 - exp2(-8.0 * temp * temp);\n" \
" fogZ = 1.0 - exp2(-8.0 * fogF * fogF);\n" \
" break;\n" \
" case 6:\n" \
" fogZ = exp2(-8.0 * (lu.fog.start + vtf.mvPos.z) * lu.fog.rangeScale);\n" \
" fogZ = exp2(-8.0 * (1.0 - fogF));\n" \
" break;\n" \
" case 7:\n" \
" temp = (lu.fog.start + vtf.mvPos.z) * lu.fog.rangeScale;\n" \
" fogZ = exp2(-8.0 * temp * temp);\n" \
" fogF = 1.0 - fogF;\n" \
" fogZ = exp2(-8.0 * fogF * fogF);\n" \
" break;\n" \
" default:\n" \
" fogZ = 0.0;\n" \
@@ -44,7 +44,7 @@ extern const hecl::Backend::Function ExtensionPostFuncsMetal[];
"#ifdef BLEND_DST_ONE\n" \
" return float4(mix(colorIn, float4(0.0), saturate(fogZ)).rgb, colorIn.a);\n" \
"#else\n" \
" return float4(mix(colorIn, lu.fog.color, saturate(fogZ)).rgb, colorIn.a);\n" \
" return float4(mix(colorIn, lu.fog.color, saturate(fogZ)).rgb, colorIn.a);\n" \
"#endif\n"
static std::string_view LightingMetal =
@@ -100,13 +100,7 @@ static std::string_view LightingShadowMetal =
" float4 linAtt;\n"
" float4 angAtt;\n"
"};\n"
"struct Fog\n"
"{\n"
" int mode;\n"
" float4 color;\n"
" float rangeScale;\n"
" float start;\n"
"};\n"
FOG_STRUCT_METAL
"\n"
"struct LightingUniform\n"
"{\n"
@@ -221,7 +215,7 @@ static std::string_view DisintegratePostMetal = FOG_STRUCT_METAL
"\n"sv;
static std::string_view ThermalColdPostMetal =
"static float4 ThermalColdPostFunc(thread VertToFrag& vtf, constant LightingUniform& lu, float4 colorIn)\n"
"static float4 ThermalColdPostFunc(thread VertToFrag& vtf, float4 colorIn)\n"
"{\n"
" return colorIn * float4(0.75, 0.75, 0.75, 0.75);\n"
"}\n"