PDA

View Full Version : Texture Buffer Issues



ViolentHamster
12-15-2009, 06:06 PM
I accidently set my texture buffer format to GL_LUMINANCE instead of GL_LUMINANCE8. It would have been nice if the driver threw an error instead of giving me a bunch of 0s in the shader. Oh well.

Now I have another problem. I'm trying to access the buffer using a texture coordinate. Something like:

float val = texelFetch( buffer, int(texcoord.p)*stride + offset ).x;

Stride and offset are both integers. It sort of works, except I get some really nasty artifacts. It looks like z fighting. Is there something wrong with my code? Has anyone seen anything that looks like that?

Assuming I can get the texture buffer working, does anyone have performance numbers on texture buffers versus other texture types? (I've also coded it to work with texture arrays.)

Thanks in advance.

ViolentHamster
12-16-2009, 07:59 AM
A coworker figured out that int(texcoord.p + 0.5 ) fixes the problem. I guess texcoord might be something like 2.99999999999 sometimes and 3.000000000001 other times, so sometimes it rounds down and other times it rounds up. The flickering only happened when the eyepoint changed. Weird.