openvdb icon indicating copy to clipboard operation
openvdb copied to clipboard

[REQUEST] SDF Xor operation

Open MysteryPancake opened this issue 2 years ago • 1 comments

Currently OpenVDB supports the following SDF operations:

SDF Union: min(d1, d2)

SDF Intersection: max(d1, d2)

SDF Difference (usually named SDF Subtraction): max(-d1, d2)

However, it doesn't support the XOR operation described by Inigo Quilez: max(min(d1, d2), -max(d1, d2))

This operation finds regions where the sign mismatches.

image

It would be nice to include all standard SDF operations in OpenVDB.

MysteryPancake avatar Jan 08 '24 03:01 MysteryPancake

As a workaround you can find the symmetric difference with

csgUnionCopy(csgDifferenceCopy(grid1, grid2), csgDifferenceCopy(grid2, grid1))

or

csgDifferenceCopy(csgUnionCopy(grid1, grid2), csgIntersectionCopy(grid1, grid2))

For an in-place workaround, this might be the most efficient:

gridint = csgIntersectionCopy(grid1, grid2);
csgUnion(grid1, grid2);
csgDifference(grid1, gridint);

ghurstunither avatar Feb 13 '24 19:02 ghurstunither