improved MSAA instance transparency

This commit is contained in:
Turánszki János
2025-07-07 08:31:24 +02:00
parent 985596c9b3
commit 38caf1a5f0
+23 -12
View File
@@ -515,17 +515,6 @@ float4 main(PixelInput input, in bool is_frontface : SV_IsFrontFace APPEND_COVER
write_mipmap_feedback(push.materialIndex, ddx_coarse(uvsets), ddy_coarse(uvsets));
#endif // TILEDFORWARD
#ifndef DISABLE_ALPHATEST
#ifndef TRANSPARENT
#ifndef ENVMAPRENDERING
#ifdef OBJECTSHADER_USE_DITHERING
// apply dithering:
clip(dither(pixel + GetTemporalAASampleRotation()) - input.GetDither());
#endif // OBJECTSHADER_USE_DITHERING
#endif // DISABLE_ALPHATEST
#endif // TRANSPARENT
#endif // ENVMAPRENDERING
#ifdef OBJECTSHADER_USE_INSTANCEINDEX
ShaderMeshInstance meshinstance = load_instance(input.GetInstanceIndex());
#endif // OBJECTSHADER_USE_INSTANCEINDEX
@@ -1078,8 +1067,30 @@ float4 main(PixelInput input, in bool is_frontface : SV_IsFrontFace APPEND_COVER
color = saturateMediump(color);
half alphatest = material.GetAlphaTest() + meshinstance.GetAlphaTest();
#ifndef DISABLE_ALPHATEST
coverage = AlphaToCoverage(color.a, material.GetAlphaTest() + meshinstance.GetAlphaTest(), input.pos); // opaque soft alpha test (MSAA, temporal AA support)
#ifndef TRANSPARENT
#ifndef ENVMAPRENDERING
#ifdef OBJECTSHADER_USE_DITHERING
// apply dithering:
if (GetCamera().sample_count > 1)
{
// AlphaToCoverage will handle it as transparent instead of dithering:
color.a -= input.GetDither();
alphatest += input.GetDither();
}
else
{
clip(dither(pixel + GetTemporalAASampleRotation()) - input.GetDither());
}
#endif // OBJECTSHADER_USE_DITHERING
#endif // DISABLE_ALPHATEST
#endif // TRANSPARENT
#endif // ENVMAPRENDERING
#ifndef DISABLE_ALPHATEST
coverage = AlphaToCoverage(color.a, alphatest, input.pos); // opaque soft alpha test (MSAA, temporal AA support)
#endif // DISABLE_ALPHATEST
// end point: