Ray SOP, minimum distance, understanding the result

I’m using the minimum distance option on a Ray SOP, and I’m surprised by the results.

For every point on input 1 (box), I want to know the minimum distance to anywhere on the surface of input 2 (sphere).

The sphere has radius 0.3 and the box has radius 0.5. That means the point (0, 0, -.5) is minimally 0.2 away from the surface of the sphere. The Ray SOP correctly calculates this. However, the calculation for (0,0,.5) is 0.8, as if it were calculating to an intersection at the other side of the sphere. Can anyone offer insight?
ray_sop_understanding.1.toe (4.61 KB)

The ray sop will only ray along the normals of the input 1 sop

Thanks. It looks like I can’t use the Ray SOP for this, and TD may not currently have the built-in function I need.
https://docs.unity3d.com/ScriptReference/Physics.CheckSphere.html

If this existed in TD, I’d do a raymarching algorithm like in SearchDistance
https://github.com/keijiro/DFVolume/blob/master/Assets/DFVolume/VolumeSampler.cs

Actually, in the case of ‘minimum distance’, normals aren’t required,
but it does seem it’s not acting properly, or well enough.
I’ve logged this as a bug.
Thanks for posting.

Didn’t know that. Sorry for the wrong answer David

Reasonable assumption given how poor the results are!

Picking up this thread again, what are the latest and greatest ways of doing DFVolume (building a 3D texture of a distance field for a static mesh)? If TD had a sphere collision function we could do a raymarching technique.

Hi David,

I’ve looked into some techniques for similar ideas, and this is all pretty deep into DIY territory. Xenoptik has successfully created 3d octrees of a TD scene as 3d textures for each density, and iirc achieved global illumination with refractions, but it was full of hacks as there are limits to how deep in the opengl pipeline you can get using TD. Heavy preprocessing of sops to stuff values into custom attributes available to shaders seemed to be the key to getting things to work.

This seems usable github.com/aman-tiwari/MeshToSDF
I didn’t realize JFA could extend to 3D. It’s a 64x64x64 texture 3D.
Update: I got it working in TD :open_mouth: