Brightening a texture

I’d like to apply a multiplier to every texel of a texture while displaying it on a 2D rectangle. This would be trivial if I used a fragment program, but I’m trying to do this with minimal OpenGL extension support.

It seems to me that I could just use the ambient light to achieve this if the texture property is GL_MODULATE. However, I haven’t yet gotten it working, which leads me to suspect I’m forgetting some glEnable() or missing some other obscure setting.

Here’s what I’m doing now:

// init time


    float ambient[] = {1.0f, 1.0f, 1.0f, 1.0f};
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    // Allocate the texture
    glGenTextures(1,&e->projection.texhandle);
    glBindTexture(GL_TEXTURE_RECTANGLE_ARB, e->projection.texhandle);
    glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP);
    glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP);
    glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_INTENSITY8,
                 e->width, e->height, 0,
                 GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
    glEnable(GL_TEXTURE_RECTANGLE_ARB);
    // Setup lighting
    glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient);
    glEnable(GL_LIGHTING);

    // Setup display list
    e->projection.dlisthandle = glGenLists(1);
    glNewList(e->projection.dlisthandle, GL_COMPILE);
    glBindTexture(GL_TEXTURE_RECTANGLE_ARB,e->projection.texhandle);
    glColor4d(1.0,1.0,1.0,1.0);
    glBegin(GL_QUADS);
        glTexCoord2d(0,0);
        glVertex2d(0,0);
        glTexCoord2d(e->width,0);
        glVertex2d(e->width,0);
        glTexCoord2d(e->width,e->height);
        glVertex2d(e->width,e->height);
        glTexCoord2d(0,e->height);
        glVertex2d(0,e->height);
    glEnd();
    glEndList();

// render


      float ambient[] = {e->projection.intensity, e->projection.intensity, e->projection.intensity, 1.0};
      glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient);
      glCallList(e->projection.dlisthandle);

I’m seeing the image, but it isn’t being brightened appropriately.

Any ideas?

Okay, I figured out that I don’t really need to use lighting----just setting the glColor() will allow me to control the texture intensity.

Well, it will let me dim the texture intensity. However, I want to brighten it.

This means I don’t want the glColor() to be clamped to (0,1) before the texture modulation. (I don’t care if it’s clamped afterwords). Anyone know how to arrange this?

Using ClampColorARB() might work, but I’m not sure if that extension will always be available.

For simple things like x2 intensity, draw the texture twice (or better, use multitexture) in additive blending mode.
It may also work with *1.3 with first time with 1.0 color and second time with 0.3 color.

Indeed this would be trivial with a shader :slight_smile:

I actually had stumbled on the “multiple render additive blending” option, but the fractional blending and multitexture avenues didn’t occur to me. Thanks, I’ll check them out.