You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The "Hello Triangle" with DRTK would look like this:
importdrtkimporttorchasthfromtorchvision.utilsimportsave_image# to save images# create vertex buffer of shape [1 x n_vertices x 3], here for triangle `n_vertices` == 3v=th.as_tensor([[[0, 511, 1], [255, 0, 1], [511, 511, 1]]]).float().cuda()
# create index buffervi=th.as_tensor([[0, 1, 2]]).int().cuda()
# rasterizeindex_img=drtk.rasterize(v, vi, height=512, width=512)
# compute baricentrics_, bary=drtk.render(v, vi, index_img)
# we won't do shading, we'll just save the baricentrics and filter out the empty region# which is marked with `-1` in `index_img`img=bary* (index_img!=-1)
save_image(img, "render.png")
DRTK is MIT licensed, as found in the LICENSE file.
Citation
@mish{pidhorskyi2024rasterized,
title = {Rasterized Edge Gradients: Handling Discontinuities Differentiably},
author = {Pidhorskyi, Stanislav and Simon, Tomas and Schwartz, Gabriel and Wen, He and Sheikh, Yaser and Saragih, Jason},
howpublished = {arXiv preprint},
year = {2024},
note = {arXiv:2405.02508}
}