
This problem can't be avoided entirely and increasing the number of points ( normal_sample_count) even further doesn't seem to help. To mitigate this, the signs are determined by checking a number of surface points and using a majority vote. Q: There are cone shaped artifacts in the SDF volume when using sign_method='normal' via SSH)Īdd this to your script before importing mesh_to_sdf: import os Q: I want to run this on a computer without a screen (ie. This problem appears because pyrender tries to use a library that is only available on Linux.

This repository contains an implementation of the procedure proposed in the DeepSDF paper, as well as some alternatives. The sign of the point is positive if it is seen by any of the cameras. When using the depth buffer method, the point is projected in the frame of each render.īy comparing the depth element of the depth buffer and depth of the query point, we determine if the query point is seen by the camera. When using normals, the sign is determined with a dot product.

Use the inverse MVP matrix and depth buffer of each scan to calculate a world-space surface point cloud.These each consist of a normal buffer and a depth buffer. Create 100 virtual laser scans of the shape from multiple angles.The general pipeline for calculating SDF in this project is as follows: Viewer ( scene, use_raymond_lighting = True, point_size = 2 ) from_points ( points, colors = colors ) scene = pyrender. load ( 'chair.obj' ) points, sdf = sample_sdf_near_surface ( mesh, number_of_points = 250000 ) colors = np. from mesh_to_sdf import sample_sdf_near_surface import trimesh import pyrender import numpy as np mesh = trimesh. In this example, the resulting points are rendered in red where the SDF is positive and in blue where it is negative. This is the method that is proposed and used in the DeepSDF paper. This example creates 250,000 points, where most of the points are close to the surface and some are sampled uniformly. Sample SDF points non-uniformly near the surface Trimesh ( vertices = vertices, faces = faces, vertex_normals = normals ) mesh. marching_cubes ( voxels, level = 0 ) mesh = trimesh. load ( 'chair.obj' ) voxels = mesh_to_voxels ( mesh, 64, pad = True ) vertices, faces, normals, _ = skimage. from mesh_to_sdf import mesh_to_voxels import trimesh import skimage mesh = trimesh. In this example, a mesh is reconstructed using Marching Cubes and then rendered. The mesh_to_voxels function creates an N ✕ N ✕ N array of SDF values.
#Sdf file viewer for mac windows#
If you're using Windows or Mac, you need to work around a bug in pyrender.Ĭheck the FAQs below. It works for non-watertight meshes (meshes with holes), self-intersecting meshes, meshes with non-manifold geometry and meshes with inconsistently oriented faces. This project calculates approximate SDFs for triangle meshes.

Calculate signed distance fields for arbitrary meshes
