קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
החל מהגרסה alpha04 של ספריות Jetpack XR, יש עדכונים חשובים לגבי האופן שבו צריך לספק נכסי סביבה מרחבית כדי להשיג ביצועים ואיכות חזותית אופטימליים. השינויים האלה משפיעים על התאימות, וצריך לעדכן אפליקציות קיימות שמגדירות סביבות מרחביות.
כדי לספק סביבות מרחביות, צריך שני רכיבים עיקריים:
קובץ .glb או .gltf לגיאומטריה של הסביבה (לדוגמה, מישור הקרקע, אובייקטים בקרבת מקום) ולמרקם הראשי של תיבת השמיים החזותית שמוצגת למשתמשים.
קובץ ZIP נפרד שמכיל מידע על תאורה מבוססת-תמונה (IBL) שנוצר מתמונת EXR בטווח דינמי גבוה באמצעות הכלי cmgen. קובץ ה-ZIP משמש לחישוב התאורה, כמו השתקפויות על אובייקטים, ולא לטקסטורה החזותית של תיבת השמיים.
למה דווקא הגישה הזו?
מבנה הנכסים המעודכן הזה מספק את היתרונות הבאים:
קבצים קטנים יותר: בהשוואה לשיטות קודמות, כמו שימוש בקובץ HDR יחיד ברזולוציה גבוהה לצורך תצוגה חזותית וגם לצורך מידע על התאורה, הגישה הזו מקטינה את גודל הקבצים.
ביצועים משופרים: הפרדת המרקם החזותי של תיבת השמיים (שמשולבת ב-GLB) מנתוני ה-IBL (בקובץ ה-ZIP) מאפשרת לבצע אופטימיזציה של כל רכיב בנפרד. כתוצאה מכך, רוחב הפס לקריאה של זיכרון הטקסטורות קטן יותר וצריכת החשמל נמוכה יותר.
תאורה אופטימיזציה: שימוש במשאב של תיבת שמיים ברזולוציה נמוכה יותר, במיוחד למפת התאורה, תורם לשיפור הביצועים בלי להשפיע באופן משמעותי על התוצאות החזותית של התאורה על האובייקטים.
מידע נוסף על הוספת סביבה מרחבית לאפליקציה זמין במדריך שלנו בנושא הוספת סביבות לאפליקציה.
אופטימיזציה של קובץ ה-GLB
קובץ ה-glb מייצג את הגיאומטריה סביב המשתמש, וצריך לכלול את המרקם החזותי של תיבת השמיים. לגבי הגיאומטריה, כדאי לנסות לשמור על גודל קובץ של 80MB או פחות.
כדי לעשות זאת, יש כמה הזדמנויות לשפר את היעילות של הסביבה תוך שמירה על איכות גבוהה. לדוגמה, הצפיפות של הרשת צריכה להיות הגבוהה ביותר ליד המשתמש, וניתן להקטין את הצפיפות של רשתות שנמצאות רחוק יותר מהמשתמש.
מרחק התצוגה: מרחק התצוגה של סביבות ב-Android XR הוא 200 מ' מנקודת המשתמש, וטקסטורת תיבת השמיים צריכה לעמוד באילוץ הזה. כך אפשר ליהנות מחוויית צפייה אופטימלית, כי אי אפשר להבחין בפרלקס בטווח הזה.
גובה המשתמש: המיקום הגיאוגרפי עשוי להשתנות, אבל כדאי למקם את המשתמש על גבעה בגובה של כ-1.5 מטר כדי למנוע חתוך של רכיבי ממשק משתמש גדולים יותר באפליקציות.
מספר הפוליגונים: חשוב לשים לב למספר הפוליגונים בקובצי glb, כי מספר פוליגונים גבוה עלול להוביל לצריכת חשמל מיותרת. כל תיקון של גיאומטריה לא יכול להכיל יותר מ-10,000 קודקודים.
דחיסת KTX: כדי לבצע אופטימיזציה של ביצועי ה-GPU בקובץ ה-GLB, צריך לוודא שבקובץ ה-GLB נעשה שימוש ב-mipmaps ובטקסטורות של KTX2.
מחפשים את קובץ ה-tgz שמכיל את הגרסה המוכנה מראש של cmgen לפלטפורמה שלכם ומחלצים אותו.
הכלי שנוצר מראש נמצא בספרייה /bin של קובץ ה-tgz שחולץ.
נכסים שצריך להכין כדי ליצור את קובץ ה-zip ל-IBL:
קובץ EXR ברזולוציה נמוכה שתואמת למרקם של תיבת השמיים
הקלט של טקסטורת תיבת השמיים צריך להיות קובץ EXR. אמנם הכלי cmgen תומך בפורמטים אחרים, אבל מומלץ להשתמש בפורמטים של EXR כי הם מספקים את המידע על טווח הדינמיקה הגבוה, שחשוב מאוד כדי לספק איכות גבוהה של IBL.
שימוש בפורמטים אחרים כמו PNG גורם לתאורה פחות מדויקת.
יחס הגובה-רוחב של קובץ התמונה המקורית (EXR) צריך להיות 2:1 והמידות שלו צריכות להיות כפולות של 2. צריך להשתמש בקובץ EXR בגודל 1,024x512 פיקסלים. הערה: יכול להיות שרזולוציה של 1,024 x 512 נמוכה מדי, אבל היא משפרת את הביצועים. לגבי IBL, התוצאות החזוניות של המשתמשים דומות מאוד לאלה של נכסי IBL ברזולוציה גבוהה בהרבה.
קובץ PNG שחור אטום
יחס הגובה-רוחב של הנכס הזה צריך להיות 2:1. מומלץ להשתמש בתמונה בגודל 100 x 50 פיקסלים.
הוא משמש כטקסטורה אופטימיזציה שתלווה את ה-IBL. המשתמשים לא יבחינו בכך, לכן אנחנו מתמקדים באופטימיזציה של הנכס לפי ביצועים.
בהמשך מופיעה דוגמה לשימוש ב-cmgen כדי ליצור את קובץ ה-zip ל-IBL.
בדוגמה הזו אנחנו משתמשים בקובצי קלט בשם my_360_skybox_1024_x_512.exr ו-black_skybox.png, ויוצרים קובץ ZIP בשם my_ibl .zip.
# 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..
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-27 (שעון UTC).
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-07-27 (שעון UTC)."],[],[],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 .."]]