How to prevent interpolation in tex2D function


I am using optix6.5 for rendering. And I am trying to use tex2D to sample the radiance. But I don’t know how can I prevent interpolation in this function. In other words, I only want to use the nearest neighbor to get the radiance. Could anyone helps ? Thank you very much!

I found rtTextureSamplerSetFilteringModes may be useful. But when I call it, always get the complaint that identifier rtTextureSamplerSetFilteringModes is not defined. It should work because I can use rtTextureSampler in the same .cu file.

Please first read this post about the recommended texture usage in OptiX versions before 7:

rtTextureSamplerSetFilteringModes is a host function defined in optix_host.h. You cannot call it inside device code. The texture sampler state is immutable there.

Have a look at this code which explains how to setup a texture sampler in the old OptiX API and get a bindless texture ID from it:

That code uses bilinear texture filtering by default.
If you do not want that but nearest texture filtering, you need to change this line:
to m_sampler->setFilteringModes(RT_FILTER_NEAREST, RT_FILTER_NEAREST, mipmapFilter);