# Produce black cubemaps for the texture of the IBL asset.
./cmgen--format=rgb32f--size=128--extract=./skybox_ibl./black_skybox.png
# Produce lighting cubemaps and a Spherical Harmonics from EXR
./cmgen--format=rgb32f--size=128--deploy=./skybox_ibl--ibl-ld=.--ibl-samples=1024--extract-blur=0.0--sh-irradiance--sh-shader--sh-output=./skybox_ibl/sh.txt./my_360_skybox_1024_x_512.exr
# Copy all of the black cubemaps into the other folder.
cp-rf./skybox_ibl/black_skybox/*./skybox_ibl/my_360_skybox_1024_x_512
# Rename the directory to reflect that these are old assets.
mv./skybox_ibl/black_skybox./skybox_ibl/black_skybox_old
# Rename the directory to reflect that these are your cubemap assets.
mv./skybox_ibl/my_360_skybox_1024_x_512./skybox_ibl/black_skybox
# Change into the child directory.cd./skybox_ibl
# Zip all of the cubemap and the Spherical Harmonics assets together.
zip-qmy_ibl.zipblack_skybox/*
# Return to the directory you started in.cd..
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Optimize environment assets\n\nBeginning with the alpha04 release of the Jetpack XR libraries, there are\nimportant updates to how you should provide spatial environment assets for\noptimal performance and visual quality. These changes are a compatibility impact\nand require updating existing apps that set spatial environments.\n\nTo provide spatial environments, you need two main components:\n\n- A .glb or .gltf file for the environment's geometry (for example, the ground plane, nearby objects) and the primary visual skybox texture that users see.\n- A separate ZIP file containing Image Based Lighting (IBL) information generated from a high dynamic range EXR image using the cmgen tool. The ZIP file is used for lighting calculations, such as reflections on objects, and not for the visual skybox texture itself.\n\nWhy this approach?\n------------------\n\nThis updated asset structure provides these advantages:\n\n- **Smaller file sizes:** Compared to previous methods, such as using a single high-resolution HDR skybox file for both visual display and lighting information, this approach reduces file sizes.\n- **Improved performance:** Separating the visual skybox texture (built into the glb) from the IBL data (in the ZIP file) lets you optimize each component independently. This results in lower texture memory read bandwidth and lower power consumption.\n- **Optimized lighting:** Using a lower resolution skybox resource specifically for the lighting map is beneficial for performance without significantly impacting the visual results of the lighting on objects.\n\nTo learn more about adding a spatial Environment in your app, see our guide on\n[adding environments to your app](/develop/xr/jetpack-xr-sdk/add-environment).\n| **Note:** It's important to provide an IBL asset if your app sets a custom environment, especially if your app has any 3D objects. This is because, if your app provides a glb/glTF but no IBL ZIP file, the 3D objects in the user's environment appear with incorrect lighting (for example, too bright or dim, reflecting objects that the user can't otherwise see).\n\nOptimize your glb\n-----------------\n\nYour glb represents the geometry around the user, and you include the visual\ntexture of your skybox. For your geometry, you should try to maintain file sizes\nat or smaller than 80MB.\n\nTo do this, there are a number of opportunities to make your environment more\nefficient while maintaining high quality. For example, the density of your mesh\nshould be the most dense near the user, and you can decrease the density for\nmeshes that are farther from the user.\n\n- **View distance:** The view distance for environments in Android XR is 200m from the point of the user, and your skybox texture should adhere to this constraint. This provides an optimal experience because parallax becomes indiscernible at that distance.\n- **User height:** Geography can vary, but position the user on a mound at\n around 1.5 meters of height to avoid clipping with larger UI elements in\n apps.\n\n- **Polycount:** Be sensitive to the polycount in your glb files, as a high\n polycount can lead to unnecessary power consumption. Each patch of geometry\n shouldn't exceed 10,000 vertices.\n\n- **KTX compression:** Optimize the GPU performance of your glb file by\n ensuring that your glb uses mipmaps and ktx2 textures.\n\nWhat you'll need to optimize your IBL\n-------------------------------------\n\nDownload the cmgen command line utility:\n\n- You can find the latest release in [the Filament repository](https://github.com/google/filament/releases/).\n- Find the .tgz containing the prebuilt version of cmgen for your platform and extract it.\n- The prebuilt tool is under the /bin directory of the extracted .tgz file.\n\nAssets to prepare to generate the .zip file for IBL:\n\n- A low-resolution EXR that matches your skybox texture\n - Your skybox texture input should be an EXR file. Although cmgen supports other formats, EXRs are recommended because they provide the high dynamic range information that's critical to provide high quality IBL. Using other formats like PNG results in less precise lighting.\n - The source image (EXR) needs to have a 2:1 ratio and dimensions that are a power of 2. Use an EXR that's 1024 x 512 pixels. Note: It may seem that 1024 x 512 is too low of a resolution, but this is beneficial for performance. For IBL, the visual results for the user are very similar to much higher IBL resolution assets.\n- A solid black png\n - This asset must also be a 2:1 ratio. Use a size of 100 x 50 pixels.\n - This serves as an optimized texture to accompany the IBL. Users won't look at this, so we focus the asset on optimizing for performance.\n\nThe following shows an example of using cmgen to create the .zip file for IBL.\nIn this example we use input files named my_360_skybox_1024_x_512.exr and\nblack_skybox.png, and we create a .zip file named my_ibl.zip \n\n # Produce black cubemaps for the texture of the IBL asset.\n ./cmgen --format=rgb32f --size=128 --extract=./skybox_ibl ./black_skybox.png\n\n # Produce lighting cubemaps and a Spherical Harmonics from EXR\n ./cmgen --format=rgb32f --size=128 --deploy=./skybox_ibl --ibl-ld=. --ibl-samples=1024 --extract-blur=0.0 --sh-irradiance --sh-shader --sh-output=./skybox_ibl/sh.txt ./my_360_skybox_1024_x_512.exr\n\n # Copy all of the black cubemaps into the other folder.\n cp -rf ./skybox_ibl/black_skybox/* ./skybox_ibl/my_360_skybox_1024_x_512\n\n # Rename the directory to reflect that these are old assets.\n mv ./skybox_ibl/black_skybox ./skybox_ibl/black_skybox_old\n\n # Rename the directory to reflect that these are your cubemap assets.\n mv ./skybox_ibl/my_360_skybox_1024_x_512 ./skybox_ibl/black_skybox\n\n # Change into the child directory.\n cd ./skybox_ibl\n\n # Zip all of the cubemap and the Spherical Harmonics assets together.\n zip -q my_ibl.zip black_skybox/*\n\n # Return to the directory you started in.\n cd .."]]