mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-13 06:46:10 +00:00
New code style refactor
This commit is contained in:
@@ -1,52 +1,51 @@
|
||||
#include "CModelShaders.hpp"
|
||||
#include "hecl/Backend/GLSL.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
namespace urde {
|
||||
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_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"
|
||||
#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"
|
||||
@@ -156,72 +155,68 @@ static std::string_view LightingShadowGLSL =
|
||||
"}\n"sv;
|
||||
|
||||
static std::string_view MainPostGLSL =
|
||||
"vec4 MainPostFunc(vec4 colorIn)\n"
|
||||
"{\n"
|
||||
FOG_ALGORITHM_GLSL
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
"vec4 MainPostFunc(vec4 colorIn)\n"
|
||||
"{\n" FOG_ALGORITHM_GLSL
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
|
||||
static std::string_view ThermalPostGLSL =
|
||||
"UBINDING2 uniform ThermalUniform\n"
|
||||
"{\n"
|
||||
" vec4 tmulColor;\n"
|
||||
" vec4 addColor;\n"
|
||||
"};\n"
|
||||
"vec4 ThermalPostFunc(vec4 colorIn)\n"
|
||||
"{\n"
|
||||
" return vec4(texture(extTex7, vtf.extTcgs[0]).rrr * tmulColor.rgb + addColor.rgb, tmulColor.a + addColor.a);\n"
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
"UBINDING2 uniform ThermalUniform\n"
|
||||
"{\n"
|
||||
" vec4 tmulColor;\n"
|
||||
" vec4 addColor;\n"
|
||||
"};\n"
|
||||
"vec4 ThermalPostFunc(vec4 colorIn)\n"
|
||||
"{\n"
|
||||
" return vec4(texture(extTex7, vtf.extTcgs[0]).rrr * tmulColor.rgb + addColor.rgb, tmulColor.a + addColor.a);\n"
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
|
||||
static std::string_view SolidPostGLSL =
|
||||
"UBINDING2 uniform SolidUniform\n"
|
||||
"{\n"
|
||||
" vec4 solidColor;\n"
|
||||
"};\n"
|
||||
"vec4 SolidPostFunc(vec4 colorIn)\n"
|
||||
"{\n"
|
||||
" return solidColor;\n"
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
"UBINDING2 uniform SolidUniform\n"
|
||||
"{\n"
|
||||
" vec4 solidColor;\n"
|
||||
"};\n"
|
||||
"vec4 SolidPostFunc(vec4 colorIn)\n"
|
||||
"{\n"
|
||||
" return solidColor;\n"
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
|
||||
static std::string_view MBShadowPostGLSL =
|
||||
"UBINDING2 uniform MBShadowUniform\n"
|
||||
"{\n"
|
||||
" vec4 shadowUp;\n"
|
||||
" float shadowId;\n"
|
||||
"};\n"
|
||||
"vec4 MBShadowPostFunc(vec4 colorIn)\n"
|
||||
"{\n"
|
||||
" float idTexel = texture(extTex0, vtf.extTcgs[0]).a;\n"
|
||||
" float sphereTexel = texture(extTex1, vtf.extTcgs[1]).a;\n"
|
||||
" float fadeTexel = texture(extTex2, vtf.extTcgs[2]).a;\n"
|
||||
" float val = ((abs(idTexel - shadowId) < 0.001) ?\n"
|
||||
" (dot(vtf.mvNorm.xyz, shadowUp.xyz) * shadowUp.w) : 0.0) *\n"
|
||||
" sphereTexel * fadeTexel;\n"
|
||||
" return vec4(0.0, 0.0, 0.0, val);\n"
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
"UBINDING2 uniform MBShadowUniform\n"
|
||||
"{\n"
|
||||
" vec4 shadowUp;\n"
|
||||
" float shadowId;\n"
|
||||
"};\n"
|
||||
"vec4 MBShadowPostFunc(vec4 colorIn)\n"
|
||||
"{\n"
|
||||
" float idTexel = texture(extTex0, vtf.extTcgs[0]).a;\n"
|
||||
" float sphereTexel = texture(extTex1, vtf.extTcgs[1]).a;\n"
|
||||
" float fadeTexel = texture(extTex2, vtf.extTcgs[2]).a;\n"
|
||||
" float val = ((abs(idTexel - shadowId) < 0.001) ?\n"
|
||||
" (dot(vtf.mvNorm.xyz, shadowUp.xyz) * shadowUp.w) : 0.0) *\n"
|
||||
" sphereTexel * fadeTexel;\n"
|
||||
" return vec4(0.0, 0.0, 0.0, val);\n"
|
||||
"}\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;
|
||||
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[] =
|
||||
{
|
||||
const hecl::Backend::Function ExtensionLightingFuncsGLSL[] = {
|
||||
{},
|
||||
{LightingGLSL, "LightingFunc"},
|
||||
{},
|
||||
@@ -245,8 +240,7 @@ const hecl::Backend::Function ExtensionLightingFuncsGLSL[] =
|
||||
{},
|
||||
};
|
||||
|
||||
const hecl::Backend::Function ExtensionPostFuncsGLSL[] =
|
||||
{
|
||||
const hecl::Backend::Function ExtensionPostFuncsGLSL[] = {
|
||||
{},
|
||||
{MainPostGLSL, "MainPostFunc"},
|
||||
{ThermalPostGLSL, "ThermalPostFunc"},
|
||||
@@ -270,4 +264,4 @@ const hecl::Backend::Function ExtensionPostFuncsGLSL[] =
|
||||
{DisintegratePostGLSL, "DisintegratePostFunc"},
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace urde
|
||||
|
||||
Reference in New Issue
Block a user