I work as a photographer for Uncle Sam.
I use a small piece of regular soap, such as Ivory. Don't use a soap with cold creams in it or any other oily substance.
Ever been to a country fair and seen that guy hawking the bright orange sticks of anti-fogger? It's soap, with orange dye. Nothing more. And you pay $5 for this "marvel of science."
Many of the liquid anti-foggers also sold at sporting shows and county fairs are just dissolved soap with a little alcohol mixed with the water --- and a fancy label. But in spray form, it's convenient to carry.
Back to the camera ...
Across the filter (I never use a camera lens without a filter) give it one heavy streak of soap and then, with a dry, clean cloth, polish it out in all directions until the filter is clear. That very thin coating of soap will not obstruct vision but will keep the filter from fogging.
The same may be done with the lenses on binoculars and rifle scopes, but the lens must be absolutely clean first. You don't want to put the soap over crud and dirt, then run the risk of scratching the lens by polishing out the soap. The same warning applies to eyeglasses.
Soap also works inside diving masks. Been years since I've spit inside my mask, since being shown this trick.
Works inside the side windows of your car too but I prefer to use the Rain-X Defogger. It's easier to apply and wipe off on large areas such as a window.
The regular, exterior Rain-X is wonderful stuff but it leaves a very thin plastic coating on glass. I don't know how this might affect optics. Soap is benign if the lens is well-cleaned before use.
I keep a chunk of soap in a plastic pill bottle in my camera bag. Works on camera filters and eyeglasses. On occasion, I have to enter a steamy environment to take photos. A thin coating of soap keeps the lens from fogging and I get the photos I need.
Soap .... it's not just for cleaning, anymore ... heh