Use bitshifts idea for detecting proximity, it is more robust. Below I am attaching a snippet from a recent game jam I did that makes the enemies invisible if they aren't lit by a pebble the player throws, maybe that can help you with getting some smooth value once you know that you can actually see the pebble.
# Set alpha based on pebbles
var lightPower: float = 0;
# Go through all the pebbles in the scene
for pebble: Node2D in Global.pebbles:
# Apofex: Here you could add a check if the light source is reachable
# Distance to the currently examined pebble
var dist = pebble.position.distance_squared_to(position);
# 128 is the default radius for the pebbles light
# Pebble power is a number between 0 and 1 that determines how much power the pebble has left (shrinks radius)
# The multiplying by a small number is to make edges smoothly get more alpha instead of popping out of nowhere
# You may want to cap the value between 0 and 1 manually, here it is not needed.
var currentPower = ((128 * pebble.power)**2 - dist) * .0005;
# If the light received from the currently examined light is strongest yet, save it as the strongest.
if (currentPower > lightPower):
lightPower = currentPower;
# Change the alpha of my body to match light distance
$Body.modulate = Color(1, 1, 1, lightPower);
I wanted to attach a gif of it in action, but 1.5MB is apparently too large 😃