The OutputAlpha() function is called in all standard URP shaders, such as BakedLit:
finalColor.a = OutputAlpha(finalColor.a, _Surface);
Internally, the check to determine if the shader is opaque is not performed conditionally.
half OutputAlpha(half alpha, bool isTransparent)
{
if (isTransparent)
{
return alpha;
}
else
{
#if defined(_ALPHATEST_ON)
// Opaque materials should always export an alpha value of 1.0 unless alpha-to-coverage is available
return IsAlphaToMaskAvailable() ? alpha : 1.0;
#else
return 1.0;
#endif
}
}
Why does check use the _Surface variable instead of the _SURFACE_TYPE_TRANSPARENT keyword? A little higher in the code, AlphaDiscard (_ALPHATEST_ON keyword) and AlphaModulate (_ALPHAMODULATE_ON keyword) are completely under conditional compilation.
When _Surface=1 is set, the _SURFACE_TYPE_TRANSPARENT keyword is also always enabled.
If we surround this with conditional compilation:
#ifdef _SURFACE_TYPE_TRANSPARENT // or #if defined(_SURFACE_TYPE_TRANSPARENT) || defined(_ALPHATEST_ON)
finalColor.a = OutputAlpha(finalColor.a, _Surface);
#else
finalColor.a = 1.0;
#endif
This will give the following gain (GLES3x):

