Recommended datatypes for single channel buffers

Im trying to slim down my project that started from the optixPathTracer example to only use grayscale buffers. At first i used the normal float datatype until i stumbled over the float1 that seems to be a cuda specific data type. Using normal float i couldn’t utilize the lerp function getting a type error (even though it seems to have an implementation for 3 float inputs). Using float1 the basic operators (*, / , …) seem to be undefined. What’s the best practice here? Thanks in advance!

Hi @el_flamenco,

I’ve never used the float1 types, I’m not sure what those are for. There is a float version of lerp in OptiX in the file SDK/sutil/vec_math.h. I can also see one in the CUDA headers in cuda/std/detail/libcxx/include/cmath. I haven’t used the cmath one, so I don’t know if there are caveats.

Sometimes I just write my own, since it’s small. There’s nothing tricky or proprietary about the NVIDIA provided implementations of lerp, so you could paste a version like this one if you prefer:

float lerp(const float a, const float b, const float t)
{
  return a + t*(b-a);
}


David.

1 Like

Thanks for the answer! So i guess i will just stick with standard float. For the lerp function i will look into the problem. The one used in the sample is from sutil/vec_math.h and i assumed it’d simply work. Probably some small mistake i made somewhere else.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.