2

I am trying to store an octree in a 3D texture in OpenGL for use on the GPU using Cg, from a chapter in GPU Gems 2 found here http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter37.html. However the results I am getting are incorrect. I think this is because of how I create the octree.

In the appendix of that chapter, it says "If we bind the indirection pool texture (octree texture) in repeat mode (GL_REPEAT)...".

Does this simply mean set the the filters and wrapping to repeat, or do I need to do something else? This is my code so far

glGenTextures(1, &octree_texture);
glBindTexture(GL_TEXTURE_3D, octree_texture);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_REPEAT);
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, WIDTH, HEIGHT, DEPTH, 0, GL_RGBA, GL_UNSIGNED_BYTE, octreeData);

Thanks for the help :)

Benzino
  • 577
  • 2
  • 8
  • 21
  • Sorry, but to delve into GPU Gems you should at least have some basic knowledge of practical 3D graphics and know the distinction between wrapping mode and filter mode. – Christian Rau Aug 04 '11 at 13:19
  • Well I do know 3D graphics, I just haven't worked in the OpenGL environment that much. I have everything else set up, GPU raycasting and CPU octree, just need to store the octree correctly in the texture. Of course, it is obvious the filters shouldn't be set to repeat. Been a long day, wasn't thinking straight! :D – Benzino Aug 04 '11 at 14:54

1 Answers1

3

The filters can't be repeat, that will generate a GL error, only the wrap mode can be GL_REPEAT, and that's probably what the book means.

Dr. Snoopy
  • 55,122
  • 7
  • 121
  • 140
  • Ah ok, that must be it so. Still not working, but at least I can eliminate that as a potential cause! Thanks! – Benzino Aug 04 '11 at 12:25
  • @Benzino Did you set the MIN/MAG filters to something like GL_NEAREST or GL_LINEAR? – Dr. Snoopy Aug 04 '11 at 15:39
  • I have it currently set to GL_NEAREST. I'm beginning to think the order of the data been stored in the texture is incorrect rather than the actual texture filters and parameters – Benzino Aug 04 '11 at 16:15