PDA

View Full Version : Sky box (I know, I know)



Punchey
03-12-2002, 12:34 PM
Okay, I know everyone says the way to get rid of the border lines in a skybox is to do a:
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

Or you can substitute GL_CLAMP for CL_CLAMP_TO_EDGE. Either way, it doesn't work for me. Anybody got any other ideas? Thanks!

Humus
03-12-2002, 01:00 PM
You must use GL_CLAMP_TO_EDGE. GL_CLAMP will clamp to border color instead.

zeckensack
03-12-2002, 01:37 PM
I heard it through the grapvine that NVidia hardware up to and including the Geforce2 series can't do that particular clamp mode. GF3 is fine though.

Enbar
03-12-2002, 01:59 PM
Actually, through Geforce2 can't do GL_CLAMP (GL_CLAMP_TO_EDGE is substituted). And the Geforce3 has the wrong behavior by default (you need to set a registry flag to get correct behavior).

Punchey
03-12-2002, 07:31 PM
Okay, guys. Whether GL_CLAMP or GL_CLAMP_TO_EDGE is needed doesn't matter because my point is, NEITHER work. I've tested it on both a GF2 and a Matrox G450. So does anybody have any ideas OTHER than GL_CLAMP*?

DFrey
03-12-2002, 07:36 PM
Just to be certain, you are disabling lighting when drawing the sky box, correct?

vincoof
03-13-2002, 01:55 AM
Don't use mipmaps http://www.opengl.org/discussion_boards/ubb/smile.gif

Punchey
03-13-2002, 06:10 AM
Yes, lighting is off and I'm not using mipmaps.

And I call the two above listed lines of code before calling my texture loading function.

DFrey
03-13-2002, 06:22 AM
Are you using a cube for the sky box? If so, are you certain the textures you are using each have a 90 degree FOV?

Punchey
03-13-2002, 08:04 AM
Yes, I'm sure. I'm using the same standard skybox textures that many others have used with success.

DFrey
03-13-2002, 08:14 AM
Can you upload it (example executable or source)? Might make it easier for others to see what's wrong.

pleopard
03-13-2002, 02:08 PM
Dont have much time but consider using something like the following code snip. My skyboxes are completely seamless.




//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Render this instance.

void MgSkyBox::render()
{
e_StateManager.enable(GL_TEXTURE_2D);
e_StateManager.disable(GL_LIGHTING);
e_StateManager.enable(GL_TEXTURE_CUBE_MAP_ARB);
// e_StateManager.disable(GL_DEPTH_TEST);

glDepthMask(FALSE);
glPushMatrix();
glScalef(m_Dimensions[0],m_Dimensions[1],m_Dimensions[2]);
DrawTexturedCube(m_Textures);
glPopMatrix();
glDepthMask(TRUE);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Set the texture objects and apply the necessary properties to each (order
// is Top, Bottom, Right, Left, Front, Back

void MgSkyBox::setTextures(long textureIndices[6])
{
memcpy(m_Textures,textureIndices,sizeof(long)*6);

// Detect the GL_EXT_texture_edge_clamp extension and use it if present
int clampMode;

if (IsOpenGlExtensionSupported("GL_EXT_texture_edge_clamp"))
{
clampMode = GL_CLAMP_TO_EDGE;
}
else
{
clampMode = GL_CLAMP;
}
for (int i=0; i<6; ++i)
{
glBindTexture(GL_TEXTURE_2D,m_Textures[i]);
glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_RE PLACE);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,cl ampMode);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,cl ampMode);
}
}

vincoof
03-14-2002, 02:40 AM
Maybe you can try GL_CLAMP_TO_BORDER

Punchey
03-14-2002, 05:44 AM
vincoof, I'll give it a shot. Would you happen to have the enum value for that? Thanks.

vincoof
03-15-2002, 03:13 AM
#define GL_CLAMP_TO_EDGE 0x812F
#define GL_CLAMP_TO_EDGE_SGIS 0x812F

#define GL_CLAMP_TO_BORDER_SGIS 0x812D
#define GL_CLAMP_TO_BORDER_ARB 0x812D

Note that you have to support the extension GL_ARB_texture_border_clamp or GL_SGIS_texture_border_clamp, which is supported by GeForce3+ and Radeon8500 and a few other cards.