D3D fixes

This commit is contained in:
Jack Andersen 2019-03-03 13:04:18 -10:00
parent 8b9f073635
commit 54f0724de5
19 changed files with 596 additions and 159 deletions

View File

@ -82,7 +82,7 @@ if(MSVC)
-D_SCL_SECURE_NO_DEPRECATE=1 -D_CRT_NONSTDC_NO_WARNINGS=1
/IGNORE:4221 /wd4018 /wd4800 /wd4005 /wd4311 /wd4068
/wd4267 /wd4244 /wd4200 /wd4305 /wd4067 /wd4146 /wd4309 /wd4805
-D_ENABLE_EXTENDED_ALIGNED_STORAGE=1 ${VS_DEFINES})
-D_ENABLE_EXTENDED_ALIGNED_STORAGE=1 -D_ITERATOR_DEBUG_LEVEL=0 ${VS_DEFINES})
if(WINDOWS_STORE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /AI\"$ENV{PROGRAMFILES\(X86\)}/Microsoft Visual Studio/2017/Community/Common7/IDE/VC/vcpackages\" /AI\"$ENV{PROGRAMFILES\(X86\)}/Windows Kits/10/UnionMetadata\"")

View File

@ -190,11 +190,11 @@ public:
};
struct CFogState {
ERglFogMode m_mode;
zeus::CColor m_color;
float m_A = 0.f;
float m_B = 0.5f;
float m_C = 0.f;
ERglFogMode m_mode;
};
static CProjectionState g_Proj;

View File

@ -205,6 +205,7 @@ void CFluidPlaneShader::prepareDraw(const RenderSetupInfo& info) {
for (int i = 0; i < 3; ++i)
uni.m_lighting.colorRegs[i] = info.kColors[i];
uni.m_lighting.mulColor = info.kColors[3];
uni.m_lighting.fog = CGraphics::g_Fog;
uni.m_pad2.x() = info.indScale;
m_uniBuf->unmap();
}

View File

@ -10,11 +10,11 @@ extern const hecl::Backend::Function ExtensionPostFuncsGLSL[];
#define FOG_STRUCT_GLSL \
"struct Fog\n" \
"{\n" \
" int mode;\n" \
" vec4 color;\n" \
" float A;\n" \
" float B;\n" \
" float C;\n" \
" int mode;\n" \
"};\n"
#define FOG_ALGORITHM_GLSL \

View File

@ -9,32 +9,33 @@ extern const hecl::Backend::Function ExtensionPostFuncsHLSL[];
#define FOG_STRUCT_HLSL \
"struct Fog\n" \
"{\n" \
" int mode;\n" \
" float4 color;\n" \
" float rangeScale;\n" \
" float start;\n" \
" float A;\n" \
" float B;\n" \
" float C;\n" \
" int mode;\n" \
"};\n"
#define FOG_ALGORITHM_HLSL \
" float fogZ, temp;\n" \
" float fogZ;\n" \
" float fogF = saturate((fog.A / (fog.B - (1.0 - vtf.mvpPos.z))) - fog.C);\n" \
" switch (fog.mode)\n" \
" {\n" \
" case 2:\n" \
" fogZ = (-vtf.mvPos.z - fog.start) * fog.rangeScale;\n" \
" fogZ = fogF;\n" \
" break;\n" \
" case 4:\n" \
" fogZ = 1.0 - exp2(-8.0 * (-vtf.mvPos.z - fog.start) * fog.rangeScale);\n" \
" fogZ = 1.0 - exp2(-8.0 * fogF);\n" \
" break;\n" \
" case 5:\n" \
" temp = (-vtf.mvPos.z - fog.start) * fog.rangeScale;\n" \
" fogZ = 1.0 - exp2(-8.0 * temp * temp);\n" \
" fogZ = 1.0 - exp2(-8.0 * fogF * fogF);\n" \
" break;\n" \
" case 6:\n" \
" fogZ = exp2(-8.0 * (fog.start + vtf.mvPos.z) * fog.rangeScale);\n" \
" fogZ = exp2(-8.0 * (1.0 - fogF));\n" \
" break;\n" \
" case 7:\n" \
" temp = (fog.start + vtf.mvPos.z) * fog.rangeScale;\n" \
" fogZ = exp2(-8.0 * temp * temp);\n" \
" fogF = 1.0 - fogF;\n" \
" fogZ = exp2(-8.0 * fogF * fogF);\n" \
" break;\n" \
" default:\n" \
" fogZ = 0.0;\n" \
@ -99,13 +100,7 @@ static std::string_view LightingShadowHLSL =
" float4 linAtt;\n"
" float4 angAtt;\n"
"};\n"
"struct Fog\n"
"{\n"
" int mode;\n"
" float4 color;\n"
" float rangeScale;\n"
" float start;\n"
"};\n"
FOG_STRUCT_HLSL
"\n"
"cbuffer LightingUniform : register(b2)\n"
"{\n"

View File

@ -9,10 +9,11 @@ extern const hecl::Backend::Function ExtensionPostFuncsMetal[];
#define FOG_STRUCT_METAL \
"struct Fog\n" \
"{\n" \
" int mode;\n" \
" float4 color;\n" \
" float rangeScale;\n" \
" float start;\n" \
" float A;\n" \
" float B;\n" \
" float C;\n" \
" int mode;\n" \
"};\n"
#define FOG_ALGORITHM_METAL \

View File

@ -128,3 +128,4 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]])
#shader CColoredQuadFilterMul : CColoredQuadFilter
#srcfac zero
#dstfac srccolor
#overwritealpha true

View File

@ -256,7 +256,9 @@ float4 main(in VertToFrag vtf) : SV_Target0
{
float4 texel = tex0.Sample(samp, vtf.uv);
float4 tmp = texel * vtf.color;
return float4(tmp * tmp.a, tmp.a * texel.r);
float4 colorOut = tmp * tmp.a;
colorOut.a = tmp.a * texel.r;
return colorOut;
}
#fragment metal
@ -273,7 +275,9 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
{
float4 texel = tex0.sample(samp, vtf.uv);
float4 tmp = texel * vtf.color;
return float4(tmp * tmp.a, tmp.a * texel.r);
float4 colorOut = tmp * tmp.a;
colorOut.a = tmp.a * texel.r;
return colorOut;
}
#shader CElementGenShaderTexRedToAlphaZTestAWrite : CElementGenShaderTexRedToAlphaZTest
@ -404,8 +408,6 @@ VertToFrag main(in VertData v, in uint vertId : SV_VertexID)
VertToFrag vtf;
vtf.color = v.colorIn * 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 = mul(mvp, v.posIn[vertId]);
@ -495,8 +497,9 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
float2 tindTexel = tex2.sample(samp, vtf.uvTind).ba;
float4 sceneTexel = tex1.sample(samp, mix(vtf.uvScene.xy, vtf.uvScene.zw, tindTexel));
float4 texrTexel = tex0.sample(samp, vtf.uvTexr);
float4 colr = vtf.color * float4(sceneTexel.rgb, 1.0) + texrTexel;
return float4(colr.rgb, vtf.color.a * texrTexel.a);
float4 colorOut = vtf.color * float4(sceneTexel.rgb, 1.0) + texrTexel;
colorOut.a = vtf.color.a * texrTexel.a;
return colorOut;
}
#shader CElementGenShaderIndTexZWriteAWrite : CElementGenShaderIndTexZWrite

View File

@ -64,11 +64,11 @@ TBINDING1 uniform sampler2D texEnv;
UBINDING1 uniform FogUniform
{
int mode;
vec4 color;
float A;
float B;
float C;
int mode;
};
vec4 MainPostFunc(vec4 colorIn)
@ -158,17 +158,17 @@ struct VertToFrag
cbuffer FogUniform : register(b1)
{
int mode;
float4 color;
float A;
float B;
float C;
int mode;
};
static float4 MainPostFunc(in VertToFrag vtf, float4 colorIn)
{
float fogZ;
float fogF = saturate((A / (B - vtf.position.z)) - C);
float fogF = saturate((A / (B - (1.0 - vtf.position.z))) - C);
switch (mode)
{
case 2:
@ -251,11 +251,11 @@ struct VertToFrag
struct FogUniform
{
int mode;
float4 color;
float A;
float B;
float C;
int mode;
};
float4 MainPostFunc(thread VertToFrag& vtf, constant FogUniform& fu, float4 colorIn)

View File

@ -32,11 +32,248 @@ void main()
#fragment glsl
struct Fog
{
int mode;
vec4 color;
float A;
float B;
float C;
int mode;
};
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, fog.color, 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 = MainPostFunc(vtf.color * moduColor * texture(tex, vtf.uv));
}
#vertex hlsl
struct VertData
{
float4 posIn : POSITION;
float4 colorIn : COLOR;
float4 uvIn : UV;
};
struct VertToFrag
{
float4 position : SV_Position;
float4 color : COLOR;
float2 uv : UV;
};
VertToFrag main(in VertData v)
{
VertToFrag vtf;
vtf.color = v.colorIn;
vtf.uv = v.uvIn.xy;
vtf.position = v.posIn;
return vtf;
}
#fragment hlsl
struct Fog
{
float4 color;
float A;
float B;
float C;
int mode;
};
cbuffer LineUniform : register(b0)
{
float4 moduColor;
Fog fog;
};
SamplerState samp : register(s3);
Texture2D tex0 : register(t0);
struct VertToFrag
{
float4 position : SV_Position;
float4 color : COLOR;
float2 uv : UV;
};
static float4 MainPostFunc(in VertToFrag vtf, float4 colorIn)
{
float fogZ;
float fogF = saturate((fog.A / (fog.B - (1.0 - vtf.position.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, fog.color, saturate(fogZ)).rgb, colorIn.a);
}
float4 main(in VertToFrag vtf) : SV_Target0
{
return MainPostFunc(vtf, vtf.color * moduColor * tex0.Sample(samp, vtf.uv));
}
#vertex metal
struct VertData
{
float4 posIn;
float4 colorIn;
float4 uvIn;
};
struct VertToFrag
{
float4 position [[ position ]];
float4 color;
float2 uv;
};
vertex VertToFrag vmain(constant VertData* va [[ buffer(0) ]],
uint vertId [[ vertex_id ]])
{
VertToFrag vtf;
constant VertData& v = va[vertId];
vtf.color = v.colorIn;
vtf.uv = v.uvIn.xy;
vtf.position = v.posIn;
return vtf;
}
#fragment metal
struct Fog
{
float4 color;
float A;
float B;
float C;
int mode;
};
struct LineUniform
{
float4 moduColor;
Fog fog;
};
struct VertToFrag
{
float4 position [[ position ]];
float4 color;
float2 uv;
};
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);
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, line.fog.color, saturate(fogZ)).rgb, colorIn.a);
}
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
sampler samp [[ sampler(3) ]],
texture2d<float> tex0 [[ texture(0) ]],
constant LineUniform& line [[ buffer(2) ]])
{
return MainPostFunc(vtf, line, vtf.color * line.moduColor * tex0.sample(samp, vtf.uv));
}
#shader CLineRendererShaderTexAlphaAWrite : CLineRendererShaderTexAlpha
#alphawrite true
#shader CLineRendererShaderTexAdditive : CLineRendererShaderTexAlpha
#srcfac srcalpha
#dstfac one
#depthtest none
#alphawrite false
#fragment glsl
struct Fog
{
vec4 color;
float A;
float B;
float C;
int mode;
};
UBINDING0 uniform LineUniform
@ -88,36 +325,22 @@ void main()
colorOut = MainPostFunc(vtf.color * moduColor * texture(tex, vtf.uv));
}
#vertex hlsl
struct VertData
#fragment hlsl
struct Fog
{
float4 posIn : POSITION;
float4 colorIn : COLOR;
float4 uvIn : UV;
float4 color;
float A;
float B;
float C;
int mode;
};
cbuffer LineUniform : register(b0)
{
float4 moduColor;
Fog fog;
};
struct VertToFrag
{
float4 position : SV_Position;
float4 color : COLOR;
float2 uv : UV;
};
VertToFrag main(in VertData v)
{
VertToFrag vtf;
vtf.color = v.colorIn * moduColor;
vtf.uv = v.uvIn.xy;
vtf.position = v.posIn;
return vtf;
}
#fragment hlsl
SamplerState samp : register(s3);
Texture2D tex0 : register(t0);
struct VertToFrag
@ -127,22 +350,54 @@ struct VertToFrag
float2 uv : UV;
};
float4 main(in VertToFrag vtf) : SV_Target0
static float4 MainPostFunc(in VertToFrag vtf, float4 colorIn)
{
return vtf.color * tex0.Sample(samp, vtf.uv);
float fogZ;
float fogF = saturate((fog.A / (fog.B - (1.0 - vtf.position.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);
}
#vertex metal
struct VertData
float4 main(in VertToFrag vtf) : SV_Target0
{
float4 posIn;
float4 colorIn;
float4 uvIn;
return MainPostFunc(vtf, vtf.color * moduColor * tex0.Sample(samp, vtf.uv));
}
#fragment metal
struct Fog
{
float4 color;
float A;
float B;
float C;
int mode;
};
struct LineUniform
{
float4 moduColor;
Fog fog;
};
struct VertToFrag
@ -152,42 +407,43 @@ struct VertToFrag
float2 uv;
};
vertex VertToFrag vmain(constant VertData* va [[ buffer(0) ]],
uint vertId [[ vertex_id ]],
constant LineUniform& line [[ buffer(2) ]])
static float4 MainPostFunc(thread VertToFrag& vtf, constant LineUniform& line, float4 colorIn)
{
VertToFrag vtf;
constant VertData& v = va[vertId];
vtf.color = v.colorIn * line.moduColor;
vtf.uv = v.uvIn.xy;
vtf.position = v.posIn;
return vtf;
float fogZ;
float fogF = saturate((line.fog.A / (line.fog.B - vtf.position.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 metal
struct VertToFrag
{
float4 position [[ position ]];
float4 color;
float2 uv;
};
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
sampler samp [[ sampler(3) ]],
texture2d<float> tex0 [[ texture(0) ]])
texture2d<float> tex0 [[ texture(0) ]],
constant LineUniform& line [[ buffer(2) ]])
{
return vtf.color * tex0.sample(samp, vtf.uv);
return MainPostFunc(vtf, line, vtf.color * line.moduColor * 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
@ -200,7 +456,7 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
#shader CLineRendererShaderTexAlphaZAWrite : CLineRendererShaderTexAlphaZ
#alphawrite true
#shader CLineRendererShaderTexAdditiveZ : CLineRendererShaderTexAlpha
#shader CLineRendererShaderTexAdditiveZ : CLineRendererShaderTexAdditive
#srcfac srcalpha
#dstfac one
#depthtest lequal
@ -239,11 +495,234 @@ void main()
#fragment glsl
struct Fog
{
int mode;
vec4 color;
float A;
float B;
float C;
int mode;
};
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, fog.color, clamp(fogZ, 0.0, 1.0)).rgb, colorIn.a);
}
SBINDING(0) in VertToFrag vtf;
layout(location=0) out vec4 colorOut;
void main()
{
colorOut = MainPostFunc(vtf.color * moduColor);
}
#vertex hlsl
struct VertData
{
float4 posIn : POSITION;
float4 colorIn : COLOR;
};
struct VertToFrag
{
float4 position : SV_Position;
float4 color : COLOR;
};
VertToFrag main(in VertData v)
{
VertToFrag vtf;
vtf.color = v.colorIn;
vtf.position = v.posIn;
return vtf;
}
#fragment hlsl
struct Fog
{
float4 color;
float A;
float B;
float C;
int mode;
};
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 - (1.0 - 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, fog.color, saturate(fogZ)).rgb, colorIn.a);
}
float4 main(in VertToFrag vtf) : SV_Target0
{
return MainPostFunc(vtf.color * moduColor, vtf.position);
}
#vertex metal
struct VertData
{
float4 posIn;
float4 colorIn;
};
struct VertToFrag
{
float4 position [[ position ]];
float4 color;
};
vertex VertToFrag vmain(constant VertData* va [[ buffer(0) ]],
uint vertId [[ vertex_id ]])
{
VertToFrag vtf;
constant VertData& v = va[vertId];
vtf.color = v.colorIn;
vtf.position = v.posIn;
return vtf;
}
#fragment metal
struct Fog
{
float4 color;
float A;
float B;
float C;
int mode;
};
struct LineUniform
{
float4 moduColor;
Fog fog;
};
struct VertToFrag
{
float4 position [[ position ]];
float4 color;
};
static float4 MainPostFunc(float4 colorIn, constant LineUniform& line, float FragCoord)
{
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, line.fog.color, 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
#fragment glsl
struct Fog
{
vec4 color;
float A;
float B;
float C;
int mode;
};
UBINDING0 uniform LineUniform
@ -293,35 +772,14 @@ void main()
colorOut = MainPostFunc(vtf.color * moduColor);
}
#vertex hlsl
struct VertData
{
float4 posIn : POSITION;
float4 colorIn : COLOR;
};
struct VertToFrag
{
float4 position : SV_Position;
float4 color : COLOR;
};
VertToFrag main(in VertData v)
{
VertToFrag vtf;
vtf.color = v.colorIn;
vtf.position = v.posIn;
return vtf;
}
#fragment hlsl
struct Fog
{
int mode;
float4 color;
float A;
float B;
float C;
int mode;
};
cbuffer LineUniform : register(b0)
@ -339,7 +797,7 @@ struct VertToFrag
static float4 MainPostFunc(float4 colorIn, float4 FragCoord)
{
float fogZ;
float fogF = saturate((fog.A / (fog.B - FragCoord.z)) - fog.C);
float fogF = saturate((fog.A / (fog.B - (1.0 - FragCoord.z))) - fog.C);
switch (fog.mode)
{
case 2:
@ -370,37 +828,14 @@ float4 main(in VertToFrag vtf) : SV_Target0
return MainPostFunc(vtf.color * moduColor, vtf.position);
}
#vertex metal
struct VertData
{
float4 posIn;
float4 colorIn;
};
struct VertToFrag
{
float4 position [[ position ]];
float4 color;
};
vertex VertToFrag vmain(constant VertData* va [[ buffer(0) ]],
uint vertId [[ vertex_id ]])
{
VertToFrag vtf;
constant VertData& v = va[vertId];
vtf.color = v.colorIn;
vtf.position = v.posIn;
return vtf;
}
#fragment metal
struct Fog
{
int mode;
float4 color;
float A;
float B;
float C;
int mode;
};
struct LineUniform
@ -450,15 +885,6 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
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
@ -471,7 +897,7 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
#shader CLineRendererShaderNoTexAlphaZAWrite : CLineRendererShaderNoTexAlphaZ
#alphawrite true
#shader CLineRendererShaderNoTexAdditiveZ : CLineRendererShaderNoTexAlpha
#shader CLineRendererShaderNoTexAdditiveZ : CLineRendererShaderNoTexAdditive
#srcfac srcalpha
#dstfac one
#depthtest lequal

View File

@ -200,10 +200,12 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
#shader CRandomStaticFilterMult : CRandomStaticFilterAlpha
#srcfac zero
#dstfac srccolor
#overwritealpha true
#shader CRandomStaticFilterCookieCutter : CRandomStaticFilterAlpha
#srcfac zero
#dstfac srccolor
#overwritealpha true
#depthwrite true
#colorwrite false
#depthtest lequal

View File

@ -121,3 +121,4 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]])
#shader CScanLinesFilterMult : CScanLinesFilterAlpha
#srcfac zero
#dstfac srccolor
#overwritealpha true

View File

@ -180,6 +180,7 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
#srcfac zero
#dstfac srccolor
#depthtest none
#overwritealpha true
#shader CTexturedQuadFilterMultGEqual : CTexturedQuadFilterMult
#depthtest gequal
@ -191,6 +192,7 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
#srcfac zero
#dstfac invsrccolor
#depthtest none
#overwritealpha true
#shader CTexturedQuadFilterInvDstMultGEqual : CTexturedQuadFilterInvDstMult
#depthtest gequal
@ -204,6 +206,7 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
#srcfac srcalpha
#dstfac invsrcalpha
#depthtest none
#overwritealpha false
#fragment glsl
struct VertToFrag
@ -265,10 +268,12 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
#shader CTexturedQuadFilterAlphaTexMult : CTexturedQuadFilterAlphaTexAlpha
#srcfac zero
#dstfac srccolor
#overwritealpha true
#shader CTexturedQuadFilterAlphaTexInvDstMult : CTexturedQuadFilterAlphaTexAlpha
#srcfac zero
#dstfac invsrccolor
#overwritealpha true
#shader CTexturedQuadFilterAlphaGEqualZWrite : CTexturedQuadFilterAlpha
#depthtest gequal

View File

@ -159,7 +159,9 @@ 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) + 16.0 / 255.0;
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

@ -3,11 +3,11 @@
#define FOG_STRUCT_GLSL \
"struct Fog\n" \
"{\n" \
" int mode;\n" \
" vec4 color;\n" \
" float A;\n" \
" float B;\n" \
" float C;\n" \
" int mode;\n" \
" float indScale;\n" \
"};\n"

View File

@ -3,11 +3,11 @@
#define FOG_STRUCT_HLSL \
"struct Fog\n" \
"{\n" \
" int mode;\n" \
" float4 color;\n" \
" float A;\n" \
" float B;\n" \
" float C;\n" \
" int mode;\n" \
" float indScale;\n" \
"};\n"
@ -15,7 +15,7 @@
"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" \
" float fogF = saturate((fog.A / (fog.B - (1.0 - vtf.pos.z))) - fog.C);\n" \
" switch (fog.mode)\n" \
" {\n" \
" case 2:\n" \

View File

@ -3,11 +3,11 @@
#define FOG_STRUCT_METAL \
"struct Fog\n" \
"{\n" \
" int mode;\n" \
" float4 color;\n" \
" float A;\n" \
" float B;\n" \
" float C;\n" \
" int mode;\n" \
" float indScale;\n" \
"};\n"

2
hecl

@ -1 +1 @@
Subproject commit bfd649cd9f2b9d4382d83d5b0971f97e0ac98d84
Subproject commit ad075d532e478c0f90b86200828ef7585050c817

@ -1 +1 @@
Subproject commit 935f781e03a7f23b17d202ce8740a4b32a06140a
Subproject commit c56b69627ca3daee510ca1c52aa7198634519d0a