Hi all,
I am newer cuda-programmer and apologize in advance if I posted this in the wrong place…
My question has to do with the CUDA SDK Volume Render.
When the values from the Bucky.raw file are stored in the texture, I am unsure how they are normalized. I am modifying it for my research and need to check the value that the sample receives to coordinate my transfer function. I know the values are clamped between [0,1], but I am a little unsure how they are clamped before being stored in the texture.
Any help would be GREATLY appreciated :)
Hey onorinbejasus,
at first you have the data as unsigned char type. Then you initialize texture
texture<VolumeType, 3, cudaReadModeNormalizedFloat> tex;
with this data array. Attribute cudaReadModeNormalizedFloat defines read float data as normalized.
So at last you can read data from texture as float:
float sample = tex3D(tex, pos.x0.5f+0.5f, pos.y0.5f+0.5f, pos.z*0.5f+0.5f);
You can use cudaReadModeElementType instead cudaReadModeNormalizedFloat, then read data will not be normalized.
Thank you so much for the reply! So I am getting the correct values in the range I expected. I just have one last question. Are this values in anyway interpolated when they are returned to me? In other words, are the values I am getting the ones I entered?
Yep, they are interpolated. You can choose appropriate interpolation mode with filterMode attribute - cudaFilterModeLinear or cudaFilterModeLinear.