I work from a home office with a family. You close the door and as long as the boundaries are clear there's no problem. If you want to take a break and go shopping you can do that... It's doable.
Yes definitely, the problem is more with the perception of those in the office. All they see is you are working from home with your family and they might assume you're not able to give it your full attention.
At a previous job my manager complained incessantly about my arrival and leave times but could not find an instance where I wasn't responsive, available, and getting done everything that needed to be.
The reason I wasn't more responsive to his complaints was that I'd watch him spend his entire day at his computer either browsing facebook or reading sports blogs.
In my first ever job my manager would always sort of deliberately look at his watch when I got in, which was anything between 9am and 1pm :) But otherwise we got along great. I think it was just his way of trying to teach me some of his values which unfortunately I didn't share ;) Usually if I came in at 1pm it's because I was at work until 1am the last night... Other than that job my other managers never cared. I've always worked long hours but never fixed hours. When I managed other people, unless there are some other problems, I couldn't care less about arrival and leave times. I think these days it's unusual to find managers in tech who are about these things but YMMV.
If you're happy working those kinds of moving shifts where you're there 'til the wee hours, leave a breadcrumb trail showing that you were working. A minor email; a message in a chat channel; a manual build that sends an email out to stakeholders. It'll softly remind folks that you were on the case. And if, heaven forbid, you ever get a stickler HR person, you can show them that trail.
It probably depends on the location/culture but I've never seen issues with that. I've also, as far as I recall, never signed a contract that specified hours/week or a particular schedule. I've worked with people who came in at 5am to beat rush hour and would leave early and people who came in much later and would stay late and anything in between. Tech workers' time is generally considered flexible which is why they don't usually get paid overtime either. If you're ever at a point where HR is looking at how many hours you "punched in" then there's probably other problems. I would say that if your value is measured by "hours" that would be a red flag already. Probably no shortage of workplaces like that but I wouldn't want to work there as long as I have choice.
EDIT: p.s. if it wasn't clear I no longer do the 1pm->1am schedule. That was when I was young with no other commitments. It's not the healthiest schedule ;) Now my hours are more conventional but still reasonably flexible. I work for a large tech company and no one cares when you come in or leave as long as the work gets done.
Ironic really considering you are actually the only one who is actually able to give your work full attention as they are constantly being distracted by each other. The perception of work != actual work.