Decimation (reducing polygons)
Decimating a model means reducing its size by reducing the number of polygons in its mesh. This makes the 3D model file size smaller as well as reducing the amount of work that your GPU needs to do to render the model, improving performance.
All-in-one VR headsets i.e. Oculus Quest generally cannot render as many polygons as most modern computers and mobile phones. We advise testing performance with any models with greater than 50,000 polygons on a VR headset. One sign that too many polygons are being rendered is that your view in VR becomes shaky and unstable.
Texture Size
Spatial currently does not enforce any maximum texture size. Generally you want to use the smallest power-of-two (eg. 512x512, 1024x1024, 2048x2048) texture size that looks acceptable visually. If you have too many textures or your textures are too large Spatial may run out of memory on low end mobile phones or VR headsets.
How to Decimate a 3D Model
Method 1: gltfpack (meshoptimizer)
1. Download the open-source program gltfpack
2. Run it on the command line like so:
gltfpack -si 0.2 -i input.glb -o output.glb
The number after -si is how much it tries to reduce it by (i.e. 0.2 = 20% of the original, i.e. a 80% reduction). Try a few different values and evaluate the resulting models.
This method is usually the fastest and most automated way to decimate a model, but does not give you a lot of control over the results.
Method 2: Blender
In Blender:
- Open your GLB in Blender (delete the default cube first)
- Click through the model hierarchy on the right till you see a green mesh icon, select the "parent" (one above the green), go to object mode & select all, CTRL J (while mouse in the 3d View) to join all the bits
- Below green icon push CTRL B to select the rest of the hierarchy and click delete hierarchy
- Then Go to Edit mode > Mesh > Merge by distance - the larger the distance the smaller you are making the model but watch out for distortion
- Zoom in on detailed areas and merge there to simplify further
- Export as GLB
(Blender is a free 3D computer graphics software)
Removing unnecessary objects or vertices manually is another good way of reducing polygons.
Reduce object count
- This is the most important for performance.
- Import your model in Blender.
- Press F3 and type ‘select linked material’ and click. (Keyboard shortcut is Shift+L)
- Objects that have the same material are selected.
- Press F3 and type ‘join’ and click. (Keyboard shortcut is Control+J)
- Repeat 2~4 until the objects are merged by material.
Reduce vertex count
- This is important to reduce file size and improve performance.
- Select an object that you want to reduce vertex count.
- Merge vertices. (This could cause smoothen edges)
2-1. Go to ‘Edit Mode’ by pressing the ‘tab’ key. (Or clicking ‘Object Mode’ box on the left-top)
2-2. Press ‘1’ to vertex mode and ‘A’ to select all vertices.
2-3. Press F3 and type ‘merge by distance’ and click. (Keyboard shortcut is M and select ‘By Distance’)
2-3. Press ‘tab’ again to go back to the ‘Object Mode’. - Reduce vertex count using Decimate Modifier.
3-1. Go to ‘Modifier Property’ on the right menu.
3-2. Click ‘Add Modifier’ and select ‘Decimate’.
3-3. Change ‘Ratio’ number like 0.5.
3-4. Hover your mouse cursor on the modifier and press ‘Ctrl+A’ to apply it. - Repeat 1~3 until you reduce vertices of all objects.
Reducing Texture Size
Method 1: gltf-transform (command line)
1. Download the opensource program gltf-transform.
2. Reduce the size of the textures by running:
gltf-transform resize --width 1024 --height 1024 input.glb output.glb
Method 2: Manual resizing
- First using Photoshop or gimp, reduce your file size.
- Go into textures - reduce the size of the images one by one (don't go too small)
- After you scale down, override for each image.
- If you can use Blender, save textures .jpg instead of png, tiff or tga to reduce the size and replace textures.
- Use GLtf to GLB Packer https://glb-packer.glitch.me/ - which compresses all the things into one file
Progressive Environment Loading - Explained
Supplemental information to expand your Spatial knowledge.
When you first join a space, if necessary, Spatial will load the environment model and skybox at a lower resolution intially until you fully load the space. Then the model and skybox will appear in its full resolution. This often happens very fast at the beginning when you join a space. You would only see lower resolution for the first few seconds of joining a space. This tradeoff helps people join your space faster.