Currently I read a 3D texture with the function texture(...) like this:
vec3 value = texture(texture_3D, coord).rgb
What I want to do now is:
vec3 value = texelFetch(texture_3D, coord, 0).xyz
However, I do not know how to convert my coordinate so that it works with texelFetch. My texture is of size 256x256x256
And my current coordinate calculation is as follows:
vec3 min_box = vec3(-0.5);
vec3 max_box = vec3(0.5);
vec3 coord = worldToVolume(world_pos, min_box, max_box)
vec3 worldToVolume(world_pos, min_box, max_box) {
return (world_pos - min_box) / (max_box - min_box)
}
Any ideas? If you need more information please ask and I will provide it.