How to resize objects at different z-positions to exactly fit camera (width and height)?

It’s this topic you’re talking about, it was useful for me.