2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 12:24: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

@@ -470,8 +470,6 @@ vertex VertToFrag vmain(constant VertData* va [[ buffer(1) ]],
constant VertData& v = va[instId];
vtf.color = v.colorIn * particle.moduColor;
vtf.uvScene = v.uvsInScene;
vtf.uvScene.y = 1.0 - vtf.uvScene.y;
vtf.uvScene.w = 1.0 - vtf.uvScene.w;
vtf.uvTexr = v.uvsInTexrTind[vertId].xy;
vtf.uvTind = v.uvsInTexrTind[vertId].zw;
vtf.position = particle.mvp * v.posIn[vertId];

View File

@@ -261,7 +261,7 @@ struct FogUniform
float4 MainPostFunc(thread VertToFrag& vtf, constant FogUniform& fu, float4 colorIn)
{
float fogZ;
float fogF = saturate((fu.A / (fu.B - vtf.position.z)) - fu.C);
float fogF = saturate((fu.A / (fu.B - (1.0 - vtf.position.z))) - fu.C);
switch (fu.mode)
{
case 2:

View File

@@ -223,7 +223,7 @@ struct VertToFrag
static float4 MainPostFunc(thread VertToFrag& vtf, constant LineUniform& line, float4 colorIn)
{
float fogZ;
float fogF = saturate((line.fog.A / (line.fog.B - vtf.position.z)) - line.fog.C);
float fogF = saturate((line.fog.A / (line.fog.B - (1.0 - vtf.position.z))) - line.fog.C);
switch (line.fog.mode)
{
case 2:
@@ -410,7 +410,7 @@ struct VertToFrag
static float4 MainPostFunc(thread VertToFrag& vtf, constant LineUniform& line, float4 colorIn)
{
float fogZ;
float fogF = saturate((line.fog.A / (line.fog.B - vtf.position.z)) - line.fog.C);
float fogF = saturate((line.fog.A / (line.fog.B - (1.0 - vtf.position.z))) - line.fog.C);
switch (line.fog.mode)
{
case 2:
@@ -671,10 +671,10 @@ struct VertToFrag
float4 color;
};
static float4 MainPostFunc(float4 colorIn, constant LineUniform& line, float FragCoord)
static float4 MainPostFunc(float4 colorIn, constant LineUniform& line, float4 FragCoord)
{
float fogZ;
float fogF = saturate((line.fog.A / (line.fog.B - FragCoord.z)) - line.fog.C);
float fogF = saturate((line.fog.A / (line.fog.B - (1.0 - FragCoord.z))) - line.fog.C);
switch (line.fog.mode)
{
case 2:
@@ -850,10 +850,10 @@ struct VertToFrag
float4 color;
};
static float4 MainPostFunc(float4 colorIn, constant LineUniform& line, float FragCoord)
static float4 MainPostFunc(float4 colorIn, constant LineUniform& line, float4 FragCoord)
{
float fogZ;
float fogF = saturate((line.fog.A / (line.fog.B - FragCoord.z)) - line.fog.C);
float fogF = saturate((line.fog.A / (line.fog.B - (1.0 - FragCoord.z))) - line.fog.C);
switch (line.fog.mode)
{
case 2:

View File

@@ -247,8 +247,11 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
texture2d<float> noiseTex [[ texture(1) ]])
{
float4 noiseTexel = noiseTex.read(Lookup8BPP(vtf.noiseUv, vtf.randOff));
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) + 16.0 / 255.0;
float2 indCoord = (float3x3(vtf.indMtx0, vtf.indMtx1, vtf.indMtx2) * float3(noiseTexel.r - 0.5, noiseTexel.a - 0.5, 1.0)).xy;
float2 sceneUv = vtf.sceneUv + indCoord;
sceneUv.y = 1.0 - sceneUv.y;
float indScene = dot(sceneTex.sample(samp, sceneUv), kRGBToYPrime) + 16.0 / 255.0;
float4 colorOut = vtf.colorReg0 * indScene + vtf.colorReg2 - vtf.colorReg1 * noiseTexel.r;
colorOut.a = vtf.colorReg1.a + vtf.colorReg1.a * noiseTexel.r + vtf.colorReg2.a;
return colorOut;
}

View File

@@ -15,7 +15,7 @@
"static float4 MainPostFunc(thread VertToFrag& vtf, constant LightingUniform& lu, float4 colorIn)\n" \
"{\n" \
" float fogZ;\n" \
" float fogF = saturate((lu.fog.A / (lu.fog.B - vtf.pos.z)) - lu.fog.C);\n" \
" float fogF = saturate((lu.fog.A / (lu.fog.B - (1.0 - vtf.pos.z))) - lu.fog.C);\n" \
" switch (lu.fog.mode)\n" \
" {\n" \
" case 2:\n" \
@@ -41,7 +41,7 @@
"#if %d\n" \
" return float4(mix(colorIn, float4(0.0), saturate(fogZ)).rgb, colorIn.a);\n" \
"#else\n" \
" return float4(mix(colorIn, fog.color, saturate(fogZ)).rgb, colorIn.a);\n" \
" return float4(mix(colorIn, lu.fog.color, saturate(fogZ)).rgb, colorIn.a);\n" \
"#endif\n" \
"}\n"