mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 13:44:56 +00:00
Various rendering fixes
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#primitive tristrips
|
||||
#depthtest lequal
|
||||
#depthwrite true
|
||||
#alphawrite false
|
||||
#culling none
|
||||
|
||||
#vertex glsl
|
||||
@@ -149,47 +150,79 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
return vtf.color * tex0.sample(samp, vtf.uv);
|
||||
}
|
||||
|
||||
#shader CElementGenShaderTexZTestZWriteAWrite : CElementGenShaderTexZTestZWrite
|
||||
#alphawrite true
|
||||
|
||||
#shader CElementGenShaderTexNoZTestZWrite : CElementGenShaderTexZTestZWrite
|
||||
#depthtest none
|
||||
#depthwrite true
|
||||
#alphawrite false
|
||||
|
||||
#shader CElementGenShaderTexNoZTestZWriteAWrite : CElementGenShaderTexNoZTestZWrite
|
||||
#alphawrite true
|
||||
|
||||
#shader CElementGenShaderTexZTestNoZWrite : CElementGenShaderTexZTestZWrite
|
||||
#depthtest lequal
|
||||
#depthwrite false
|
||||
#alphawrite false
|
||||
|
||||
#shader CElementGenShaderTexZTestNoZWriteAWrite : CElementGenShaderTexZTestNoZWrite
|
||||
#alphawrite true
|
||||
|
||||
#shader CElementGenShaderTexNoZTestNoZWrite : CElementGenShaderTexZTestZWrite
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
#alphawrite false
|
||||
|
||||
#shader CElementGenShaderTexNoZTestNoZWriteAWrite : CElementGenShaderTexNoZTestNoZWrite
|
||||
#alphawrite true
|
||||
|
||||
#shader CElementGenShaderTexAdditiveZTest : CElementGenShaderTexZTestZWrite
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#depthtest lequal
|
||||
#depthwrite false
|
||||
#alphawrite false
|
||||
|
||||
#shader CElementGenShaderTexAdditiveZTestAWrite : CElementGenShaderTexAdditiveZTest
|
||||
#alphawrite true
|
||||
|
||||
#shader CElementGenShaderTexAdditiveNoZTest : CElementGenShaderTexZTestZWrite
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
#alphawrite false
|
||||
|
||||
#shader CElementGenShaderTexAdditiveNoZTestAWrite : CElementGenShaderTexAdditiveNoZTest
|
||||
#alphawrite true
|
||||
|
||||
#shader CElementGenShaderTexZTestNoZWriteSub : CElementGenShaderTexZTestZWrite
|
||||
#srcfac subtract
|
||||
#dstfac subtract
|
||||
#depthtest lequal
|
||||
#depthwrite false
|
||||
#alphawrite false
|
||||
|
||||
#shader CElementGenShaderTexZTestNoZWriteSubAWrite : CElementGenShaderTexZTestNoZWriteSub
|
||||
#alphawrite true
|
||||
|
||||
#shader CElementGenShaderTexNoZTestNoZWriteSub : CElementGenShaderTexZTestZWrite
|
||||
#srcfac subtract
|
||||
#dstfac subtract
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
#alphawrite false
|
||||
|
||||
#shader CElementGenShaderTexNoZTestNoZWriteSubAWrite : CElementGenShaderTexNoZTestNoZWriteSub
|
||||
#alphawrite true
|
||||
|
||||
#shader CElementGenShaderTexRedToAlphaZTest : CElementGenShaderTexZTestZWrite
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#srcfac one
|
||||
#dstfac one
|
||||
#depthtest lequal
|
||||
#depthwrite false
|
||||
#alphawrite false
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
@@ -203,8 +236,10 @@ layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D tex;
|
||||
void main()
|
||||
{
|
||||
colorOut = vtf.color;
|
||||
colorOut.a = texture(tex, vtf.uv).r;
|
||||
vec4 texel = texture(tex, vtf.uv);
|
||||
vec4 tmp = texel * vtf.color;
|
||||
colorOut = tmp * tmp.a;
|
||||
colorOut.a = tmp.a * texel.r;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
@@ -219,7 +254,9 @@ struct VertToFrag
|
||||
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
return float4(vtf.color.rgb, tex0.Sample(samp, vtf.uv).r);
|
||||
float4 texel = tex0.Sample(samp, vtf.uv);
|
||||
float4 tmp = texel * vtf.color;
|
||||
return float4(tmp * tmp.a, tmp.a * texel.r);
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
@@ -234,21 +271,38 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler samp [[ sampler(0) ]],
|
||||
texture2d<float> tex0 [[ texture(0) ]])
|
||||
{
|
||||
return float4(vtf.color.rgb, tex0.sample(samp, vtf.uv).r);
|
||||
float4 texel = tex0.sample(samp, vtf.uv);
|
||||
float4 tmp = texel * vtf.color;
|
||||
return float4(tmp * tmp.a, tmp.a * texel.r);
|
||||
}
|
||||
|
||||
#shader CElementGenShaderTexRedToAlphaZTestAWrite : CElementGenShaderTexRedToAlphaZTest
|
||||
#alphawrite true
|
||||
|
||||
#shader CElementGenShaderTexRedToAlphaNoZTest : CElementGenShaderTexRedToAlphaZTest
|
||||
#depthtest none
|
||||
#alphawrite false
|
||||
|
||||
#shader CElementGenShaderTexRedToAlphaNoZTestAWrite : CElementGenShaderTexRedToAlphaNoZTest
|
||||
#alphawrite true
|
||||
|
||||
#shader CElementGenShaderTexRedToAlphaZTestSub : CElementGenShaderTexRedToAlphaZTest
|
||||
#srcfac subtract
|
||||
#dstfac subtract
|
||||
#depthtest lequal
|
||||
#alphawrite false
|
||||
|
||||
#shader CElementGenShaderTexRedToAlphaZTestSubAWrite : CElementGenShaderTexRedToAlphaZTestSub
|
||||
#alphawrite true
|
||||
|
||||
#shader CElementGenShaderTexRedToAlphaNoZTestSub : CElementGenShaderTexRedToAlphaZTest
|
||||
#srcfac subtract
|
||||
#dstfac subtract
|
||||
#depthtest none
|
||||
#alphawrite false
|
||||
|
||||
#shader CElementGenShaderTexRedToAlphaNoZTestSubAWrite : CElementGenShaderTexRedToAlphaNoZTestSub
|
||||
#alphawrite true
|
||||
|
||||
#shader CElementGenShaderIndTexZWrite
|
||||
#instattribute position4 0
|
||||
@@ -265,6 +319,7 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
#dstfac invsrcalpha
|
||||
#depthtest none
|
||||
#depthwrite true
|
||||
#alphawrite false
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn[4];
|
||||
@@ -444,19 +499,31 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
return float4(colr.rgb, vtf.color.a * texrTexel.a);
|
||||
}
|
||||
|
||||
#shader CElementGenShaderIndTexZWriteAWrite : CElementGenShaderIndTexZWrite
|
||||
#alphawrite true
|
||||
|
||||
#shader CElementGenShaderIndTexNoZWrite : CElementGenShaderIndTexZWrite
|
||||
#depthwrite false
|
||||
#alphawrite false
|
||||
|
||||
#shader CElementGenShaderIndTexNoZWriteAWrite : CElementGenShaderIndTexNoZWrite
|
||||
#alphawrite true
|
||||
|
||||
#shader CElementGenShaderIndTexAdditive : CElementGenShaderIndTexZWrite
|
||||
#depthwrite true
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#alphawrite false
|
||||
|
||||
#shader CElementGenShaderIndTexAdditiveAWrite : CElementGenShaderIndTexAdditive
|
||||
#alphawrite true
|
||||
|
||||
#shader CElementGenShaderCindTexZWrite : CElementGenShaderIndTexZWrite
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#depthtest none
|
||||
#depthwrite true
|
||||
#alphawrite false
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
@@ -521,13 +588,24 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
return vtf.color * float4(sceneTexel.rgb, 1.0) * tex0.sample(samp, vtf.uvTexr);
|
||||
}
|
||||
|
||||
#shader CElementGenShaderCindTexZWriteAWrite : CElementGenShaderCindTexZWrite
|
||||
#alphawrite true
|
||||
|
||||
#shader CElementGenShaderCindTexNoZWrite : CElementGenShaderCindTexZWrite
|
||||
#depthwrite false
|
||||
#alphawrite false
|
||||
|
||||
#shader CElementGenShaderCindTexNoZWriteAWrite : CElementGenShaderCindTexNoZWrite
|
||||
#alphawrite true
|
||||
|
||||
#shader CElementGenShaderCindTexAdditive : CElementGenShaderCindTexZWrite
|
||||
#depthwrite true
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#alphawrite false
|
||||
|
||||
#shader CElementGenShaderCindTexAdditiveAWrite : CElementGenShaderCindTexAdditive
|
||||
#alphawrite true
|
||||
|
||||
#shader CElementGenShaderNoTexZTestZWrite
|
||||
#instattribute position4 0
|
||||
@@ -541,6 +619,7 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
#depthtest lequal
|
||||
#depthwrite true
|
||||
#culling none
|
||||
#alphawrite false
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn[4];
|
||||
@@ -659,26 +738,49 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]])
|
||||
return vtf.color;
|
||||
}
|
||||
|
||||
#shader CElementGenShaderNoTexZTestZWriteAWrite : CElementGenShaderNoTexZTestZWrite
|
||||
#alphawrite true
|
||||
|
||||
#shader CElementGenShaderNoTexNoZTestZWrite : CElementGenShaderNoTexZTestZWrite
|
||||
#depthtest none
|
||||
#depthwrite true
|
||||
#alphawrite false
|
||||
|
||||
#shader CElementGenShaderNoTexNoZTestZWriteAWrite : CElementGenShaderNoTexNoZTestZWrite
|
||||
#alphawrite true
|
||||
|
||||
#shader CElementGenShaderNoTexZTestNoZWrite : CElementGenShaderNoTexZTestZWrite
|
||||
#depthtest lequal
|
||||
#depthwrite false
|
||||
#alphawrite false
|
||||
|
||||
#shader CElementGenShaderNoTexZTestNoZWriteAWrite : CElementGenShaderNoTexZTestNoZWrite
|
||||
#alphawrite true
|
||||
|
||||
#shader CElementGenShaderNoTexNoZTestNoZWrite : CElementGenShaderNoTexZTestZWrite
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
#alphawrite false
|
||||
|
||||
#shader CElementGenShaderNoTexNoZTestNoZWriteAWrite : CElementGenShaderNoTexNoZTestNoZWrite
|
||||
#alphawrite true
|
||||
|
||||
#shader CElementGenShaderNoTexAdditiveZTest : CElementGenShaderNoTexZTestZWrite
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#depthtest lequal
|
||||
#depthwrite false
|
||||
#alphawrite false
|
||||
|
||||
#shader CElementGenShaderNoTexAdditiveZTestAWrite : CElementGenShaderNoTexAdditiveZTest
|
||||
#alphawrite true
|
||||
|
||||
#shader CElementGenShaderNoTexAdditiveNoZTest : CElementGenShaderNoTexZTestZWrite
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
#alphawrite false
|
||||
|
||||
#shader CElementGenShaderNoTexAdditiveNoZTestAWrite : CElementGenShaderNoTexAdditiveNoZTest
|
||||
#alphawrite true
|
||||
|
||||
@@ -66,37 +66,38 @@ UBINDING1 uniform FogUniform
|
||||
{
|
||||
int mode;
|
||||
vec4 color;
|
||||
float rangeScale;
|
||||
float start;
|
||||
float A;
|
||||
float B;
|
||||
float C;
|
||||
};
|
||||
|
||||
vec4 MainPostFunc(vec4 colorIn)
|
||||
{
|
||||
float fogZ, temp;
|
||||
float fogZ;
|
||||
float fogF = clamp((A / (B - gl_FragCoord.z)) - C, 0.0, 1.0);
|
||||
switch (mode)
|
||||
{
|
||||
case 2:
|
||||
fogZ = (-vtf.mvPos.z - start) * rangeScale;
|
||||
fogZ = fogF;
|
||||
break;
|
||||
case 4:
|
||||
fogZ = 1.0 - exp2(-8.0 * (-vtf.mvPos.z - start) * rangeScale);
|
||||
fogZ = 1.0 - exp2(-8.0 * fogF);
|
||||
break;
|
||||
case 5:
|
||||
temp = (-vtf.mvPos.z - start) * rangeScale;
|
||||
fogZ = 1.0 - exp2(-8.0 * temp * temp);
|
||||
fogZ = 1.0 - exp2(-8.0 * fogF * fogF);
|
||||
break;
|
||||
case 6:
|
||||
fogZ = exp2(-8.0 * (start + vtf.mvPos.z) * rangeScale);
|
||||
fogZ = exp2(-8.0 * (1.0 - fogF));
|
||||
break;
|
||||
case 7:
|
||||
temp = (start + vtf.mvPos.z) * rangeScale;
|
||||
fogZ = exp2(-8.0 * temp * temp);
|
||||
fogF = 1.0 - fogF;
|
||||
fogZ = exp2(-8.0 * fogF * fogF);
|
||||
break;
|
||||
default:
|
||||
fogZ = 0.0;
|
||||
break;
|
||||
}
|
||||
return vec4(mix(colorIn, color, clamp(fogZ, 0.0, 1.0)).rgb, colorIn.a);
|
||||
return vec4(mix(colorIn, vec4(0.0), clamp(fogZ, 0.0, 1.0)).rgb, colorIn.a);
|
||||
}
|
||||
|
||||
void main()
|
||||
@@ -159,37 +160,38 @@ cbuffer FogUniform : register(b1)
|
||||
{
|
||||
int mode;
|
||||
float4 color;
|
||||
float rangeScale;
|
||||
float start;
|
||||
float A;
|
||||
float B;
|
||||
float C;
|
||||
};
|
||||
|
||||
static float4 MainPostFunc(in VertToFrag vtf, float4 colorIn)
|
||||
{
|
||||
float fogZ, temp;
|
||||
float fogZ;
|
||||
float fogF = saturate((A / (B - vtf.position.z)) - C);
|
||||
switch (mode)
|
||||
{
|
||||
case 2:
|
||||
fogZ = (-vtf.mvPos.z - start) * rangeScale;
|
||||
fogZ = fogF;
|
||||
break;
|
||||
case 4:
|
||||
fogZ = 1.0 - exp2(-8.0 * (-vtf.mvPos.z - start) * rangeScale);
|
||||
fogZ = 1.0 - exp2(-8.0 * fogF);
|
||||
break;
|
||||
case 5:
|
||||
temp = (-vtf.mvPos.z - start) * rangeScale;
|
||||
fogZ = 1.0 - exp2(-8.0 * temp * temp);
|
||||
fogZ = 1.0 - exp2(-8.0 * fogF * fogF);
|
||||
break;
|
||||
case 6:
|
||||
fogZ = exp2(-8.0 * (start + vtf.mvPos.z) * rangeScale);
|
||||
fogZ = exp2(-8.0 * (1.0 - fogF));
|
||||
break;
|
||||
case 7:
|
||||
temp = (start + vtf.mvPos.z) * rangeScale;
|
||||
fogZ = exp2(-8.0 * temp * temp);
|
||||
fogF = 1.0 - fogF;
|
||||
fogZ = exp2(-8.0 * fogF * fogF);
|
||||
break;
|
||||
default:
|
||||
fogZ = 0.0;
|
||||
break;
|
||||
}
|
||||
return float4(lerp(colorIn, color, saturate(fogZ)).rgb, colorIn.a);
|
||||
return float4(lerp(colorIn, float4(0.0,0.0,0.0,0.0), saturate(fogZ)).rgb, colorIn.a);
|
||||
}
|
||||
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
@@ -251,37 +253,38 @@ struct FogUniform
|
||||
{
|
||||
int mode;
|
||||
float4 color;
|
||||
float rangeScale;
|
||||
float start;
|
||||
float A;
|
||||
float B;
|
||||
float C;
|
||||
};
|
||||
|
||||
float4 MainPostFunc(thread VertToFrag& vtf, constant FogUniform& fu, float4 colorIn)
|
||||
{
|
||||
float fogZ, temp;
|
||||
float fogZ;
|
||||
float fogF = saturate((fu.A / (fu.B - vtf.position.z)) - fu.C);
|
||||
switch (fu.mode)
|
||||
{
|
||||
case 2:
|
||||
fogZ = (-vtf.mvPos.z - fu.start) * fu.rangeScale;
|
||||
fogZ = fogF;
|
||||
break;
|
||||
case 4:
|
||||
fogZ = 1.0 - exp2(-8.0 * (-vtf.mvPos.z - fu.start) * fu.rangeScale);
|
||||
fogZ = 1.0 - exp2(-8.0 * fogF);
|
||||
break;
|
||||
case 5:
|
||||
temp = (-vtf.mvPos.z - fu.start) * fu.rangeScale;
|
||||
fogZ = 1.0 - exp2(-8.0 * temp * temp);
|
||||
fogZ = 1.0 - exp2(-8.0 * fogF * fogF);
|
||||
break;
|
||||
case 6:
|
||||
fogZ = exp2(-8.0 * (fu.start + vtf.mvPos.z) * fu.rangeScale);
|
||||
fogZ = exp2(-8.0 * (1.0 - fogF));
|
||||
break;
|
||||
case 7:
|
||||
temp = (fu.start + vtf.mvPos.z) * fu.rangeScale;
|
||||
fogZ = exp2(-8.0 * temp * temp);
|
||||
fogF = 1.0 - fogF;
|
||||
fogZ = exp2(-8.0 * fogF * fogF);
|
||||
break;
|
||||
default:
|
||||
fogZ = 0.0;
|
||||
break;
|
||||
}
|
||||
return float4(mix(colorIn, fu.color, saturate(fogZ)).rgb, colorIn.a);
|
||||
return float4(mix(colorIn, float4(0.0), saturate(fogZ)).rgb, colorIn.a);
|
||||
}
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#primitive tristrips
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
#alphawrite false
|
||||
#culling none
|
||||
|
||||
#vertex glsl
|
||||
@@ -14,11 +15,6 @@ layout(location=0) in vec4 posIn;
|
||||
layout(location=1) in vec4 colorIn;
|
||||
layout(location=2) in vec4 uvIn;
|
||||
|
||||
UBINDING0 uniform LineUniform
|
||||
{
|
||||
vec4 moduColor;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
@@ -28,24 +24,68 @@ struct VertToFrag
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vtf.color = colorIn * moduColor;
|
||||
vtf.color = colorIn;
|
||||
vtf.uv = uvIn.xy;
|
||||
gl_Position = posIn;
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct Fog
|
||||
{
|
||||
int mode;
|
||||
vec4 color;
|
||||
float A;
|
||||
float B;
|
||||
float C;
|
||||
};
|
||||
|
||||
UBINDING0 uniform LineUniform
|
||||
{
|
||||
vec4 moduColor;
|
||||
Fog fog;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
};
|
||||
|
||||
vec4 MainPostFunc(vec4 colorIn)
|
||||
{
|
||||
float fogZ;
|
||||
float fogF = clamp((fog.A / (fog.B - gl_FragCoord.z)) - fog.C, 0.0, 1.0);
|
||||
switch (fog.mode)
|
||||
{
|
||||
case 2:
|
||||
fogZ = fogF;
|
||||
break;
|
||||
case 4:
|
||||
fogZ = 1.0 - exp2(-8.0 * fogF);
|
||||
break;
|
||||
case 5:
|
||||
fogZ = 1.0 - exp2(-8.0 * fogF * fogF);
|
||||
break;
|
||||
case 6:
|
||||
fogZ = exp2(-8.0 * (1.0 - fogF));
|
||||
break;
|
||||
case 7:
|
||||
fogF = 1.0 - fogF;
|
||||
fogZ = exp2(-8.0 * fogF * fogF);
|
||||
break;
|
||||
default:
|
||||
fogZ = 0.0;
|
||||
break;
|
||||
}
|
||||
return vec4(mix(colorIn, vec4(0.0), clamp(fogZ, 0.0, 1.0)).rgb, colorIn.a);
|
||||
}
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D tex;
|
||||
void main()
|
||||
{
|
||||
colorOut = vtf.color * texture(tex, vtf.uv);
|
||||
colorOut = MainPostFunc(vtf.color * moduColor * texture(tex, vtf.uv));
|
||||
}
|
||||
|
||||
#vertex hlsl
|
||||
@@ -139,20 +179,35 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
return vtf.color * tex0.sample(samp, vtf.uv);
|
||||
}
|
||||
|
||||
#shader CLineRendererShaderTexAlphaAWrite : CLineRendererShaderTexAlpha
|
||||
#alphawrite true
|
||||
|
||||
#shader CLineRendererShaderTexAdditive : CLineRendererShaderTexAlpha
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#depthtest none
|
||||
#alphawrite false
|
||||
|
||||
#shader CLineRendererShaderTexAdditiveAWrite : CLineRendererShaderTexAdditive
|
||||
#alphawrite true
|
||||
|
||||
#shader CLineRendererShaderTexAlphaZ : CLineRendererShaderTexAlpha
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#depthtest lequal
|
||||
#alphawrite false
|
||||
|
||||
#shader CLineRendererShaderTexAlphaZAWrite : CLineRendererShaderTexAlphaZ
|
||||
#alphawrite true
|
||||
|
||||
#shader CLineRendererShaderTexAdditiveZ : CLineRendererShaderTexAlpha
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#depthtest lequal
|
||||
#alphawrite false
|
||||
|
||||
#shader CLineRendererShaderTexAdditiveZAWrite : CLineRendererShaderTexAdditiveZ
|
||||
#alphawrite true
|
||||
|
||||
#shader CLineRendererShaderNoTexAlpha
|
||||
#attribute position4
|
||||
@@ -162,17 +217,13 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
#primitive tristrips
|
||||
#depthtest none
|
||||
#depthwrite false
|
||||
#alphawrite false
|
||||
#culling none
|
||||
|
||||
#vertex glsl
|
||||
layout(location=0) in vec4 posIn;
|
||||
layout(location=1) in vec4 colorIn;
|
||||
|
||||
UBINDING0 uniform LineUniform
|
||||
{
|
||||
vec4 moduColor;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
@@ -181,21 +232,65 @@ struct VertToFrag
|
||||
SBINDING(0) out VertToFrag vtf;
|
||||
void main()
|
||||
{
|
||||
vtf.color = colorIn * moduColor;
|
||||
vtf.color = colorIn;
|
||||
gl_Position = posIn;
|
||||
}
|
||||
|
||||
#fragment glsl
|
||||
struct Fog
|
||||
{
|
||||
int mode;
|
||||
vec4 color;
|
||||
float A;
|
||||
float B;
|
||||
float C;
|
||||
};
|
||||
|
||||
UBINDING0 uniform LineUniform
|
||||
{
|
||||
vec4 moduColor;
|
||||
Fog fog;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
vec4 MainPostFunc(vec4 colorIn)
|
||||
{
|
||||
float fogZ;
|
||||
float fogF = clamp((fog.A / (fog.B - gl_FragCoord.z)) - fog.C, 0.0, 1.0);
|
||||
switch (fog.mode)
|
||||
{
|
||||
case 2:
|
||||
fogZ = fogF;
|
||||
break;
|
||||
case 4:
|
||||
fogZ = 1.0 - exp2(-8.0 * fogF);
|
||||
break;
|
||||
case 5:
|
||||
fogZ = 1.0 - exp2(-8.0 * fogF * fogF);
|
||||
break;
|
||||
case 6:
|
||||
fogZ = exp2(-8.0 * (1.0 - fogF));
|
||||
break;
|
||||
case 7:
|
||||
fogF = 1.0 - fogF;
|
||||
fogZ = exp2(-8.0 * fogF * fogF);
|
||||
break;
|
||||
default:
|
||||
fogZ = 0.0;
|
||||
break;
|
||||
}
|
||||
return vec4(mix(colorIn, vec4(0.0), clamp(fogZ, 0.0, 1.0)).rgb, colorIn.a);
|
||||
}
|
||||
|
||||
SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
void main()
|
||||
{
|
||||
colorOut = vtf.color;
|
||||
colorOut = MainPostFunc(vtf.color * moduColor);
|
||||
}
|
||||
|
||||
#vertex hlsl
|
||||
@@ -205,11 +300,6 @@ struct VertData
|
||||
float4 colorIn : COLOR;
|
||||
};
|
||||
|
||||
cbuffer LineUniform : register(b0)
|
||||
{
|
||||
float4 moduColor;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
@@ -219,21 +309,65 @@ struct VertToFrag
|
||||
VertToFrag main(in VertData v)
|
||||
{
|
||||
VertToFrag vtf;
|
||||
vtf.color = v.colorIn * moduColor;
|
||||
vtf.color = v.colorIn;
|
||||
vtf.position = v.posIn;
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment hlsl
|
||||
struct Fog
|
||||
{
|
||||
int mode;
|
||||
float4 color;
|
||||
float A;
|
||||
float B;
|
||||
float C;
|
||||
};
|
||||
|
||||
cbuffer LineUniform : register(b0)
|
||||
{
|
||||
float4 moduColor;
|
||||
Fog fog;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
static float4 MainPostFunc(float4 colorIn, float4 FragCoord)
|
||||
{
|
||||
float fogZ;
|
||||
float fogF = saturate((fog.A / (fog.B - FragCoord.z)) - fog.C);
|
||||
switch (fog.mode)
|
||||
{
|
||||
case 2:
|
||||
fogZ = fogF;
|
||||
break;
|
||||
case 4:
|
||||
fogZ = 1.0 - exp2(-8.0 * fogF);
|
||||
break;
|
||||
case 5:
|
||||
fogZ = 1.0 - exp2(-8.0 * fogF * fogF);
|
||||
break;
|
||||
case 6:
|
||||
fogZ = exp2(-8.0 * (1.0 - fogF));
|
||||
break;
|
||||
case 7:
|
||||
fogF = 1.0 - fogF;
|
||||
fogZ = exp2(-8.0 * fogF * fogF);
|
||||
break;
|
||||
default:
|
||||
fogZ = 0.0;
|
||||
break;
|
||||
}
|
||||
return float4(lerp(colorIn, float4(0.0,0.0,0.0,0.0), saturate(fogZ)).rgb, colorIn.a);
|
||||
}
|
||||
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
return vtf.color;
|
||||
return MainPostFunc(vtf.color * moduColor, vtf.position);
|
||||
}
|
||||
|
||||
#vertex metal
|
||||
@@ -243,11 +377,6 @@ struct VertData
|
||||
float4 colorIn;
|
||||
};
|
||||
|
||||
struct LineUniform
|
||||
{
|
||||
float4 moduColor;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
@@ -255,44 +384,107 @@ struct VertToFrag
|
||||
};
|
||||
|
||||
vertex VertToFrag vmain(constant VertData* va [[ buffer(0) ]],
|
||||
uint vertId [[ vertex_id ]],
|
||||
constant LineUniform& line [[ buffer(2) ]])
|
||||
uint vertId [[ vertex_id ]])
|
||||
{
|
||||
VertToFrag vtf;
|
||||
constant VertData& v = va[vertId];
|
||||
vtf.color = v.colorIn * line.moduColor;
|
||||
vtf.color = v.colorIn;
|
||||
vtf.position = v.posIn;
|
||||
return vtf;
|
||||
}
|
||||
|
||||
#fragment metal
|
||||
struct Fog
|
||||
{
|
||||
int mode;
|
||||
float4 color;
|
||||
float A;
|
||||
float B;
|
||||
float C;
|
||||
};
|
||||
|
||||
struct LineUniform
|
||||
{
|
||||
float4 moduColor;
|
||||
Fog fog;
|
||||
};
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
float4 position [[ position ]];
|
||||
float4 color;
|
||||
};
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]])
|
||||
static float4 MainPostFunc(float4 colorIn, constant LineUniform& line, float FragCoord)
|
||||
{
|
||||
return vtf.color;
|
||||
float fogZ;
|
||||
float fogF = saturate((line.fog.A / (line.fog.B - FragCoord.z)) - line.fog.C);
|
||||
switch (line.fog.mode)
|
||||
{
|
||||
case 2:
|
||||
fogZ = fogF;
|
||||
break;
|
||||
case 4:
|
||||
fogZ = 1.0 - exp2(-8.0 * fogF);
|
||||
break;
|
||||
case 5:
|
||||
fogZ = 1.0 - exp2(-8.0 * fogF * fogF);
|
||||
break;
|
||||
case 6:
|
||||
fogZ = exp2(-8.0 * (1.0 - fogF));
|
||||
break;
|
||||
case 7:
|
||||
fogF = 1.0 - fogF;
|
||||
fogZ = exp2(-8.0 * fogF * fogF);
|
||||
break;
|
||||
default:
|
||||
fogZ = 0.0;
|
||||
break;
|
||||
}
|
||||
return float4(mix(colorIn, float4(0.0), saturate(fogZ)).rgb, colorIn.a);
|
||||
}
|
||||
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
constant LineUniform& line [[ buffer(2) ]])
|
||||
{
|
||||
return MainPostFunc(vtf.color * line.moduColor, line, vtf.position);
|
||||
}
|
||||
|
||||
#shader CLineRendererShaderNoTexAlphaAWrite : CLineRendererShaderNoTexAlpha
|
||||
#alphawrite true
|
||||
|
||||
#shader CLineRendererShaderNoTexAdditive : CLineRendererShaderNoTexAlpha
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#depthtest none
|
||||
#alphawrite false
|
||||
|
||||
#shader CLineRendererShaderNoTexAdditiveAWrite : CLineRendererShaderNoTexAdditive
|
||||
#alphawrite true
|
||||
|
||||
#shader CLineRendererShaderNoTexAlphaZ : CLineRendererShaderNoTexAlpha
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#depthtest lequal
|
||||
#alphawrite false
|
||||
|
||||
#shader CLineRendererShaderNoTexAlphaZAWrite : CLineRendererShaderNoTexAlphaZ
|
||||
#alphawrite true
|
||||
|
||||
#shader CLineRendererShaderNoTexAdditiveZ : CLineRendererShaderNoTexAlpha
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#depthtest lequal
|
||||
#alphawrite false
|
||||
|
||||
#shader CLineRendererShaderNoTexAdditiveZAWrite : CLineRendererShaderNoTexAdditiveZ
|
||||
#alphawrite true
|
||||
|
||||
#shader CLineRendererShaderNoTexAlphaZGEqual : CLineRendererShaderNoTexAlpha
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#depthtest gequal
|
||||
#alphawrite false
|
||||
|
||||
#shader CLineRendererShaderNoTexAlphaZGEqualAWrite : CLineRendererShaderNoTexAlphaZGEqual
|
||||
#alphawrite true
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#primitive tristrips
|
||||
#depthtest lequal
|
||||
#depthwrite true
|
||||
#alphawrite false
|
||||
#culling none
|
||||
|
||||
#vertex glsl
|
||||
@@ -136,27 +137,42 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
return vtf.color * tex.sample(samp, vtf.uv);
|
||||
}
|
||||
|
||||
#shader CParticleSwooshShaderTexZWriteAWrite : CParticleSwooshShaderTexZWrite
|
||||
#alphawrite true
|
||||
|
||||
#shader CParticleSwooshShaderTexNoZWrite : CParticleSwooshShaderTexZWrite
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#depthwrite false
|
||||
#alphawrite false
|
||||
|
||||
#shader CParticleSwooshShaderTexNoZWriteAWrite : CParticleSwooshShaderTexNoZWrite
|
||||
#alphawrite true
|
||||
|
||||
#shader CParticleSwooshShaderTexAdditiveZWrite : CParticleSwooshShaderTexZWrite
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#depthwrite true
|
||||
#alphawrite false
|
||||
|
||||
#shader CParticleSwooshShaderTexAdditiveZWriteAWrite : CParticleSwooshShaderTexAdditiveZWrite
|
||||
#alphawrite true
|
||||
|
||||
#shader CParticleSwooshShaderTexAdditiveNoZWrite : CParticleSwooshShaderTexZWrite
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#depthwrite false
|
||||
#alphawrite false
|
||||
|
||||
#shader CParticleSwooshShaderTexAdditiveNoZWriteAWrite : CParticleSwooshShaderTexAdditiveNoZWrite
|
||||
#alphawrite true
|
||||
|
||||
#shader CParticleSwooshShaderNoTexZWrite : CParticleSwooshShaderTexZWrite
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#depthtest lequal
|
||||
#depthwrite true
|
||||
#alphawrite false
|
||||
|
||||
#fragment glsl
|
||||
struct VertToFrag
|
||||
@@ -198,19 +214,32 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]])
|
||||
return vtf.color;
|
||||
}
|
||||
|
||||
#shader CParticleSwooshShaderNoTexZWriteAWrite : CParticleSwooshShaderNoTexZWrite
|
||||
#alphawrite true
|
||||
|
||||
#shader CParticleSwooshShaderNoTexNoZWrite : CParticleSwooshShaderNoTexZWrite
|
||||
#srcfac srcalpha
|
||||
#dstfac invsrcalpha
|
||||
#depthwrite false
|
||||
#alphawrite false
|
||||
|
||||
#shader CParticleSwooshShaderNoTexNoZWriteAWrite : CParticleSwooshShaderNoTexNoZWrite
|
||||
#alphawrite true
|
||||
|
||||
#shader CParticleSwooshShaderNoTexAdditiveZWrite : CParticleSwooshShaderNoTexZWrite
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#depthwrite true
|
||||
#alphawrite false
|
||||
|
||||
#shader CParticleSwooshShaderNoTexAdditiveZWriteAWrite : CParticleSwooshShaderNoTexAdditiveZWrite
|
||||
#alphawrite true
|
||||
|
||||
#shader CParticleSwooshShaderNoTexAdditiveNoZWrite : CParticleSwooshShaderNoTexZWrite
|
||||
#srcfac srcalpha
|
||||
#dstfac one
|
||||
#depthwrite false
|
||||
#alphawrite false
|
||||
|
||||
#shader CParticleSwooshShaderNoTexAdditiveNoZWriteAWrite : CParticleSwooshShaderNoTexAdditiveNoZWrite
|
||||
#alphawrite true
|
||||
|
||||
@@ -74,12 +74,12 @@ SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D sceneTex;
|
||||
TBINDING1 uniform sampler2D noiseTex;
|
||||
const vec4 kRGBToYPrime = vec4(0.299, 0.587, 0.114, 0.0);
|
||||
const vec4 kRGBToYPrime = vec4(0.257, 0.504, 0.098, 0.0);
|
||||
void main()
|
||||
{
|
||||
vec4 noiseTexel = texelFetch(noiseTex, Lookup8BPP(vtf.noiseUv, vtf.randOff), 0);
|
||||
vec2 indCoord = (vtf.indMtx * vec3(noiseTexel.r - 0.5, noiseTexel.a - 0.5, 1.0)).xy;
|
||||
float indScene = dot(texture(sceneTex, vtf.sceneUv + indCoord), kRGBToYPrime);
|
||||
float indScene = dot(texture(sceneTex, vtf.sceneUv + indCoord), kRGBToYPrime) + 16.0 / 255.0;
|
||||
colorOut = vtf.colorReg0 * indScene + vtf.colorReg2 - vtf.colorReg1 * noiseTexel.r;
|
||||
colorOut.a = vtf.colorReg1.a + vtf.colorReg1.a * noiseTexel.r + vtf.colorReg2.a;
|
||||
}
|
||||
@@ -154,12 +154,12 @@ static int3 Lookup8BPP(float2 uv, float randOff)
|
||||
return int3(addr & 0x3ff, addr >> 10, 0);
|
||||
}
|
||||
|
||||
static const float4 kRGBToYPrime = {0.299, 0.587, 0.114, 0.0};
|
||||
static const float4 kRGBToYPrime = {0.257, 0.504, 0.098, 0.0};
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
float4 noiseTexel = noiseTex.Load(Lookup8BPP(vtf.noiseUv, vtf.randOff));
|
||||
float2 indCoord = mul(vtf.indMtx, float3(noiseTexel.r - 0.5, noiseTexel.a - 0.5, 1.0)).xy;
|
||||
float indScene = dot(sceneTex.Sample(samp, vtf.sceneUv + indCoord), kRGBToYPrime);
|
||||
float indScene = dot(sceneTex.Sample(samp, vtf.sceneUv + indCoord), 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;
|
||||
@@ -238,7 +238,7 @@ static uint2 Lookup8BPP(float2 uv, float randOff)
|
||||
return uint2(addr & 0x3ff, addr >> 10);
|
||||
}
|
||||
|
||||
constant float4 kRGBToYPrime = {0.299, 0.587, 0.114, 0.0};
|
||||
constant float4 kRGBToYPrime = {0.257, 0.504, 0.098, 0.0};
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler samp [[ sampler(3) ]],
|
||||
texture2d<float> sceneTex [[ texture(0) ]],
|
||||
@@ -246,7 +246,7 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
{
|
||||
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);
|
||||
float indScene = dot(sceneTex.sample(samp, vtf.sceneUv + indCoord), 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;
|
||||
}
|
||||
|
||||
@@ -41,11 +41,11 @@ SBINDING(0) in VertToFrag vtf;
|
||||
layout(location=0) out vec4 colorOut;
|
||||
TBINDING0 uniform sampler2D sceneTex;
|
||||
TBINDING1 uniform sampler2D paletteTex;
|
||||
const vec4 kRGBToYPrime = vec4(0.299, 0.587, 0.114, 0.0);
|
||||
const vec4 kRGBToYPrime = vec4(0.257, 0.504, 0.098, 0.0);
|
||||
void main()
|
||||
{
|
||||
float sceneSample = dot(texture(sceneTex, vtf.sceneUv), kRGBToYPrime);
|
||||
vec4 colorSample = texture(paletteTex, vec2(sceneSample / 17.0, 0.5));
|
||||
float sceneSample = dot(texture(sceneTex, vtf.sceneUv), kRGBToYPrime) + 16.0 / 255.0;
|
||||
vec4 colorSample = texture(paletteTex, vec2(sceneSample / 16.0, 0.5));
|
||||
colorOut = vec4(colorSample.rgb, 0.0);
|
||||
}
|
||||
|
||||
@@ -88,11 +88,11 @@ struct VertToFrag
|
||||
float2 sceneUv : UV;
|
||||
};
|
||||
|
||||
static const float4 kRGBToYPrime = float4(0.299, 0.587, 0.114, 0.0);
|
||||
static const float4 kRGBToYPrime = float4(0.257, 0.504, 0.098, 0.0);
|
||||
float4 main(in VertToFrag vtf) : SV_Target0
|
||||
{
|
||||
float sceneSample = dot(sceneTex.Sample(samp, vtf.sceneUv), kRGBToYPrime);
|
||||
float4 colorSample = paletteTex.Sample(samp, float2(sceneSample / 17.0, 0.5));
|
||||
float sceneSample = dot(sceneTex.Sample(samp, vtf.sceneUv), kRGBToYPrime) + 16.0 / 255.0;
|
||||
float4 colorSample = paletteTex.Sample(samp, float2(sceneSample / 16.0, 0.5));
|
||||
return float4(colorSample.rgb, 0.0);
|
||||
}
|
||||
|
||||
@@ -132,13 +132,13 @@ struct VertToFrag
|
||||
float2 sceneUv;
|
||||
};
|
||||
|
||||
constant float4 kRGBToYPrime = float4(0.299, 0.587, 0.114, 0.0);
|
||||
constant float4 kRGBToYPrime = float4(0.257, 0.504, 0.098, 0.0);
|
||||
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
|
||||
sampler samp [[ sampler(0) ]],
|
||||
texture2d<float> sceneTex [[ texture(0) ]],
|
||||
texture2d<float> paletteTex [[ texture(1) ]])
|
||||
{
|
||||
float sceneSample = dot(sceneTex.sample(samp, vtf.sceneUv), kRGBToYPrime);
|
||||
float4 colorSample = paletteTex.sample(samp, float2(sceneSample / 17.0, 0.5));
|
||||
float sceneSample = dot(sceneTex.sample(samp, vtf.sceneUv), kRGBToYPrime) + 16.0 / 255.0;
|
||||
float4 colorSample = paletteTex.sample(samp, float2(sceneSample / 16.0, 0.5));
|
||||
return float4(colorSample.rgb, 0.0);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,50 @@
|
||||
#include "shader_CFluidPlaneShader.hpp"
|
||||
|
||||
#define FOG_STRUCT_GLSL \
|
||||
"struct Fog\n" \
|
||||
"{\n" \
|
||||
" int mode;\n" \
|
||||
" vec4 color;\n" \
|
||||
" float A;\n" \
|
||||
" float B;\n" \
|
||||
" float C;\n" \
|
||||
" float indScale;\n" \
|
||||
"};\n"
|
||||
|
||||
#define FOG_ALGORITHM_GLSL \
|
||||
"vec4 MainPostFunc(vec4 colorIn)\n" \
|
||||
"{\n" \
|
||||
" float fogZ;\n" \
|
||||
" float fogF = clamp((fog.A / (fog.B - gl_FragCoord.z)) - fog.C, 0.0, 1.0);\n" \
|
||||
" switch (fog.mode)\n" \
|
||||
" {\n" \
|
||||
" case 2:\n" \
|
||||
" fogZ = fogF;\n" \
|
||||
" break;\n" \
|
||||
" case 4:\n" \
|
||||
" fogZ = 1.0 - exp2(-8.0 * fogF);\n" \
|
||||
" break;\n" \
|
||||
" case 5:\n" \
|
||||
" fogZ = 1.0 - exp2(-8.0 * fogF * fogF);\n" \
|
||||
" break;\n" \
|
||||
" case 6:\n" \
|
||||
" fogZ = exp2(-8.0 * (1.0 - fogF));\n" \
|
||||
" break;\n" \
|
||||
" case 7:\n" \
|
||||
" fogF = 1.0 - fogF;\n" \
|
||||
" fogZ = exp2(-8.0 * fogF * fogF);\n" \
|
||||
" break;\n" \
|
||||
" default:\n" \
|
||||
" fogZ = 0.0;\n" \
|
||||
" break;\n" \
|
||||
" }\n" \
|
||||
"#if %d\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" \
|
||||
"}\n"
|
||||
|
||||
static const char* VS =
|
||||
"layout(location=0) in vec4 posIn;\n"
|
||||
"layout(location=1) in vec4 normalIn;\n"
|
||||
@@ -175,14 +220,7 @@ static const char* FS =
|
||||
" vec4 linAtt;\n"
|
||||
" vec4 angAtt;\n"
|
||||
"};\n"
|
||||
"struct Fog\n" // Reappropriated for indirect texture scaling
|
||||
"{\n"
|
||||
" int mode;\n"
|
||||
" vec4 color;\n"
|
||||
" float rangeScale;\n"
|
||||
" float start;\n"
|
||||
" float indScale;\n"
|
||||
"};\n"
|
||||
FOG_STRUCT_GLSL
|
||||
"\n"
|
||||
"UBINDING2 uniform LightingUniform\n"
|
||||
"{\n"
|
||||
@@ -229,38 +267,7 @@ static const char* FS =
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) in VertToFrag vtf;\n"
|
||||
"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"
|
||||
"#if %d\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"
|
||||
"}\n"
|
||||
FOG_ALGORITHM_GLSL
|
||||
"\n"
|
||||
"layout(location=0) out vec4 colorOut;\n"
|
||||
"%s" // Textures here
|
||||
@@ -281,14 +288,7 @@ static const char* FSDoor =
|
||||
" vec4 linAtt;\n"
|
||||
" vec4 angAtt;\n"
|
||||
"};\n"
|
||||
"struct Fog\n" // Reappropriated for indirect texture scaling
|
||||
"{\n"
|
||||
" int mode;\n"
|
||||
" vec4 color;\n"
|
||||
" float rangeScale;\n"
|
||||
" float start;\n"
|
||||
" float indScale;\n"
|
||||
"};\n"
|
||||
FOG_STRUCT_GLSL
|
||||
"\n"
|
||||
"UBINDING2 uniform LightingUniform\n"
|
||||
"{\n"
|
||||
@@ -311,6 +311,7 @@ static const char* FSDoor =
|
||||
" vec4 color;\n"
|
||||
" vec2 uvs[7];\n"
|
||||
"};\n"
|
||||
FOG_ALGORITHM_GLSL
|
||||
"\n"
|
||||
"SBINDING(0) in VertToFrag vtf;\n"
|
||||
"layout(location=0) out vec4 colorOut;\n"
|
||||
@@ -318,6 +319,7 @@ static const char* FSDoor =
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
"%s" // Combiner expression here
|
||||
" colorOut = MainPostFunc(colorOut);\n"
|
||||
"}\n";
|
||||
|
||||
static std::string _BuildFS(const SFluidPlaneShaderInfo& info) {
|
||||
@@ -766,7 +768,7 @@ static std::string _BuildFS(const SFluidPlaneDoorShaderInfo& info) {
|
||||
combiner += " colorOut.a = kColor0.a;\n";
|
||||
|
||||
char* finalFSs;
|
||||
asprintf(&finalFSs, FSDoor, textures.c_str(), combiner.c_str());
|
||||
asprintf(&finalFSs, FSDoor, 0, textures.c_str(), combiner.c_str());
|
||||
std::string ret(finalFSs);
|
||||
free(finalFSs);
|
||||
return ret;
|
||||
|
||||
@@ -1,5 +1,50 @@
|
||||
#include "shader_CFluidPlaneShader.hpp"
|
||||
|
||||
#define FOG_STRUCT_HLSL \
|
||||
"struct Fog\n" \
|
||||
"{\n" \
|
||||
" int mode;\n" \
|
||||
" float4 color;\n" \
|
||||
" float A;\n" \
|
||||
" float B;\n" \
|
||||
" float C;\n" \
|
||||
" float indScale;\n" \
|
||||
"};\n"
|
||||
|
||||
#define FOG_ALGORITHM_HLSL \
|
||||
"static float4 MainPostFunc(in VertToFrag vtf, float4 colorIn)\n" \
|
||||
"{\n" \
|
||||
" float fogZ;\n" \
|
||||
" float fogF = saturate((fog.A / (fog.B - vtf.pos.z)) - fog.C);\n" \
|
||||
" switch (fog.mode)\n" \
|
||||
" {\n" \
|
||||
" case 2:\n" \
|
||||
" fogZ = fogF;\n" \
|
||||
" break;\n" \
|
||||
" case 4:\n" \
|
||||
" fogZ = 1.0 - exp2(-8.0 * fogF);\n" \
|
||||
" break;\n" \
|
||||
" case 5:\n" \
|
||||
" fogZ = 1.0 - exp2(-8.0 * fogF * fogF);\n" \
|
||||
" break;\n" \
|
||||
" case 6:\n" \
|
||||
" fogZ = exp2(-8.0 * (1.0 - fogF));\n" \
|
||||
" break;\n" \
|
||||
" case 7:\n" \
|
||||
" fogF = 1.0 - fogF;\n" \
|
||||
" fogZ = exp2(-8.0 * fogF * fogF);\n" \
|
||||
" break;\n" \
|
||||
" default:\n" \
|
||||
" fogZ = 0.0;\n" \
|
||||
" break;\n" \
|
||||
" }\n" \
|
||||
"#if %d\n" \
|
||||
" return float4(lerp(colorIn, float4(0.0,0.0,0.0,0.0), saturate(fogZ)).rgb, colorIn.a);\n" \
|
||||
"#else\n" \
|
||||
" return float4(lerp(colorIn, fog.color, saturate(fogZ)).rgb, colorIn.a);\n" \
|
||||
"#endif\n" \
|
||||
"}\n"
|
||||
|
||||
static const char* VS =
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
@@ -211,14 +256,7 @@ static const char* FS =
|
||||
" float4 linAtt;\n"
|
||||
" float4 angAtt;\n"
|
||||
"};\n"
|
||||
"struct Fog\n" // Reappropriated for indirect texture scaling
|
||||
"{\n"
|
||||
" int mode;\n"
|
||||
" float4 color;\n"
|
||||
" float rangeScale;\n"
|
||||
" float start;\n"
|
||||
" float indScale;\n"
|
||||
"};\n"
|
||||
FOG_STRUCT_HLSL
|
||||
"\n"
|
||||
"cbuffer LightingUniform : register(b2)\n"
|
||||
"{\n"
|
||||
@@ -264,38 +302,7 @@ static const char* FS =
|
||||
" float2 uvs[7] : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"static float4 MainPostFunc(in VertToFrag vtf, float4 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"
|
||||
"#if %d\n"
|
||||
" return float4(lerp(colorIn, float4(0.0, 0.0, 0.0, 0.0), saturate(fogZ)).rgb, colorIn.a);\n"
|
||||
"#else\n"
|
||||
" return float4(lerp(colorIn, fog.color, saturate(fogZ)).rgb, colorIn.a);\n"
|
||||
"#endif\n"
|
||||
"}\n"
|
||||
FOG_ALGORITHM_HLSL
|
||||
"\n"
|
||||
"SamplerState samp : register(s0);\n"
|
||||
"%s" // Textures here
|
||||
@@ -316,14 +323,7 @@ static const char* FSDoor =
|
||||
" float4 linAtt;\n"
|
||||
" float4 angAtt;\n"
|
||||
"};\n"
|
||||
"struct Fog\n" // Reappropriated for indirect texture scaling
|
||||
"{\n"
|
||||
" int mode;\n"
|
||||
" float4 color;\n"
|
||||
" float rangeScale;\n"
|
||||
" float start;\n"
|
||||
" float indScale;\n"
|
||||
"};\n"
|
||||
FOG_STRUCT_HLSL
|
||||
"\n"
|
||||
"cbuffer LightingUniform : register(b2)\n"
|
||||
"{\n"
|
||||
@@ -346,6 +346,7 @@ static const char* FSDoor =
|
||||
" float4 color : COLOR;\n"
|
||||
" float2 uvs[7] : UV;\n"
|
||||
"};\n"
|
||||
FOG_ALGORITHM_HLSL
|
||||
"\n"
|
||||
"SamplerState samp : register(s0);\n"
|
||||
"%s" // Textures here
|
||||
@@ -353,7 +354,7 @@ static const char* FSDoor =
|
||||
"{\n"
|
||||
" float4 colorOut;\n"
|
||||
"%s" // Combiner expression here
|
||||
" return colorOut;\n"
|
||||
" return MainPostFunc(vtf, colorOut);\n"
|
||||
"}\n";
|
||||
|
||||
static std::string _BuildFS(const SFluidPlaneShaderInfo& info) {
|
||||
@@ -761,7 +762,7 @@ static std::string _BuildFS(const SFluidPlaneDoorShaderInfo& info) {
|
||||
combiner += " colorOut.a = kColor0.a;\n";
|
||||
|
||||
char* finalFSs;
|
||||
asprintf(&finalFSs, FSDoor, textures.c_str(), combiner.c_str());
|
||||
asprintf(&finalFSs, FSDoor, 0, textures.c_str(), combiner.c_str());
|
||||
std::string ret(finalFSs);
|
||||
free(finalFSs);
|
||||
return ret;
|
||||
|
||||
@@ -1,5 +1,50 @@
|
||||
#include "shader_CFluidPlaneShader.hpp"
|
||||
|
||||
#define FOG_STRUCT_METAL \
|
||||
"struct Fog\n" \
|
||||
"{\n" \
|
||||
" int mode;\n" \
|
||||
" float4 color;\n" \
|
||||
" float A;\n" \
|
||||
" float B;\n" \
|
||||
" float C;\n" \
|
||||
" float indScale;\n" \
|
||||
"};\n"
|
||||
|
||||
#define FOG_ALGORITHM_METAL \
|
||||
"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" \
|
||||
" switch (lu.fog.mode)\n" \
|
||||
" {\n" \
|
||||
" case 2:\n" \
|
||||
" fogZ = fogF;\n" \
|
||||
" break;\n" \
|
||||
" case 4:\n" \
|
||||
" fogZ = 1.0 - exp2(-8.0 * fogF);\n" \
|
||||
" break;\n" \
|
||||
" case 5:\n" \
|
||||
" fogZ = 1.0 - exp2(-8.0 * fogF * fogF);\n" \
|
||||
" break;\n" \
|
||||
" case 6:\n" \
|
||||
" fogZ = exp2(-8.0 * (1.0 - fogF));\n" \
|
||||
" break;\n" \
|
||||
" case 7:\n" \
|
||||
" fogF = 1.0 - fogF;\n" \
|
||||
" fogZ = exp2(-8.0 * fogF * fogF);\n" \
|
||||
" break;\n" \
|
||||
" default:\n" \
|
||||
" fogZ = 0.0;\n" \
|
||||
" break;\n" \
|
||||
" }\n" \
|
||||
"#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" \
|
||||
"#endif\n" \
|
||||
"}\n"
|
||||
|
||||
static const char* VS =
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
@@ -195,14 +240,7 @@ static const char* FS =
|
||||
" float4 linAtt;\n"
|
||||
" float4 angAtt;\n"
|
||||
"};\n"
|
||||
"struct Fog\n" // Reappropriated for indirect texture scaling
|
||||
"{\n"
|
||||
" int mode;\n"
|
||||
" float4 color;\n"
|
||||
" float rangeScale;\n"
|
||||
" float start;\n"
|
||||
" float indScale;\n"
|
||||
"};\n"
|
||||
FOG_STRUCT_METAL
|
||||
"\n"
|
||||
"struct LightingUniform\n"
|
||||
"{\n"
|
||||
@@ -254,38 +292,7 @@ static const char* FS =
|
||||
" float2 uv6;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"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"
|
||||
"#if %d\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"
|
||||
FOG_ALGORITHM_METAL
|
||||
"\n"
|
||||
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
|
||||
" sampler samp [[ sampler(0) ]],\n"
|
||||
@@ -306,14 +313,7 @@ static const char* FSDoor =
|
||||
" float4 linAtt;\n"
|
||||
" float4 angAtt;\n"
|
||||
"};\n"
|
||||
"struct Fog\n" // Reappropriated for indirect texture scaling
|
||||
"{\n"
|
||||
" int mode;\n"
|
||||
" float4 color;\n"
|
||||
" float rangeScale;\n"
|
||||
" float start;\n"
|
||||
" float indScale;\n"
|
||||
"};\n"
|
||||
FOG_STRUCT_METAL
|
||||
"\n"
|
||||
"struct LightingUniform\n"
|
||||
"{\n"
|
||||
@@ -343,6 +343,7 @@ static const char* FSDoor =
|
||||
" float2 uv5;\n"
|
||||
" float2 uv6;\n"
|
||||
"};\n"
|
||||
FOG_ALGORITHM_METAL
|
||||
"\n"
|
||||
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
|
||||
" sampler samp [[ sampler(0) ]],\n"
|
||||
@@ -350,7 +351,7 @@ static const char* FSDoor =
|
||||
"{\n"
|
||||
" float4 colorOut;\n"
|
||||
"%s" // Combiner expression here
|
||||
" return colorOut;\n"
|
||||
" return MainPostFunc(vtf, lu, colorOut);\n"
|
||||
"}\n";
|
||||
|
||||
static std::string _BuildFS(const SFluidPlaneShaderInfo& info) {
|
||||
@@ -748,7 +749,7 @@ static std::string _BuildFS(const SFluidPlaneDoorShaderInfo& info) {
|
||||
combiner += " colorOut.a = lu.kColor0.a;\n";
|
||||
|
||||
char* finalFSs;
|
||||
asprintf(&finalFSs, FSDoor, textures.c_str(), combiner.c_str());
|
||||
asprintf(&finalFSs, FSDoor, 0, textures.c_str(), combiner.c_str());
|
||||
std::string ret(finalFSs);
|
||||
free(finalFSs);
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user