Hi Flordelis,
I was facing the same problem: trying to mask out the background through glass with complicated shapes (trees...) in the foreground.
In my search I came up with this solution, which is not perfect but did the trick for me:
As you can see, it is not the perfect solution since it only seems to work when the refraction color is set to white, but maybe it can be of any help!
Good luck!