This might not be a definitive solution to fix z-fighting issues, but it's a good solution meanwhile and can be implemented easily on any shader just by adding a few lines.