NVlabs / nvdiffrast

Nvdiffrast - Modular Primitives for High-Performance Differentiable Rendering
Other
1.37k stars 146 forks source link

python to c++ #124

Closed chky1997 closed 1 year ago

chky1997 commented 1 year ago

Hi, thank you first for your great framework. I'm working on my python project using nvdiffrast.torch.rasterize() and nvdiffrast.torch.interpolate() to render a mesh. For further use, I need to convert my python code to c++ code, but I'm not familiar with c++. Could you please tell me how to use the two python functions above in a c++ project? Thank you!

s-laine commented 1 year ago

The Python functions in nvdiffrast/torch/ops.py are simply wrappers that call the C++ functions in the extension plugin, so you shouldn't need anything from them — from C++ code, you can call the C++ functions directly instead. These functions handle the interfacing between PyTorch and the CUDA kernels that do the actual computation, so if you're planning on not using Torch/PyTorch either, you'll have to modify them to operate with whatever tensor abstraction you have.

chky1997 commented 1 year ago

Thank you for your reply! Following your instruction, I found that rasterize.cu and interpolate.cu define some CUDA kernels for the actual computation. However, when I tried to use the kernels, many “undefined identifier“ and other errors occurred. How to solve this? Is there any other head file should be added? image image image

By the way, I'd appreciate it if there is any c++ example or guide can be provided. My email is chky1997@163.com. Thank you very much for your help!

s-laine commented 1 year ago

This is not an issue with nvdiffrast anymore, and general Cuda/C++ programming is way outside the scope of this issue tracker. I suggest you look for beginner-friendly tutorials for Cuda and C++ programming — there are many available online.

Closing as out-of-scope.