Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Floating Point textures in Cg

  1. #1
    Intern Newbie
    Join Date
    Mar 2003
    Location
    France
    Posts
    38

    Floating Point textures in Cg

    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 :
    Code :
     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, &amp;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 :
    Code :
     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 ?

  2. #2
    Intern Contributor
    Join Date
    Jun 2003
    Location
    Burlington VT US
    Posts
    53

    Re: Floating Point textures in Cg

    are using a pBuffer with WGL_FLOAT_COMPONENTS_NV and 32bit depth per channel etc? Otherwise it won't work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •