Game Development Community

Better control of Detailmapping

by Paul Ash · in Torque Game Engine · 07/16/2007 (12:37 pm) · 2 replies

Hello everyone im trying to find an easy way to collect the texture size of the texture the detail mapping is being applied to so i can make the detail map the same size as the texture it is being applied to thanks.

void sgDetailMapping::sgEnableDetailMapping(void *buffer, U32 elementsize)
{
if(!LightManager::sgAllowDetailMaps())
return;

const F32 scale[16] = {4.0, 0.0, 0.0, 0.0, //I understand this is the scale setting for the
0.0, 4.0, 0.0, 0.0, //detail map, i just need the best way to collect the size 0.0, 0.0, 4.0, 0.0, //of what its being applied too
0.0, 0.0, 0.0, 1.0};

const F32 scaleX4[16] = {8.0, 0.0, 0.0, 0.0,
0.0, 8.0, 0.0, 0.0,
0.0, 0.0, 8.0, 0.0,
0.0, 0.0, 0.0, 1.0};

glActiveTextureARB(GL_TEXTURE2_ARB);
glEnable(GL_TEXTURE_2D);
LightManager::sgSetupExposureRendering();
glMatrixMode(GL_TEXTURE);
glPushMatrix();
glMultMatrixf(scale);

glActiveTextureARB(GL_TEXTURE3_ARB);
//glDisable(GL_TEXTURE_2D);
glEnable(GL_TEXTURE_2D);
LightManager::sgSetupExposureRendering();
glMatrixMode(GL_TEXTURE);
glPushMatrix();
glMultMatrixf(scaleX4);

glActiveTextureARB(GL_TEXTURE0_ARB);

glClientActiveTextureARB(GL_TEXTURE2_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, elementsize, buffer);

glClientActiveTextureARB(GL_TEXTURE3_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, elementsize, buffer);

glClientActiveTextureARB(GL_TEXTURE0_ARB);
}

#1
07/18/2007 (11:58 am)
You'll want to set the scale to:

{1.0, 0.0, 0.0, 0.0,
 0.0, 1.0, 0.0, 0.0,
 0.0, 0.0, 1.0, 0.0,
 0.0, 0.0, 0.0, 1.0};

but setting the detail texture to the same size as the diffuse defeats the purpose of detail mapping - why not just add the detail into the diffuse?

Edit: Oh, you'll also need to comment out the code setting up GL_TEXTURE3_ARB.
#2
07/20/2007 (5:11 am)
Yeah, i already figured it out, and marked this for being deleted and they never removed it.