Feature 4 Post Mortem

Adding a skybox to my scene was one of the simpler tasks I’ve done, although I had a couple problems. One was purely a human mistake, and the other I can’t really explain but I eventually worked around it.

To start, I created a cube obj and a cube_map texture and linked them together with shaders like those in Dr. Johnson’s video.

Then came the time to load my images in. I found a T-shaped skybox texture online and cut it up into separate 256 x 256 images in Gimp. When I loaded my scene, there were white borders between the images, making it look very box-y and unrealistic. I searched online for a solution, and tried calling glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS). This didn’t work, so I figured my images had white borders around them. I checked the ppm’s and did indeed find quite a few 255 values in a row. After this I tried a lot of things, including but not limited to:

– cutting out 254 x 254 images and using those

– cutting out 254 x 254 images and scaling them up to 256 x 256

– cutting out 254 x 254 images and scaling them up to 512 x 512

…and a few other things as well. These methods caused my skybox to be either distorted or bordered, so I gave up this particular skybox texture and found a new one consisting of 5 individual images. This caused the borders to disappear, but now my skybox didn’t have a bottom. I pieced together a bottom picture out of portions of the other five images, which matches the colors but does stand out if one focuses on the bottom. I figured this was about the best I could do, so I called it a day.

The rest of the skybox looks great, and the bottom can only be seen if one stands near the edge of the terrain and looks down. To help make this difficult, I added a feature to my camera that allows one to toggle whether or not the camera can move off the terrain. If the bool is toggled to false, the camera will reset the from position to the old position if the new one would have been off the terrain. It was actually a quick, easy fix I was able to figure out on my first try.

The only other issue I had was forgetting to set the projection matrix uniform in the skybox shader, causing my skybox’s position to be multiplied by 0 and not appear. This took me a while to realize, but eventually I fixed it.

And here is a video of my skybox.



Leave a Reply

Your email address will not be published. Required fields are marked *