This is very easy. By default, anything you create - or even imagine - during business hours or in execution of your duties is 100% owned by the company. In fact, if you produce something at home and you can't show clean room separation between systems and code between your personal code and your work code, you're not likely going to keep the rights to that either.
You know that part of the employment process where they ask you to list all your prior works? This is them giving you a chance to CYA. Granted, the legalese on that page usually states that you're allowing them to use it for free in perpetuity if you include it in any of your work at the company, but that makes perfect sense Think utility libraries you carry around with you from job to job. They don't want to own them, but they can't risk having their products 'poisoned' by arbitrary licensing.
In fact, there's even a case where a guy had an idea, spoke to a co-worker about it, discussed it with his immediate superior and they decided not to follow up on it. After he quit the company, he started work on it himself, and was getting ready to finish/sell it, when he was sued by his prior employer. Because it had been 'developed' (thought of, even if it was never written down) on company time, the judge sided with the company and full ownership was given to them. He had to finish the program and deliver it and the mechanisms required to build and distribute it to them, without malicious sabotage Forced to write code for free, for a product the company didn't even want.
So! The only way this is really going to work for you is if you speak to your legal team and management.
I have, in the past, approached my manager(s) and asked permission to work on side jobs which were clearly and 100% outside of the scope of my current job; working on banking applications while I was writing automobile inventorying software, and was given permission. Got a signed statement, and I was good. Did open source work on the side as well, for a game engine, again, no problems.
However, it's extremely unlikely that anything you do at work will be allowed to be owned by you. No company likes giving away potential revenue and adding competitors with insider knowledge. I mean, really unlikely. Like, I can't even comprehend how you think it's a real possibility. Getting the company to go along with an open source thing might be one possibility, but an employee getting ownership?
Think of it this way: You work as a mechanic in a garage. You have access to all the tools and equipment there. You decide that you'll start your own business, in that garage, fixing cars, but you'll keep all the money instead of giving it to your employer, while still using his equipment and space. You still expect him to pay you for the hours you're working there.
Can you really see this happening? If so, you may need to lay off the cough syrup, cause we're all worried about you.