Lines at joining of textures in skybox

Started by
6 comments, last by ade-the-heat 19 years, 4 months ago
Hi, I implemented a skybox but I seem to get lines on the edges where the 2 textures meet. It happens occasionally but its visible. I have a screenshot to show exactly what I mean here http://gautam.digitalthinker.org/Screenshots/skyboxshot.png This is how I am rendering the skybox

	float matrix[16];
	
	glGetFloatv(GL_MODELVIEW_MATRIX, matrix);
	matrix[12] = 0;
	matrix[13] = 0;
	matrix[14] = 0;

	glPushMatrix();
	glLoadMatrixf(matrix);
	glBindTexture(GL_TEXTURE_2D, texture[FRONT]);
	
	glBegin(GL_QUADS);
		glTexCoord2f(0, 0); glVertex3f(-100,   100, -100);
		glTexCoord2f(0, 1); glVertex3f(-100,  -100, -100);
		glTexCoord2f(1, 1); glVertex3f( 100,  -100, -100);
		glTexCoord2f(1, 0); glVertex3f( 100,   100, -100);
	glEnd();
		
	glBindTexture(GL_TEXTURE_2D, texture);
	glBegin(GL_QUADS);
		glTexCoord2f(0, 0); glVertex3f(100,  100, -100);
		glTexCoord2f(0, 1); glVertex3f(100, -100, -100);
		glTexCoord2f(1, 1); glVertex3f(100, -100,  100);
		glTexCoord2f(1, 0); glVertex3f(100,  100,  100);
	glEnd();
	
	glBindTexture(GL_TEXTURE_2D, texture);
	glBegin(GL_QUADS);
		glTexCoord2f(0, 0); glVertex3f(-100,  100,  100);
		glTexCoord2f(0, 1); glVertex3f(-100, -100,  100);
		glTexCoord2f(1, 1); glVertex3f(-100, -100, -100);
		glTexCoord2f(1, 0); glVertex3f(-100,  100, -100);
	glEnd();

	glBindTexture(GL_TEXTURE_2D, texture[BACK]);
	glBegin(GL_QUADS);
		glTexCoord2f(1, 0); glVertex3f(-100,  100,  100);
		glTexCoord2f(0, 0); glVertex3f( 100,  100,  100);
		glTexCoord2f(0, 1); glVertex3f( 100, -100,  100);
		glTexCoord2f(1, 1); glVertex3f(-100, -100,  100);
	glEnd();

	glBindTexture(GL_TEXTURE_2D, texture[UP]);
	glBegin(GL_QUADS);
		glTexCoord2f(0, 0); glVertex3f(-100,  100,  100);
		glTexCoord2f(0, 1); glVertex3f(-100,  100, -100);
		glTexCoord2f(1, 1); glVertex3f( 100,  100, -100);
		glTexCoord2f(1, 0); glVertex3f( 100,  100,  100);
	glEnd();

	glBindTexture(GL_TEXTURE_2D, texture[DOWN]);
	glBegin(GL_QUADS);
		glTexCoord2f(0, 0); glVertex3f(-100,  -100, -100);
		glTexCoord2f(0, 1); glVertex3f(-100,  -100,  100);
		glTexCoord2f(1, 1); glVertex3f( 100,  -100,  100);
		glTexCoord2f(1, 0); glVertex3f( 100,  -100,  -100);
	glEnd();

	glPopMatrix();


Any idea as to how to remove the seam/lines ? Thanks
The more applications I write, more I find out how less I know
Advertisement
Try GL_CLAMP_TO_EDGE as wrap mode for all textures.
I tried using GL_CLAMP_TO_EDGE but it had no effect. I am using ilutGLLoadImage from DevIL - I am not sure if that might have anything to do with it. It shouldn't though in my opinion.

However I will try with removing the ilut part and use the il and ilu functions and do the rest in opengl code and post back.
The more applications I write, more I find out how less I know
I think it doesnt matter what you use for loading the images.
Just do:

glBindTexture(GL_TEXTURE_2D,MyTexture);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);


Or if that doesnt work... well, then I suppose your video card doesnt support it, although thats possible only on some VERY old cards (I remember my Voodoo3 didnt support it, hehe :) ) Maybe it could be a driver issue if your video card is up to date, dunno, but that should work.
"A screen buffer is worth a thousand char's" - me
Hi,

I thought this had to be done only once -
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

I did it after every call to
glBindTexture(...)

and now it works - thanks.


The more applications I write, more I find out how less I know
I did say for ALL textures, didn't I?
Glad it worked :)
Actually you dont have to do it after every glBindTexture(); The way I understand this works is that every texture has variables to store the GL_TEXTURE_WRAP_S and GL_TEXTURE_WRAP_T and some other parametres. And You can change them using glTexParameteri when the texture is bound using glBindTexture and the variables keep that in memory. So if you set that for each texture during loading time you dont have to do that when rendering. Unless of course you want to use the same texture with different parametres in the rendering.
"A screen buffer is worth a thousand char's" - me
Hi, I think I know what the problem is.
Try this before drawing it as this works fine for me:

glDepthMask(GL_FALSE); //don't write to depth buffer
glDisable(GL_LIGHTING); //so join between box isn't seen

cheers

If it works rate me up please !!

Ade

This topic is closed to new replies.

Advertisement