2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-13 06:46:10 +00:00

Various bug fixes

This commit is contained in:
Jack Andersen
2018-11-07 14:53:38 -10:00
parent 0b3a9e1865
commit 1aab0528f3
29 changed files with 478 additions and 167 deletions

View File

@@ -8,6 +8,46 @@ using namespace std::literals;
extern const hecl::Backend::Function ExtensionLightingFuncsGLSL[];
extern const hecl::Backend::Function ExtensionPostFuncsGLSL[];
#define FOG_STRUCT_GLSL \
"struct Fog\n" \
"{\n" \
" int mode;\n" \
" vec4 color;\n" \
" float rangeScale;\n" \
" float start;\n" \
"};\n"
#define FOG_ALGORITHM_GLSL \
" float fogZ, temp;\n" \
" switch (fog.mode)\n" \
" {\n" \
" case 2:\n" \
" fogZ = (-vtf.mvPos.z - fog.start) * fog.rangeScale;\n" \
" break;\n" \
" case 4:\n" \
" fogZ = 1.0 - exp2(-8.0 * (-vtf.mvPos.z - fog.start) * fog.rangeScale);\n" \
" break;\n" \
" case 5:\n" \
" temp = (-vtf.mvPos.z - fog.start) * fog.rangeScale;\n" \
" fogZ = 1.0 - exp2(-8.0 * temp * temp);\n" \
" break;\n" \
" case 6:\n" \
" fogZ = exp2(-8.0 * (fog.start + vtf.mvPos.z) * fog.rangeScale);\n" \
" break;\n" \
" case 7:\n" \
" temp = (fog.start + vtf.mvPos.z) * fog.rangeScale;\n" \
" fogZ = exp2(-8.0 * temp * temp);\n" \
" break;\n" \
" default:\n" \
" fogZ = 0.0;\n" \
" break;\n" \
" }\n" \
"#ifdef BLEND_DST_ONE\n" \
" return vec4(mix(colorIn, vec4(0.0), clamp(fogZ, 0.0, 1.0)).rgb, colorIn.a);\n" \
"#else\n" \
" return vec4(mix(colorIn, fog.color, clamp(fogZ, 0.0, 1.0)).rgb, colorIn.a);\n" \
"#endif\n"
static std::string_view LightingGLSL =
"struct Light\n"
"{\n"
@@ -17,13 +57,7 @@ static std::string_view LightingGLSL =
" vec4 linAtt;\n"
" vec4 angAtt;\n"
"};\n"
"struct Fog\n"
"{\n"
" int mode;\n"
" vec4 color;\n"
" float rangeScale;\n"
" float start;\n"
"};\n"
FOG_STRUCT_GLSL
"\n"
"UBINDING2 uniform LightingUniform\n"
"{\n"
@@ -124,35 +158,7 @@ static std::string_view LightingShadowGLSL =
static std::string_view MainPostGLSL =
"vec4 MainPostFunc(vec4 colorIn)\n"
"{\n"
" float fogZ, temp;\n"
" switch (fog.mode)\n"
" {\n"
" case 2:\n"
" fogZ = (-vtf.mvPos.z - fog.start) * fog.rangeScale;\n"
" break;\n"
" case 4:\n"
" fogZ = 1.0 - exp2(-8.0 * (-vtf.mvPos.z - fog.start) * fog.rangeScale);\n"
" break;\n"
" case 5:\n"
" temp = (-vtf.mvPos.z - fog.start) * fog.rangeScale;\n"
" fogZ = 1.0 - exp2(-8.0 * temp * temp);\n"
" break;\n"
" case 6:\n"
" fogZ = exp2(-8.0 * (fog.start + vtf.mvPos.z) * fog.rangeScale);\n"
" break;\n"
" case 7:\n"
" temp = (fog.start + vtf.mvPos.z) * fog.rangeScale;\n"
" fogZ = exp2(-8.0 * temp * temp);\n"
" break;\n"
" default:\n"
" fogZ = 0.0;\n"
" break;\n"
" }\n"
"#ifdef BLEND_DST_ONE\n"
" return vec4(mix(colorIn, vec4(0.0), clamp(fogZ, 0.0, 1.0)).rgb, colorIn.a);\n"
"#else\n"
" return vec4(mix(colorIn, fog.color, clamp(fogZ, 0.0, 1.0)).rgb, colorIn.a);\n"
"#endif\n"
FOG_ALGORITHM_GLSL
"}\n"
"\n"sv;
@@ -197,6 +203,23 @@ static std::string_view MBShadowPostGLSL =
"}\n"
"\n"sv;
static std::string_view DisintegratePostGLSL =
FOG_STRUCT_GLSL
"UBINDING2 uniform DisintegrateUniform\n"
"{\n"
" vec4 addColor;\n"
" Fog fog;\n"
"};\n"
"vec4 DisintegratePostFunc(vec4 colorIn)\n"
"{\n"
" vec4 texel0 = texture(extTex7, vtf.extTcgs[0]);\n"
" vec4 texel1 = texture(extTex7, vtf.extTcgs[1]);\n"
" colorIn = mix(vec4(0.0), texel1, texel0);\n"
" colorIn.rgb += addColor.rgb;\n"
FOG_ALGORITHM_GLSL
"}\n"
"\n"sv;
const hecl::Backend::Function ExtensionLightingFuncsGLSL[] =
{
{},
@@ -218,7 +241,8 @@ const hecl::Backend::Function ExtensionLightingFuncsGLSL[] =
{LightingGLSL, "LightingFunc"},
{LightingGLSL, "LightingFunc"},
{LightingGLSL, "LightingFunc"},
{LightingGLSL, "LightingFunc"}
{LightingGLSL, "LightingFunc"},
{},
};
const hecl::Backend::Function ExtensionPostFuncsGLSL[] =
@@ -243,6 +267,7 @@ const hecl::Backend::Function ExtensionPostFuncsGLSL[] =
{MainPostGLSL, "MainPostFunc"},
{MainPostGLSL, "MainPostFunc"},
{MainPostGLSL, "MainPostFunc"},
{DisintegratePostGLSL, "DisintegratePostFunc"},
};
}