Can I use a custom shape function using numpy or torch? #555
-
Hi, thank you for developing such an awesome software. class MyShape(nn.Module):
def __init__(self, *args, **kwargs):
super().__init__()
# model definitions here
...
def forward(self, x, y, z):
xyz = torch.cat([x, y, z], dim=1)
signed_distance = self.model(xyz)
normals = self.compute_normal(xyz)
return signd_distance, normals
def compute_normal(self, xyz):
# normal vectors can easily be computed by using autodiff feature in torch
...
return normals If it is not possible for now, are you willing to possibly add this feature? What do you think of this? Thanks :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Unfortunately, that's not possible right now.
If you could export such a math tree from Torch, that would be one option; another option would be to use the Oracle API (which requires writing C++, discussed here). I don't have the resources to do either implementation myself. |
Beta Was this translation helpful? Give feedback.
Unfortunately, that's not possible right now.
libfive
works by compiling shapes down to math trees, usually using evaluation tracing (that's how the@shape
decorator works). These tree objects are what's rendered, so it doesn't support arbitrary code.If you could export such a math tree from Torch, that would be one option; another option would be to use the Oracle API (which requires writing C++, discussed here). I don't have the resources to do either implementation myself.