Defeating them is not strictly necessary, however, as the ingredients are dropped during the fight. On the Desktop version, it requires fighting the Brain of Cthulhu or the Eater of Worlds to obtain Tissue Samples or Shadow Scales.
Both can also be acquired before the player obtains a Deathbringer or Nightmare Pickaxe, but acquiring the Obsidian will require explosives or an alternate form of mining.