Advertisement

3 texture units in 2

Started by June 01, 2004 11:21 AM
1 comment, last by python_regious 20 years, 5 months ago
I first saw this on Serious Sam(first or second encounter... don`t remember). And now it`s fairly used in games like Unreal and the like. Basicly we have a diffuse map, a detail map, and a lightmap. After seeing what the env_combine funcs can do, I came up with the idea for that 1 texture unit->Base Map*Detail Map(actually I use the GL_INTERPOLATE_ARB, but can`t figure out where to best put the Detail Map) 2 texture unit->LightMap This is what I use for that stuff ->

//

         glActiveTextureARB(GL_TEXTURE0_ARB);
//

glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE_ARB);
    glTexEnvi(GL_TEXTURE_ENV,GL_COMBINE_RGB_ARB,GL_INTERPOLATE_ARB);//

                                          // now setup Arg0

    glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE0_RGB_ARB,GL_TEXTURE);
    glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND0_RGB_ARB,GL_SRC_ALPHA);
                                          // now setup Arg1

	glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE1_RGB_ARB,GL_TEXTURE);
    glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND1_RGB_ARB,GL_SRC_COLOR);

	glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE2_RGB_ARB,GL_PREVIOUS);
    glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND2_RGB_ARB,GL_SRC_COLOR);
//	

	glActiveTextureARB(GL_TEXTURE1_ARB);
//

	glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE_ARB);
    glTexEnvi(GL_TEXTURE_ENV,GL_COMBINE_RGB_ARB,GL_MODULATE);
                                           // now setup Arg0

    glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE0_RGB_ARB,GL_PREVIOUS);
    glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND0_RGB_ARB,GL_SRC_COLOR);
                                          // now setup Arg1

	glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE1_RGB_ARB,GL_TEXTURE);
    glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND1_RGB_ARB,GL_SRC_COLOR);
My problem is-> If I`d normally use 3 texture units to make this stuff(and I wouldn`t bother anymore), everything would be just fine, but this way I won`t be able(or don`t know how to) scale the alpha map(which is the Detail Map), any help would be apreciated Edit:To clarify-> I mean I can`t use the

glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glScalef(size,size,size);
glMatrixMode(GL_MODELVIEW);
to show detail upclose [edited by - cippyboy on June 1, 2004 12:33:48 PM]

Relative Games - My apps

Try this and see if it works:

 glBindTexture(TextureID); glActiveTextureARB(GL_TEXTURE1_ARB); glEnable(GL_TEXTURE_2D); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2); glBindTexture(DetailTextureID); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glScalef(DetailLevel, DetailLevel, 1); glMatrixMode(GL_MODELVIEW);
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
Advertisement
Do you mean that you have the detail texture in the alpha channel of the diffuse texture?
If at first you don't succeed, redefine success.

This topic is closed to new replies.

Advertisement