Daily news, dev blogs, and stories from Game Developer straight to your inbox
December 20, 2023
3 Min Read
After deciding I did not have enough time to implement ray tracing I decided to create a system for skyboxes to be put into the game. My implementation was fraught with issues. The most recommended way of tackling skyboxes I could find was using cubemaps.there is also a good tutorial posted by learnopengl.com here LearnOpenGL - Cubemaps. The other good thing about cubemaps is that they allow for easy reflections by inputting the cube sampler type into a glsl shader. I tried really hard to get cubemaps to work, but the “best” output I could get were the following.
The one on the left was me forgetting that .png and .jpg textures have different amounts of channels. Even after I fixed the issue with the failed render the issues of the skybox only being a plane that moved around in the look direction of the camera persisted.
I decided that I was done with cubemaps and decided to start creating a skybox through the frameworks I had already created.
Hacking together a skybox:
The first extremely important thing to note when creating a skybox is that the geometry you draw needs to be drawn with the depth mask disabled.
As you can see in the image above, I created a function that helps me draw the planes needed for the first implementation by drawing 6 separate planes and different rotations and translations.
It looks extremely trippy when you are able to move your camera through where the skybox is being drawn so I decided I needed to scale it up. I was also still using the brick texture, so I did some searching and found a space skybox generator to get some new textures.
It was starting to look better, especially with the texture change, but the skybox is not centered on the camera position and doesn’t move along with the camera position. I thought it would be as easy as adding the Vector into the original translations, but it did not seem to enjoy that solution. I had multiple times that it was moving towards the camera at a faster speed or moving down while the camera was moving up so it just took some time for me to figure out what the correct additions were. I ended up with the following.
The only real problem I have with my implementation is that the creation of reflections is much harder without the use of the cubemap. I ended up spending around 3 hours on trying to get reflections to work after finishing the skybox. I was plagued with compiler errors for the shaders I was trying to create and eventually decided that if reflections were something I wanted to eventually explore I could revisit what I had worked on this week in the future.
Read more about:Blogs
You May Also Like
Accessibility and fancy footwork with GLYDR's John Warren - Game Developer Podcast ep. 40Feb 28, 2024
Exploring the 2024 State of the Game Industry report - Game Developer Podcast ep. 39Feb 2, 2024
Phantom inspiration and the ethical auteur with Xalavier Nelson Jr.Dec 8, 2023
Designing Killer Queen: from playground experiment to modern arcade sensationOct 18, 2023
Get daily news, dev blogs, and stories from Game Developer straight to your inbox
Subscribe to Game Developer Newsletters to stay caught up with the latest news, design insights, marketing tips, and more