-
1 Attachment(s)
openGL skybox help
I am currently doing a skybox for a living room using openGL with c++. All my codes are ready expect for the picture of the living room that I want to divide into 5 parts to make a skybox. I know how to use the photoshop to divide the image expect that I am not sure how to divide the image such that the skybox and the length are perfect. Anyway I am doing the skybox sides for a square cube skybox where there are front, left, right, top and bottom facing skybox. I do not have the sides for the backfacing as I am going to create that part for myself without skybox. So, my skybox would have 5 sides.
So, how should I divide the image into 5 parts. Currently i divide my image such as like this. My left, front, right facing has definitely no problem expect the top and bottom facing where the image looks strectched. So, likes how should I divide the image to fit the skybox.
__________________
|top |
|________________|
| | | |
| | | |
|left|front| right |
|___|___ |_______ |
|bottom |
__________________
Code:
//front
glBindTexture(GL_TEXTURE_2D, texture[FRONT].id);
glBegin(GL_QUADS);
glTexCoord2f(0,1);glVertex3f(100, 100, 100);
glTexCoord2f(1,1);glVertex3f(-100, 100, 100);
glTexCoord2f(1,0);glVertex3f(-100, -100, 100);
glTexCoord2f(0,0);glVertex3f(100,-100, 100);
glEnd();
//left
glBindTexture(GL_TEXTURE_2D, texture[LEFT].id);
glBegin(GL_QUADS);
glTexCoord2f(1,1);glVertex3f(100, 100, 100); //0, 1
glTexCoord2f(1,0);glVertex3f(100, -100, 100); //0, 0
glTexCoord2f(0,0);glVertex3f(100, -100, -100); //1, 0
glTexCoord2f(0,1);glVertex3f(100, 100, -100); //1, 1
glEnd();
//right
glBindTexture(GL_TEXTURE_2D, texture[RIGHT].id);
glBegin(GL_QUADS);
glTexCoord2f(0,1);glVertex3f(-100, 100, 100);
glTexCoord2f(0,0);glVertex3f(-100, -100, 100);
glTexCoord2f(1,0);glVertex3f(-100, -100, -100);
glTexCoord2f(1,1);glVertex3f(-100, 100, -100);
glEnd();
//top
glBindTexture(GL_TEXTURE_2D, texture[TOP].id);
glBegin(GL_QUADS);
glTexCoord2f(0,0);glVertex3f(100, 100, 100); //0, 0
glTexCoord2f(1,0);glVertex3f(-100, 100, 100);//1, 0
glTexCoord2f(1,1);glVertex3f(-100, 100, -100);//1, 1
glTexCoord2f(0,1);glVertex3f(100, 100, -100);//0, 1
glEnd();
//bottom
glBindTexture(GL_TEXTURE_2D, texture[BOTTOM].id);
glBegin(GL_QUADS);
glTexCoord2f(1,0);glVertex3f(100, -100, 100);
glTexCoord2f(1,1);glVertex3f(-100, -100, 100);
glTexCoord2f(0,1);glVertex3f(-100, -100, -100);
glTexCoord2f(0,0);glVertex3f(100, -100, -100);
glEnd();
This is my part of c++ code. All my codes are correct and what I am doing is a square skybox.
I'm not asking for help the c++ code expect the image where how should I cut into 5 parts of skybox.
-
You need 6 images for the skybox to work. There is no way to get the top and bottom images from that image.
-
No, i am doing 5 images only. The back part, i'm going to create my own skybox using openGL drawings instead of the images.
-
You still need multiple images; you're basically making a panorama. There is a free tool called Hugin that can stitch the photos together for you, that's what I use (but I don't have Photoshop... use whichever). To do the skybox you need to
-Make a 360 degree panorama
-Get 90 degree FOV rectilinear projections for each face of the cube you want to texture, and then you end up with something like this.