Actually, one could determine optimal ethical codes based on the nature and structure of a given society with a purely scientific method, in which we define a desirable state for the society as a whole, and then determine the necessary codes of ethics that will allow us to achieve that state.
Of course, we can still argue that how we go about defining a desirable state is itself left to philosophy or religion, and to an extent I'm forced to agree. But we can leave religion entirely out of it, and embrace a philosophy which eschews the unscientific and emotive, the unproven and irrelevant, and embraces overall positive benefits for our species based upon known facts and provable methods.
Of course, there are many who would undoubtably cry out against such a philosophy, because obviously it would mean going against many of their cherished beliefs; for example, by viewing the human as merely another animal - and one which can be tailored to more suitable forms as the society requires - we dehumanize the human animal and reduce its divine nature. This is, of course, repugnant to many people, even those not of religious bent.
But the process has been in place for centuries, and with a few minor setbacks, proceeds apace. Our children's children may very well see the dawn of an age where reason and logic supplant emotion and faith entirely, and religion is relegated to a few fringes of society, where it belongs.
Sincerely,
Rev. Tohausen