NVlabs / nvdiffrast

Nvdiffrast - Modular Primitives for High-Performance Differentiable Rendering
Other
1.35k stars 144 forks source link

Bogus error in even-channeled texture mapping #16

Closed msqrt closed 3 years ago

msqrt commented 3 years ago

Using pytorch, calling dr.texture for a texture with an even number of channels gives the error "tex or mip input tensor not aligned to float4" (or "float2" for 2 channels). To reproduce, replace line 34 in samples/torch/earth.py with the following (making the texture 4-channeled and discarding the last channel after texturing; should be perfectly OK):

        tex = torch.cat((tex, tex[...,:1]),-1)
        color = dr.texture(tex[None, ...], texc, texd, filter_mode='linear-mipmap-linear', max_mip_level=max_mip_level)[..., :3]

This seems to be due to this and this line in torch_texture.cpp, where the condition should probably read i <= p.mipLevelMax instead of 0 <= p.mipLevelMax.

s-laine commented 3 years ago

Oof, fixed 😅. Thanks for the report!