I am confused, I thought you were asking about the material function we already have called Sphere_AO? somebody mentioned it by name up above.
The code snippet posted looks like the same thing but much longer for some reason as far as I can tell. Maybe some additional below the horizon math that isn’t needed in your case.
It does work exactly like you say, except that the sphere is purely virtual, there is no actual sphere for the leg you will merely set a parameter in the material pretending it is there. That really isn’t so hard, you can grab a bone position in the blueprint by using Get Socket Location. Then set to update a material param collection or MID value. Then you place the material on more of a box or flat plane that is closer to the ground.
Showdown VR used something much simpler, it just used a blob texture on translucency.
If translucency is a no-go then I don’t see how you can do it other than placing the Sphere_AO material function into your ground material like my alternate suggestion.