I’m trying to use a floating point texture as a look up table in my fragment program, I’m building my texture like this :
float fbuffer[1024];
for (int i = 0 ; i < 1024 ; i++)
{
double remap = ((double) (i - 511)) / (double) 512;
float arcos = (float) acos (remap);
fbuffer[i] = arcos;
}
glGenTextures(1, &m_AcosLookUpTexture);
glBindTexture(GL_TEXTURE_RECTANGLE_NV, m_AcosLookUpTexture);
glTexParameteri (GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri (GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri( GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri( GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D (GL_TEXTURE_RECTANGLE_NV, 0, FLOAT_R32_NV, 1024, 1, 0, GL_RED, GL_FLOAT, fbuffer);
And then in my fragment program I’m doing this :
PrecomputedAcos = texRECT (AcosLookUpTexture, angle).r;
But it doesn’t work : the result is always plain white. I think that it’s en error binding the texture to the program, with a classical texture format (glTexImage1D (GL_TEXTURE_1D, 0, GL_RGB, 1024, 0, GL_RED, GL_UNSIGNED_BYTE, buffer) ; ) it works but the precision is bad so I’ve got artefacts. I’m not really comfortable with how GL_NV_float_buffer really works what kinf of things should I check when I replace my basic 1D texture look up with a fp texture look up ?