2D SDF collision detection?

I found this method for detecting collisions with SDFs on Shadertoy. I have an idea for a filter which requires detailed collision, and I was wondering if there is any way of translating this method to Spark.

I don’t think it’s possible, at best you’d get a shader signal as result. But it probably can’t be done. I’d recommend something like AABB (but 2D), it isn’t as precise (especially if your shape is VERY different from a square) but I’ll detect a collision fairly reliably.

You can easily implement SDF collision for simple shapes like circles or rectangles. E.g. circle is a formula, co circle collision is just a distance(center1, center2) < r1 + r2.

2 Likes