material dynamic mask (edge detect) for tiles grout?

Hi,

I’d like to know if there is any way to utilize some sort of edge detect (as a mask) where two objects meet, to be able to dynamically add grout.

Here is a screenshot of what I’m trying to achieve.

Thank you!

if you are using baked lighting (Static ) then using AmbiantOclusion Mask is the best way to do it
youc could do it with DistanceFields with the node DistanceToNearestSurface but you need to activate DistanceFields hope it helped you !

Thank you for your help.

I tried using ambientOcclusionMask but it creates artifacts. The problem is at the corner, where it creates uneven area.

I don’t quite understand how to use the DistanceToNearestSurface works and how to implement it, so could you make a screenshot or elaborate a bit more, on how to use it.
Thank you!