How to reverse 'DistanceToNearestSurface'

How would one reverse the effect of the DistanceToNearestSurface node. Im trying to occlude the surface caustics in my emissive color from showing up where the foam is.

Below is with the DTNS effect, however simply changing the value to a negative didnt work. Foam is base color and caustics are emissive.

Basically, if it’s a short distance to the nearest surface, you need to reduce the emmissive.

You need to rationalize the distance and feed it into a lerp which goes from max to min emmissive.

By rationalize, I mean make a computation involving the actual distance, how far you want the effect to last etc and map this to the 0-1 range needed for a lerp.