We express nested Hilbert schemes of points and curves on a smooth projective surface as ‘virtual resolutions’ of degeneracy loci of maps of vector bundles on smooth ambient spaces. We show how to modify the resulting obstruction theories to produce the virtual cycles of Vafa–Witten theory and other sheaf-counting problems. The result is an effective way of calculating invariants (VW, SW, local PT and local DT) via Thom–Porteous-like Chern class formulae.