Skybox in Sketchfab
How to add a skybox / panorama/ Equirectangular Sphere Mesh to your Sketchfab scene.
I recently uploaded some scenes to sketchfab with skyboxes. Since some people asked how to do the same, here is a quick guide.
You can see an example of this on one of my sketchfab meshes, a peak in south tyrol: https://skfb.ly/6TUZv
There is an official sketchfab blog on how to add a skybox, however I find the shape of that skybox abit weird and doesnt look good with panos: https://sketchfab.com/blogs/community/how-to-add-a-skybox-to-your-model/
Here are the general steps to get your pano in your sketfab scene:
- create an equirectangular Sphere Mesh
- Import it in 3D software (blender) and align it to your scene
- upload it with your mesh to Sketchfab
- In the 3D settings editor, assign the pano to the sphere mesh and turn it to single sided rendering
I will now explain the above in more details.
A skybox in games is usually a mesh rendered far in the background with a texture on it. This could be a cube or a sphere. It has two special properties:
- The mesh is treated as if it as far away as possible from the camera
- The mesh is glued to the camera, meaning when you move the camera around, it moves with it. This does not apply to rotation, it has a fixed rotation.
The goal would be to have something similar in your Sketchfab scene. Since Sketchfab (very regrettably) does not expose a shader API, it is impossible to get these two properties exactly in the scene. So if you zoom out with your camera, you will see that it is a actually a sphere.
However within a reasonable area, the illusion of a skybox is convincing.
Equirectangular Sphere Mesh
First step is to get this sphere mesh. In game engines, the equirectangular mapping is usually done in shader, that way the uv can be unwrapped in specific ways to aid stuff like procedural skybox and sampling clouds etc. Again there is no shader API in Sketchfab (please add some, please!), we have to unwrap the mesh in a way that our pano would work on it.
I have already gone a head and done that. You can find an equirectangular Sphere Mesh in this repository:
Just grab the FBX file in there and you are good to go. If for whatever reason you want to unwrap/ create one yourself, here is a good video to get you started, make sure you invert the normals so that they are pointing in, since that is how we want to render the mesh:
Aligning to your scene
I am doing this step in Blender, you can do it in any software. After you imported your mesh/ scene you wish to put on your sketchfab in Blender, import the skybox mesh too. Then on the skybox mesh material, assign your pano as a image texture to a emissive or unlint shader. Position the skybox mesh so that the scene is in the center and rotate it around the up axis until your enviroment aligns with your scene. I sometimes even move the skybox a bit up and down, depending on if I made the pano with a drone or with my phone, until they visually match. Then export the skybox mesh together with your scene and upload them to sketchfab with your pano texture.
If you dont know how to do any of the above, then refer to the documentation of your 3D software of choice.
Sketchfab 3D settings
In sketchfab, go to your scenes 3D settings. In the Materials tabs, from the drop menu, find material of your skybox mesh. If you are using the mesh I made, this would be called Material.001.
Once you select that material, you need to link it with your pano texture, which you have also uploaded to sketchfab. Go on to your base color, click on the image icon, and under Manage Textures, click on the drop menu and choose the pano you uploaded.
If you already correctly linked the pano texture with the skybox material in your 3D software, sketchfab will automatically do the linking.
Last step is to turn off double sided rendering. Your sphere should have normals pointing in, otherwise you will get wrong rendering. To do this, on the same material tab, click on Face Rendering and then Single Sided.
Actually do yourself a favour and do this for all your materials, unless you need it otherwise. I have no idea why this is not default behaviour in sketchfab. Single sided rendering will save you some performance.
Also turn off other stuff you dont need like emission etc. If you dont need them.
That was all. Looking forward to awesome skybox integration in Sketchfab.