Skip to main content
gamedev.net
🔒 Locked

Create good looking skyboxes

Started by X5-Programmer Jul 2, 2004 at 7:59 PM 4 replies 700+ views
Original Post
X5-Programmer
X5-Programmer
Hi, I will try to make an skybox engine but were can i find some information about skyboxes and how to blend them so thay look real. can you guys point me somewere.. thx.
-[ thx ]-
Eddie Zehoo
Eddie Zehoo
You may already know this, but take a look at Terragen : http://www.planetside.co.uk/terragen/
It's a pretty good tool to make greatlooking skyboxes

Regards

00000100-00100011-10000000
X5-Programmer
X5-Programmer
ok thanks, but when i draw the skyboxes only 3 sides shows why does not the 3 about shows?

but when i have glCullFace(GL_BACK); the ohter 3 shows and not the first 3

dont know why.. someone help me
-[ thx ]-
CraZeE
CraZeE
i think it is the way u order ur vertices. by default, to render a face, the normal must face the general direction of the camera. this means u must draw the vertices in anti-clockwise for a triangle that faces the camera to be rendered correctly.

to render the 6 faces of the skybox, u must make sure all faces are drawn relative to the center of the box. not sure how best to explain this, but imagine the box is unwrapped. u'll have a T-shaped collection of 6 faces. visualize drawing each face in this state in a coutner-clockwise direction. so when u actually render the real skybox, the order of the vertices must adhere to this so as to make sure all normals face the INSIDE of the box.
in ur case, 3 are probably facing inside correctly, the other 3 are reversed.
To learn, we share... Give some to take some -
X5-Programmer
X5-Programmer
Okay, I have try but I cant fix it :\ here is the code.

Sky=glGenLists(1);	glNewList(Sky,GL_COMPILE);		GLfloat LightPosition[]={0.0,0.0,1500.0}; //...Position of the light...		GLfloat LightColor[]={1,1,1,1};		glCullFace(GL_BACK);		glClearColor(0,0,0,0);		glEnable(GL_NORMALIZE);		glDisable(GL_FOG);				//...The transparency function...		glBlendFunc( GL_SRC_COLOR, GL_DST_COLOR );		//...Putting the light...		glLightfv(GL_LIGHT0,GL_DIFFUSE,LightColor);		glLightfv(GL_LIGHT0,GL_POSITION,LightPosition);		glEnable(GL_LIGHT0);		glEnable(GL_LIGHTING);		glEnable(GL_TEXTURE_2D);		glBindTexture(GL_TEXTURE_2D, g_Texture[BACK_ID]);		// Start drawing the side as a QUAD		glBegin(GL_QUADS);								// Assign the texture coordinates and vertices for the BACK Side			glTexCoord2f(0.0f, 0.0f); glVertex3f(x,			y,			z);			glTexCoord2f(0.0f, 1.0f); glVertex3f(x,			y + height, z);			glTexCoord2f(1.0f, 1.0f); glVertex3f(x + width, y + height, z); 			glTexCoord2f(1.0f, 0.0f); glVertex3f(x + width, y,			z);		glEnd();				// Bind the LEFT texture of the sky map to the LEFT side of the box		glBindTexture(GL_TEXTURE_2D, g_Texture[LEFT_ID]);				// Start drawing the side as a QUAD		glBegin(GL_QUADS);								// Assign the texture coordinates and vertices for the LEFT Side			glTexCoord2f(1.0f, 0.0f); glVertex3f(x,			y,			z);			glTexCoord2f(0.0f, 0.0f); glVertex3f(x,			y,			z + length);			glTexCoord2f(0.0f, 1.0f); glVertex3f(x,			y + height,	z + length); 			glTexCoord2f(1.0f, 1.0f); glVertex3f(x,			y + height,	z);		glEnd();						// Bind the FRONT texture of the sky map to the FRONT side of the box		glBindTexture(GL_TEXTURE_2D, g_Texture[FRONT_ID]);		// Start drawing the side as a QUAD		glBegin(GL_QUADS);						// Assign the texture coordinates and vertices for the FRONT Side			glTexCoord2f(1.0f, 0.0f); glVertex3f(x,			y,			z + length);			glTexCoord2f(1.0f, 1.0f); glVertex3f(x,			y + height, z + length);			glTexCoord2f(0.0f, 1.0f); glVertex3f(x + width, y + height, z + length); 			glTexCoord2f(0.0f, 0.0f); glVertex3f(x + width, y,			z + length);		glEnd();		// Bind the RIGHT texture of the sky map to the RIGHT side of the box		glBindTexture(GL_TEXTURE_2D, g_Texture[RIGHT_ID]);				// Start drawing the side as a QUAD		glBegin(GL_QUADS);					// Assign the texture coordinates and vertices for the RIGHT Side			glTexCoord2f(0.0f, 0.0f); glVertex3f(x + width, y,			z);			glTexCoord2f(1.0f, 0.0f); glVertex3f(x + width, y,			z + length);			glTexCoord2f(1.0f, 1.0f); glVertex3f(x + width, y + height,	z + length); 			glTexCoord2f(0.0f, 1.0f); glVertex3f(x + width, y + height,	z);		glEnd();				// Bind the TOP texture of the sky map to the TOP side of the box		glBindTexture(GL_TEXTURE_2D, g_Texture[TOP_ID]);		// Start drawing the side as a QUAD		glBegin(GL_QUADS);								// Assign the texture coordinates and vertices for the TOP Side			glTexCoord2f(1.0f, 1.0f); glVertex3f(x,			y + height,	z);			glTexCoord2f(1.0f, 0.0f); glVertex3f(x,			y + height,	z + length);			glTexCoord2f(0.0f, 0.0f); glVertex3f(x + width, y + height, z + length); 			glTexCoord2f(0.0f, 1.0f); glVertex3f(x + width, y + height, z);		glEnd();		// Bind the BOTTOM texture of the sky map to the BOTTOM side of the box		glBindTexture(GL_TEXTURE_2D, g_Texture[BOTTOM_ID]);		// Start drawing the side as a QUAD		glBegin(GL_QUADS);								// Assign the texture coordinates and vertices for the TOP Side			glTexCoord2f(1.0f, 0.0f); glVertex3f(x,			y,			z);			glTexCoord2f(1.0f, 1.0f); glVertex3f(x,			y,			z + length);			glTexCoord2f(0.0f, 1.0f); glVertex3f(x + width, y,			z + length); 			glTexCoord2f(0.0f, 0.0f); glVertex3f(x + width, y,			z);		glEnd();		glEnable(GL_FOG);		glCullFace(GL_FRONT);	glEndList();
-[ thx ]-
Trienco
Trienco
if thats the code after his suggestion you either didnt understand or didnt try. you CANT draw the right quad in the same order as the left quad and expect them to face different ways. cull the backfaces and reverse the order for the missing quads.
f@dzhttp://festini.device-zero.de

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.