2
0
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:
Jack Andersen
2018-12-07 19:30:43 -10:00
parent 41ae32be31
commit 636c82a568
1451 changed files with 171430 additions and 203303 deletions

View File

@@ -1,7 +1,6 @@
#include "CModelShaders.hpp"
namespace urde
{
namespace urde {
using namespace std::literals;
extern const hecl::Backend::Function ExtensionLightingFuncsMetal[];
@@ -119,111 +118,109 @@ static std::string_view LightingShadowMetal =
"}\n"sv;
static std::string_view MainPostMetal =
"float4 MainPostFunc(thread VertToFrag& vtf, constant LightingUniform& lu, float4 colorIn)\n"
"{\n"
" float fogZ, temp;\n"
" switch (lu.fog.mode)\n"
" {\n"
" case 2:\n"
" fogZ = (-vtf.mvPos.z - lu.fog.start) * lu.fog.rangeScale;\n"
" break;\n"
" case 4:\n"
" fogZ = 1.0 - exp2(-8.0 * (-vtf.mvPos.z - lu.fog.start) * lu.fog.rangeScale);\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"
" break;\n"
" case 6:\n"
" fogZ = exp2(-8.0 * (lu.fog.start + vtf.mvPos.z) * lu.fog.rangeScale);\n"
" break;\n"
" case 7:\n"
" temp = (lu.fog.start + vtf.mvPos.z) * lu.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 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"
"#endif\n"
"}\n"
"\n"sv;
"float4 MainPostFunc(thread VertToFrag& vtf, constant LightingUniform& lu, float4 colorIn)\n"
"{\n"
" float fogZ, temp;\n"
" switch (lu.fog.mode)\n"
" {\n"
" case 2:\n"
" fogZ = (-vtf.mvPos.z - lu.fog.start) * lu.fog.rangeScale;\n"
" break;\n"
" case 4:\n"
" fogZ = 1.0 - exp2(-8.0 * (-vtf.mvPos.z - lu.fog.start) * lu.fog.rangeScale);\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"
" break;\n"
" case 6:\n"
" fogZ = exp2(-8.0 * (lu.fog.start + vtf.mvPos.z) * lu.fog.rangeScale);\n"
" break;\n"
" case 7:\n"
" temp = (lu.fog.start + vtf.mvPos.z) * lu.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 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"
"#endif\n"
"}\n"
"\n"sv;
static std::string_view ThermalPostMetal =
"struct ThermalUniform\n"
"{\n"
" float4 tmulColor;\n"
" float4 addColor;\n"
"};\n"
"static float4 EXTThermalPostFunc(thread VertToFrag& vtf, constant ThermalUniform& lu,\n"
" sampler samp, sampler clampSamp, texture2d<float> extTex7, float4 colorIn)\n"
"{\n"
" //return float4(vtf.extTcgs0.xy, 0.0, 1.0);\n"
" return float4(extTex7.sample(samp, vtf.extTcgs0).rrr * lu.tmulColor.rgb + lu.addColor.rgb,\n"
" lu.tmulColor.a + lu.addColor.a);\n"
"}\n"
"\n"sv;
"struct ThermalUniform\n"
"{\n"
" float4 tmulColor;\n"
" float4 addColor;\n"
"};\n"
"static float4 EXTThermalPostFunc(thread VertToFrag& vtf, constant ThermalUniform& lu,\n"
" sampler samp, sampler clampSamp, texture2d<float> extTex7, float4 colorIn)\n"
"{\n"
" //return float4(vtf.extTcgs0.xy, 0.0, 1.0);\n"
" return float4(extTex7.sample(samp, vtf.extTcgs0).rrr * lu.tmulColor.rgb + lu.addColor.rgb,\n"
" lu.tmulColor.a + lu.addColor.a);\n"
"}\n"
"\n"sv;
static std::string_view SolidPostMetal =
"struct SolidUniform\n"
"{\n"
" float4 solidColor;\n"
"};\n"
"static float4 SolidPostFunc(thread VertToFrag& vtf, constant SolidUniform& lu, float4 colorIn)\n"
"{\n"
" return lu.solidColor;\n"
"}\n"
"\n"sv;
"struct SolidUniform\n"
"{\n"
" float4 solidColor;\n"
"};\n"
"static float4 SolidPostFunc(thread VertToFrag& vtf, constant SolidUniform& lu, float4 colorIn)\n"
"{\n"
" return lu.solidColor;\n"
"}\n"
"\n"sv;
static std::string_view MBShadowPostMetal =
"struct MBShadowUniform\n"
"{\n"
" float4 shadowUp;\n"
" float shadowId;\n"
"};\n"
"static float4 EXTMBShadowPostFunc(thread VertToFrag& vtf, constant MBShadowUniform& su, sampler samp, sampler clampSamp,\n"
" texture2d<float> extTex0, texture2d<float> extTex1, texture2d<float> extTex2, float4 colorIn)\n"
"{\n"
" float idTexel = extTex0.sample(samp, vtf.extTcgs0).a;\n"
" float sphereTexel = extTex1.sample(samp, vtf.extTcgs1).a;\n"
" float fadeTexel = extTex2.sample(samp, vtf.extTcgs2).a;\n"
" float val = ((fabs(idTexel - su.shadowId) < 0.001) ?\n"
" (dot(vtf.mvNorm.xyz, su.shadowUp.xyz) * su.shadowUp.w) : 0.0) *\n"
" sphereTexel * fadeTexel;\n"
" return float4(0.0, 0.0, 0.0, val);\n"
"}\n"
"\n"sv;
"struct MBShadowUniform\n"
"{\n"
" float4 shadowUp;\n"
" float shadowId;\n"
"};\n"
"static float4 EXTMBShadowPostFunc(thread VertToFrag& vtf, constant MBShadowUniform& su, sampler samp, sampler "
"clampSamp,\n"
" texture2d<float> extTex0, texture2d<float> extTex1, texture2d<float> extTex2, "
"float4 colorIn)\n"
"{\n"
" float idTexel = extTex0.sample(samp, vtf.extTcgs0).a;\n"
" float sphereTexel = extTex1.sample(samp, vtf.extTcgs1).a;\n"
" float fadeTexel = extTex2.sample(samp, vtf.extTcgs2).a;\n"
" float val = ((fabs(idTexel - su.shadowId) < 0.001) ?\n"
" (dot(vtf.mvNorm.xyz, su.shadowUp.xyz) * su.shadowUp.w) : 0.0) *\n"
" sphereTexel * fadeTexel;\n"
" return float4(0.0, 0.0, 0.0, val);\n"
"}\n"
"\n"sv;
const hecl::Backend::Function ExtensionLightingFuncsMetal[] =
{
{},
{LightingMetal, "LightingFunc"},
{},
{LightingMetal, "LightingFunc"},
{LightingMetal, "LightingFunc"},
{},
{},
{},
{},
{},
{},
{},
{LightingShadowMetal, "EXTLightingShadowFunc"},
{LightingMetal, "LightingFunc"},
{LightingMetal, "LightingFunc"},
{LightingMetal, "LightingFunc"},
{LightingMetal, "LightingFunc"},
{LightingMetal, "LightingFunc"},
{LightingMetal, "LightingFunc"},
{LightingMetal, "LightingFunc"}
};
const hecl::Backend::Function ExtensionLightingFuncsMetal[] = {{},
{LightingMetal, "LightingFunc"},
{},
{LightingMetal, "LightingFunc"},
{LightingMetal, "LightingFunc"},
{},
{},
{},
{},
{},
{},
{},
{LightingShadowMetal, "EXTLightingShadowFunc"},
{LightingMetal, "LightingFunc"},
{LightingMetal, "LightingFunc"},
{LightingMetal, "LightingFunc"},
{LightingMetal, "LightingFunc"},
{LightingMetal, "LightingFunc"},
{LightingMetal, "LightingFunc"},
{LightingMetal, "LightingFunc"}};
const hecl::Backend::Function ExtensionPostFuncsMetal[] =
{
const hecl::Backend::Function ExtensionPostFuncsMetal[] = {
{},
{MainPostMetal, "MainPostFunc"},
{ThermalPostMetal, "EXTThermalPostFunc"},
@@ -251,4 +248,4 @@ static const char* ThermalBlockNames[] = {"ThermalUniform"};
static const char* SolidBlockNames[] = {"SolidUniform"};
static const char* MBShadowBlockNames[] = {"MBShadowUniform"};
}
} // namespace urde