In the derived category of a commutative noetherian ring, we explicitly construct a silting object associated with each sp-filtration of the Zariski spectrum satisfying the "slice" condition. Our new construction is based on local cohomology and it allows us to study when the silting object is tilting. For a ring admitting a dualizing complex, this occurs precisely when the sp-filtration arises from a codimension function on the spectrum. In the absence of a dualizing complex, the situation is more delicate and the tilting property is closely related to the condition that the ring is a homomorphic image of a Cohen-Macaulay ring. We also provide dual versions of our results in the cosilting case. Contents 1. Introduction 1 2. Preliminaries 5 2.1. Silting objects in derived categories 5 2.2. Bousfield localization 9 2.3. Depth and width 11 2.4. Sp-filtrations 12 2.5. Dualizing complexes 14 2.6. Lukas lemma for complexes 17 3. Slice sp-filtrations and codimension filtrations 18 4. Proof of Theorem 1.1 24 5. Cosilting objects corresponding to slice sp-filtrations 31 6. Endomorphism rings of (co)tilting objects induced by codimension functions 36 7. Homomorphic images of Cohen-Macaulay rings 50 References 59