XR_ANDROID_light_estimation_cubemap

Name String

XR_ANDROID_light_estimation_cubemap

ประเภทส่วนขยาย

ส่วนขยายอินสแตนซ์

หมายเลขต่อที่ลงทะเบียนไว้

722

การแก้ไข

1

สถานะการให้สัตยาบัน

ไม่ได้รับการให้สัตยาบัน

ทรัพยากร Dependency ของส่วนขยายและเวอร์ชัน

XR_ANDROID_light_estimation

วันที่แก้ไขล่าสุด

2025-08-06

สถานะ IP

ไม่มีการอ้างสิทธิ์ IP ที่ทราบ

ผู้เขียน

Salar Khan, Google
Scott Chung, Google
Jared Finder, Google
Spencer Quin, Google
Levana Chen, Google
Nihav Jain, Google
Jürgen Sturm, Google

ภาพรวม

ส่วนขยายนี้ต่อยอดมาจากส่วนขยาย XR_ANDROID_light_estimation พื้นฐาน โดยจะเพิ่มการรองรับการรับค่าประมาณแสงของ Cubemap ซึ่งจะให้ค่าประมาณที่ละเอียดยิ่งขึ้นเกี่ยวกับแสงในสภาพแวดล้อมจริง

หมายเหตุ

กลไกในการรับข้อมูลการประมาณแสงจะเหมือนกับส่วนขยายพื้นฐาน ยกเว้นว่าต้องเชื่อมโยง XrCubemapLightEstimatorCreateInfoANDROID กับ XrLightEstimatorCreateInfoANDROID เมื่อสร้างแฮนเดิลเครื่องมือประมาณแสง

ตรวจสอบความสามารถของระบบ

typedef struct XrSystemCubemapLightEstimationPropertiesANDROID {
    XrStructureType    type;
    void*              next;
    XrBool32           supportsCubemapLightEstimation;
} XrSystemCubemapLightEstimationPropertiesANDROID;

คำอธิบายสมาชิก

  • type คือ XrStructureType ของโครงสร้างนี้
  • next คือ NULL หรือตัวชี้ไปยังโครงสร้างถัดไปในเชนโครงสร้าง ไม่มีการกำหนดโครงสร้างดังกล่าวใน OpenXR หลักหรือส่วนขยายนี้
  • supportsCubemapLightEstimation เป็น XrBool32 ซึ่งระบุว่าระบบปัจจุบันรองรับการประมาณแสงแบบคิวบ์แมปหรือไม่

แอปพลิเคชันสามารถตรวจสอบว่าระบบรองรับการประมาณแสง Cubemap หรือไม่โดยขยาย XrSystemProperties ด้วยโครงสร้าง XrSystemCubemapLightEstimationPropertiesANDROID เมื่อเรียกใช้ xrGetSystemProperties

หากรันไทม์แสดงผล XR_FALSE สำหรับ supportsCubemapLightEstimation และ XrCubemapLightEstimatorCreateInfoANDROID เชื่อมโยงกับ XrLightEstimatorCreateInfoANDROID แล้ว รันไทม์ต้องแสดงผล XR_ERROR_FEATURE_UNSUPPORTED จาก xrCreateLightEstimatorANDROID

การใช้งานที่ถูกต้อง (โดยนัย)

การรับความละเอียดของคิวบ์แมปที่รองรับ

XrResult xrEnumerateCubemapLightingResolutionsANDROID(
    XrInstance                                  instance,
    XrSystemId                                  systemId,
    uint32_t                                    resolutionCapacityInput,
    uint32_t*                                   resolutionCountOutput,
    uint32_t*                                   resolutions);

คำอธิบายพารามิเตอร์

  • instance คือ XrInstance ที่สร้างไว้ก่อนหน้านี้
  • systemId คือ XrSystemId ที่เรียกข้อมูลมาก่อนหน้านี้โดย xrGetSystem เพื่อรับความละเอียดของ Cubemap ที่รองรับ
  • resolutionCapacityInput คือ uint32_t ที่ระบุจำนวนองค์ประกอบสูงสุดที่สามารถจัดเก็บในอาร์เรย์ resolutions
  • resolutionCountOutput คือตัวชี้ไปยัง uint32_t ซึ่งตั้งค่าโดยรันไทม์ที่ระบุจำนวนองค์ประกอบที่เขียนลงในอาร์เรย์ resolutions โดยรันไทม์
  • resolutions คืออาร์เรย์ของ uint32_t ซึ่งรันไทม์จะป้อนข้อมูลด้วยความละเอียดของคิวบ์แมปที่รองรับ

ความละเอียดของ Cubemap จะระบุความกว้างและความสูงของแต่ละด้านของ Cubemap เป็นพิกเซล สำนวนการเรียก 2 ครั้ง แอปพลิเคชันสามารถเลือกใช้ความละเอียดที่รองรับรายการใดรายการหนึ่งใน XrCubemapLightEstimatorCreateInfoANDROID :: cubemapResolution เมื่อสร้างแฮนเดิลเครื่องมือประมาณแสง แอปพลิเคชันต้องจัดสรรหน่วยความจำในปริมาณที่เหมาะสมสำหรับสมาชิกบัฟเฟอร์รูปภาพของ XrCubemapLightingDataANDROID โดยอิงตามความละเอียดที่เลือกและรูปแบบสี

การใช้งานที่ถูกต้อง (โดยนัย)

  • ต้องเปิดใช้ส่วนขยาย XR_ANDROID_light_estimation_cubemap ก่อนเรียกใช้ xrEnumerateCubemapLightingResolutionsANDROID
  • instance ต้องเป็นแฮนเดิล XrInstance ที่ถูกต้อง
  • resolutionCountOutput ต้องเป็นตัวชี้ไปยังค่า uint32_t
  • หาก resolutionCapacityInput ไม่ใช่ 0 resolutions ต้องเป็นพอยน์เตอร์ไปยังอาร์เรย์ของค่า resolutionCapacityInput uint32_t

รหัสการคืนสินค้า

สำเร็จ

  • XR_SUCCESS

ความล้มเหลว

  • XR_ERROR_FUNCTION_UNSUPPORTED
  • XR_ERROR_HANDLE_INVALID
  • XR_ERROR_INSTANCE_LOST
  • XR_ERROR_RUNTIME_FAILURE
  • XR_ERROR_SIZE_INSUFFICIENT
  • XR_ERROR_SYSTEM_INVALID
  • XR_ERROR_VALIDATION_FAILURE

กำลังรับรูปแบบสี Cubemap ที่รองรับ

การแจงนับ XrCubemapLightingColorFormatANDROID จะระบุรูปแบบสีของแสง Cubemap ที่จะใช้กับรันไทม์

typedef enum XrCubemapLightingColorFormatANDROID {
    XR_CUBEMAP_LIGHTING_COLOR_FORMAT_R32G32B32_SFLOAT_ANDROID = 1,
    XR_CUBEMAP_LIGHTING_COLOR_FORMAT_R32G32B32A32_SFLOAT_ANDROID = 2,
    XR_CUBEMAP_LIGHTING_COLOR_FORMAT_R16G16B16A16_SFLOAT_ANDROID = 3,
    XR_CUBEMAP_LIGHTING_COLOR_FORMAT_MAX_ENUM_ANDROID = 0x7FFFFFFF
} XrCubemapLightingColorFormatANDROID;

Enum มีความหมายดังนี้

คำอธิบาย Enum

XR_CUBEMAP_LIGHTING_COLOR_FORMAT_R32G32B32_SFLOAT_ANDROID

รูปแบบสีที่มี 3 ช่องทาง โดยแต่ละช่องทางเป็นค่าจุดลอยตัว 32 บิต

XR_CUBEMAP_LIGHTING_COLOR_FORMAT_R32G32B32A32_SFLOAT_ANDROID

รูปแบบสีที่มี 4 แชแนล โดยแต่ละแชแนลเป็นค่าจุดลอยตัว 32 บิต

XR_CUBEMAP_LIGHTING_COLOR_FORMAT_R16G16B16A16_SFLOAT_ANDROID

รูปแบบสีที่มี 4 ช่องทาง โดยแต่ละช่องทางเป็นค่าจุดลอยตัว 16 บิต

XrResult xrEnumerateCubemapLightingColorFormatsANDROID(
    XrInstance                                  instance,
    XrSystemId                                  systemId,
    uint32_t                                    colorFormatCapacityInput,
    uint32_t*                                   colorFormatCountOutput,
    XrCubemapLightingColorFormatANDROID*        colorFormats);

คำอธิบายพารามิเตอร์

  • instance คือ XrInstance ที่สร้างไว้ก่อนหน้านี้
  • systemId คือ XrSystemId ที่เรียกข้อมูลมาก่อนหน้านี้โดย xrGetSystem เพื่อรับความละเอียดของ Cubemap ที่รองรับ
  • colorFormatCapacityInput คือ uint32_t ที่ระบุจำนวนองค์ประกอบสูงสุดที่สามารถจัดเก็บในอาร์เรย์ colorFormats
  • colorFormatCountOutput คือตัวชี้ไปยัง uint32_t ซึ่งตั้งค่าโดยรันไทม์ที่ระบุจำนวนองค์ประกอบที่เขียนลงในอาร์เรย์ colorFormats โดยรันไทม์
  • colorFormats คืออาร์เรย์ของ XrCubemapLightingColorFormatANDROID ซึ่งรันไทม์จะป้อนข้อมูลด้วยรูปแบบสี Cubemap ที่รองรับ

สำนวนการเรียก 2 ครั้ง จากนั้นแอปพลิเคชันสามารถเลือกใช้รูปแบบสีที่รองรับรูปแบบใดรูปแบบหนึ่งใน XrCubemapLightEstimatorCreateInfoANDROID :: colorFormat เมื่อสร้างแฮนเดิลเครื่องมือประมาณแสง แอปพลิเคชันต้องจัดสรรหน่วยความจำในปริมาณที่เหมาะสมสำหรับสมาชิกบัฟเฟอร์รูปภาพของ XrCubemapLightingDataANDROID โดยอิงตามรูปแบบสีที่เลือก

การใช้งานที่ถูกต้อง (โดยนัย)

  • ต้องเปิดใช้ส่วนขยาย XR_ANDROID_light_estimation_cubemap ก่อนเรียกใช้ xrEnumerateCubemapLightingColorFormatsANDROID
  • instance ต้องเป็นแฮนเดิล XrInstance ที่ถูกต้อง
  • colorFormatCountOutput ต้องเป็นตัวชี้ไปยังค่า uint32_t
  • หาก colorFormatCapacityInput ไม่ใช่ 0 colorFormats ต้องเป็นพอยเตอร์ไปยังอาร์เรย์ของค่า colorFormatCapacityInput XrCubemapLightingColorFormatANDROID

รหัสการคืนสินค้า

สำเร็จ

  • XR_SUCCESS

ความล้มเหลว

  • XR_ERROR_FUNCTION_UNSUPPORTED
  • XR_ERROR_HANDLE_INVALID
  • XR_ERROR_INSTANCE_LOST
  • XR_ERROR_RUNTIME_FAILURE
  • XR_ERROR_SIZE_INSUFFICIENT
  • XR_ERROR_SYSTEM_INVALID
  • XR_ERROR_VALIDATION_FAILURE

สร้างแฮนเดิลเครื่องมือประมาณแสง Cubemap

typedef struct XrCubemapLightEstimatorCreateInfoANDROID {
    XrStructureType                        type;
    const void*                            next;
    uint32_t                               cubemapResolution;
    XrCubemapLightingColorFormatANDROID    colorFormat;
    XrBool32                               reproject;
} XrCubemapLightEstimatorCreateInfoANDROID;

คำอธิบายสมาชิก

  • type คือ XrStructureType ของโครงสร้างนี้
  • next คือ NULL หรือตัวชี้ไปยังโครงสร้างถัดไปในเชนโครงสร้าง
  • cubemapResolution คือ uint32_t ที่ระบุความละเอียดของแสง Cubemap ที่จะใช้
  • colorFormat คือ XrCubemapLightingColorFormatANDROID ที่ระบุรูปแบบสีของข้อมูลแสง Cubemap ที่จะใช้
  • reproject คือ XrBool32 ที่ระบุว่าควรฉายแสงคิวบ์แมปซ้ำไปยังพื้นที่ฐานของแอปพลิเคชันหรือไม่

โครงสร้าง XrCubemapLightEstimatorCreateInfoANDROID อธิบายข้อมูลเพื่อสร้างแฮนเดิล XrLightEstimatorANDROID ให้สามารถให้ค่าประมาณแสง Cubemap ได้ ต้องตั้งค่าสมาชิก XrCubemapLightEstimatorCreateInfoANDROID :: cubemapResolution ต้องเป็นความละเอียดรายการใดรายการหนึ่งที่ xrEnumerateCubemapLightingResolutionsANDROID แสดงผล ต้องตั้งค่าสมาชิก XrCubemapLightEstimatorCreateInfoANDROID :: colorFormat เป็นรูปแบบสีรูปแบบใดรูปแบบหนึ่งที่ xrEnumerateCubemapLightingColorFormatsANDROID แสดงผล หากแอปพลิเคชันไม่ได้ตั้งค่าความละเอียดเป็นความละเอียดที่รองรับหรือรูปแบบสีเป็นรูปแบบสีที่รองรับ รันไทม์ต้องแสดงผล XR_ERROR_FEATURE_UNSUPPORTED จาก xrCreateLightEstimatorANDROID

การใช้งานที่ถูกต้อง (โดยนัย)

การประมาณแสงคิวบ์แมป

typedef struct XrCubemapLightingDataANDROID {
    XrStructureType                type;
    void*                          next;
    XrLightEstimateStateANDROID    state;
    uint32_t                       imageBufferSize;
    uint8_t*                       imageBufferRight;
    uint8_t*                       imageBufferLeft;
    uint8_t*                       imageBufferTop;
    uint8_t*                       imageBufferBottom;
    uint8_t*                       imageBufferFront;
    uint8_t*                       imageBufferBack;
    XrQuaternionf                  rotation;
    XrTime                         centerExposureTime;
} XrCubemapLightingDataANDROID;

คำอธิบายสมาชิก

  • type คือ XrStructureType ของโครงสร้างนี้
  • next คือ NULL หรือตัวชี้ไปยังโครงสร้างถัดไปในเชนโครงสร้าง โครงสร้างที่ถูกต้องคือ XrAmbientLightANDROID , XrSphericalHarmonicsANDROID , XrDirectionalLightANDROID
  • state คือ XrLightEstimateStateANDROID ที่แสดงสถานะของการประมาณแสง
  • imageBufferSize คือ uint32_t ที่ระบุขนาดไบต์ของบัฟเฟอร์รูปภาพแต่ละด้านใน Cubemap
  • imageBufferRight คือบัฟเฟอร์ uint8_t ที่มีรูปภาพด้านขวาของ Cubemap
  • imageBufferLeft คือบัฟเฟอร์ uint8_t ที่มีรูปภาพด้านซ้ายของ Cubemap
  • imageBufferTop คือบัฟเฟอร์ uint8_t ที่มีรูปภาพด้านบนของ Cubemap
  • imageBufferBottom คือบัฟเฟอร์ uint8_t ที่มีรูปภาพด้านล่างของ Cubemap
  • imageBufferFront คือบัฟเฟอร์ uint8_t ที่มีรูปภาพด้านหน้าของ Cubemap
  • imageBufferBack คือบัฟเฟอร์ uint8_t ที่มีรูปภาพด้านหลังของ Cubemap
  • rotation คือ XrQuaternionf ที่ระบุการหมุนของ Cubemap
  • centerExposureTime คือ XrTime ที่ระบุเวลาที่จับภาพ Cubemap

โครงสร้างนี้สามารถเชื่อมโยงกับ XrLightEstimateANDROID ได้ รันไทม์ต้องป้อนข้อมูลโครงสร้างนี้ใน xrGetLightEstimateANDROID เท่านั้นหากใช้ XrCubemapLightEstimatorCreateInfoANDROID เพื่อสร้างแฮนเดิลเครื่องมือประมาณแสง แอปพลิเคชันต้องจัดสรรหน่วยความจำในปริมาณที่เหมาะสมสำหรับบัฟเฟอร์รูปภาพ ซึ่งขึ้นอยู่กับค่าที่ตั้งไว้ใน XrCubemapLightEstimatorCreateInfoANDROID :: cubemapResolution และ XrCubemapLightEstimatorCreateInfoANDROID :: colorFormat เมื่อสร้างแฮนเดิลเครื่องมือประมาณแสง แอปพลิเคชันต้องตั้งค่า XrCubemapLightingDataANDROID :: imageBufferSize เป็นความจุของบัฟเฟอร์รูปภาพแต่ละด้านในหน่วยไบต์ หากแอปพลิเคชันไม่ได้ใช้การประมาณแสงแบบคิวบ์แมป หรือหาก XrCubemapLightingDataANDROID :: imageBufferSize มีขนาดไม่ใหญ่พอที่รันไทม์จะป้อนข้อมูลบัฟเฟอร์รูปภาพ รันไทม์ต้องตั้งค่า XrCubemapLightingDataANDROID :: state เป็น XR_LIGHT_ESTIMATE_STATE_INVALID_ANDROID

หากแอปพลิเคชันตั้งค่า XrCubemapLightEstimatorCreateInfoANDROID :: reproject เป็น XR_TRUE เมื่อสร้างแฮนเดิลเครื่องมือประมาณแสง รันไทม์ต้องตั้งค่า XrCubemapLightingDataANDROID :: rotation เป็นการหมุนเอกลักษณ์ และตรวจสอบว่าคิวบ์แมปที่หมุนภายในได้รับการฉายภาพใหม่ลงบนใบหน้าของคิวบ์แมปเอกลักษณ์ในพื้นที่ฐานของแอปพลิเคชัน

เลย์เอาต์ของคิวบ์แมปแสงจะเหมือนกับเลย์เอาต์คิวบ์แมป OpenGL ดังที่แสดงในรูปภาพต่อไปนี้

เลย์เอาต์คิวบ์แมปการประมาณแสง XR ANDROID

รูปที่ 31 เลย์เอาต์คิวบ์แมป

การใช้งานที่ถูกต้อง (โดยนัย)

  • ต้องเปิดใช้ส่วนขยาย XR_ANDROID_light_estimation_cubemap ก่อนใช้ XrCubemapLightingDataANDROID
  • type ต้องเป็น XR_TYPE_CUBEMAP_LIGHTING_DATA_ANDROID
  • next ต้องเป็น NULL หรือพอยน์เตอร์ที่ถูกต้องไปยังโครงสร้างถัดไปในเชนโครงสร้าง
  • state ต้องเป็นค่า XrLightEstimateStateANDROID ที่ถูกต้อง
  • imageBufferRight ต้องเป็นตัวชี้ไปยังอาร์เรย์ของค่า imageBufferSize uint8_t
  • imageBufferLeft ต้องเป็นตัวชี้ไปยังอาร์เรย์ของค่า imageBufferSize uint8_t
  • imageBufferTop ต้องเป็นตัวชี้ไปยังอาร์เรย์ของค่า imageBufferSize uint8_t
  • imageBufferBottom ต้องเป็นตัวชี้ไปยังอาร์เรย์ของค่า imageBufferSize uint8_t
  • imageBufferFront ต้องเป็นตัวชี้ไปยังอาร์เรย์ของค่า imageBufferSize uint8_t
  • imageBufferBack ต้องเป็นตัวชี้ไปยังอาร์เรย์ของค่า imageBufferSize uint8_t
  • พารามิเตอร์ imageBufferSize ต้องมากกว่า 0

โค้ดตัวอย่างสำหรับการประมาณแสง

โค้ดตัวอย่างต่อไปนี้แสดงวิธีรับปริมาณการประมาณแสงที่เป็นไปได้ทั้งหมดจากรันไทม์

XrSession session;  // Created at app startup
XrInstance instance; // Created at app startup
XrSpace appSpace;   // Created previously.
XrSystemId systemId; // Retrieved previously by xrGetSystem
PFN_xrCreateLightEstimatorANDROID xrCreateLightEstimatorANDROID; // Created previously.
PFN_xrDestroyLightEstimatorANDROID xrDestroyLightEstimatorANDROID; // Created previously.
PFN_xrGetLightEstimateANDROID xrGetLightEstimateANDROID; // Created previously.
PFN_xrEnumerateCubemapLightingResolutionsANDROID xrEnumerateCubemapLightingResolutionsANDROID; // Created previously.
PFN_xrEnumerateCubemapLightingColorFormatsANDROID xrEnumerateCubemapLightingColorFormatsANDROID; // Created previously.

XrSystemCubemapLightEstimationPropertiesANDROID props = {
  .type = XR_TYPE_SYSTEM_CUBEMAP_LIGHT_ESTIMATION_PROPERTIES_ANDROID};
XrSystemProperties base = {.type = XR_TYPE_SYSTEM_PROPERTIES,
                           .next = &props};
CHK_XR(xrGetSystemProperties(instance, systemId, &base));
if (!props.supportsCubemapLightEstimation) {
   // Cubemap light estimation is not supported
}

uint32_t cubemapResolution = 0;
std::vector<uint32_t> supportedCubemapResolutions;
uint32_t resolutionCount;
CHK_XR(xrEnumerateCubemapLightingResolutionsANDROID(
  instance, systemId, 0, &resolutionCount, nullptr));
supportedCubemapResolutions.resize(resolutionCount);
if (resolutionCount == 0) {
  // No cubemap lighting supported
} else {
  CHK_XR(xrEnumerateCubemapLightingResolutionsANDROID(
    instance, systemId, 0, &resolutionCount, supportedCubemapResolutions.data()));
  cubemapResolution = supportedCubemapResolutions[0];
}

uint32_t pixelCount = cubemapResolution * cubemapResolution;

XrCubemapLightingColorFormatANDROID colorFormat;
std::vector<XrCubemapLightingColorFormatANDROID> supportedColorFormats;
uint32_t colorFormatCount;
CHK_XR(xrEnumerateCubemapLightingColorFormatsANDROID(
  instance, systemId, 0, &colorFormatCount, nullptr));
supportedColorFormats.resize(colorFormatCount);
if (colorFormatCount == 0) {
  // No supported color formats for cubemap lighting. Cannot use cubemap
  // light estimation.
} else {
  CHK_XR(xrEnumerateCubemapLightingColorFormatsANDROID(
    instance, systemId, 0, &colorFormatCount, supportedColorFormats.data()));
  colorFormat = supportedColorFormats[0];
}

uint32_t pixelSize = 0;
switch (colorFormat) {
  case XR_CUBEMAP_LIGHTING_COLOR_FORMAT_R32G32B32_SFLOAT_ANDROID:
    pixelSize = 3 * sizeof(float);
    break;
  case XR_CUBEMAP_LIGHTING_COLOR_FORMAT_R32G32B32A32_SFLOAT_ANDROID:
    pixelSize = 4 * sizeof(float);
    break;
  case XR_CUBEMAP_LIGHTING_COLOR_FORMAT_R16G16B16A16_SFLOAT_ANDROID:
    pixelSize = 4 * sizeof(uint16_t);
    break;
  default:
    // Should not happen since the color format was validated previously.
    break;
}

uint32_t perFaceImageBufferSize = pixelCount * pixelSize;

XrLightEstimatorANDROID estimator;
XrCubemapLightEstimatorCreateInfoANDROID cubemapCreateInfo = {
    .type = XR_TYPE_CUBEMAP_LIGHT_ESTIMATOR_CREATE_INFO_ANDROID,
    .cubemapResolution = cubemapResolution,
    .colorFormat = colorFormat,
    .reproject = XR_TRUE
};
XrLightEstimatorCreateInfoANDROID basicCreateInfo = {
    .type = XR_TYPE_LIGHT_ESTIMATOR_CREATE_INFO_ANDROID,
    .next = &cubemapCreateInfo};
CHK_XR(xrCreateLightEstimatorANDROID(session, &basicCreateInfo, &estimator));

std::vector<uint8_t> cubemapBuffer(perFaceImageBufferSize * 6); // 6 faces * perFaceImageBufferSize

// Every frame
XrTime updateTime;  // Time used for the current frame's simulation update.

XrLightEstimateGetInfoANDROID info = {
    .type = XR_TYPE_LIGHT_ESTIMATE_GET_INFO_ANDROID,
    .space = appSpace,
    .time = updateTime,
};

XrCubemapLightingDataANDROID cubemap = {
    .type = XR_TYPE_CUBEMAP_LIGHTING_DATA_ANDROID,
    .next = nullptr,
    .imageBufferSize = perFaceImageBufferSize,
    .imageBufferRight = cubemapBuffer.data() + 0 * perFaceImageBufferSize,
    .imageBufferLeft = cubemapBuffer.data() + 1 * perFaceImageBufferSize,
    .imageBufferTop = cubemapBuffer.data() + 2 * perFaceImageBufferSize,
    .imageBufferBottom = cubemapBuffer.data() + 3 * perFaceImageBufferSize,
    .imageBufferFront = cubemapBuffer.data() + 4 * perFaceImageBufferSize,
    .imageBufferBack = cubemapBuffer.data() + 5 * perFaceImageBufferSize,
};

XrDirectionalLightANDROID directionalLight = {
    .type = XR_TYPE_DIRECTIONAL_LIGHT_ANDROID,
    .next = &cubemap,
};

XrSphericalHarmonicsANDROID totalSh = {
    .type = XR_TYPE_SPHERICAL_HARMONICS_ANDROID,
    .next = &directionalLight,
    .kind = XR_SPHERICAL_HARMONICS_KIND_TOTAL_ANDROID,
};

XrSphericalHarmonicsANDROID ambientSh = {
    .type = XR_TYPE_SPHERICAL_HARMONICS_ANDROID,
    .next = &totalSh,
    .kind = XR_SPHERICAL_HARMONICS_KIND_AMBIENT_ANDROID,
};

XrAmbientLightANDROID ambientLight = {
    .type = XR_TYPE_AMBIENT_LIGHT_ANDROID,
    .next = &ambientSh,
};

XrLightEstimateANDROID estimate = {
    .type = XR_TYPE_LIGHT_ESTIMATE_ANDROID,
    .next = &ambientLight,
};

XrResult result = xrGetLightEstimateANDROID(estimator, &info, &estimate);
if (result == XR_SUCCESS &&
    estimate.state == XR_LIGHT_ESTIMATE_STATE_VALID_ANDROID) {
  // use cubemap, directionalLight, totalSh, ambientSh, and
  // ambientLight if each struct has a valid state field

  if (cubemap.state == XR_LIGHT_ESTIMATE_STATE_VALID_ANDROID) {
    // use cubemap
    if (cubemapCreateInfo.reproject == XR_TRUE) {
      XrQuaternionf identityQuaternion = {0.0f, 0.0f, 0.0f, 1.0f};
      assert(memcmp(&cubemap.rotation, &identityQuaternion, sizeof(XrQuaternionf)) == 0);
    }
  }
}

// When you want to disable light estimation
CHK_XR(xrDestroyLightEstimatorANDROID(estimator));

คำสั่งใหม่

โครงสร้างใหม่

Enum ใหม่

ค่าคงที่ Enum ใหม่

  • XR_ANDROID_LIGHT_ESTIMATION_CUBEMAP_EXTENSION_NAME
  • XR_ANDROID_light_estimation_cubemap_SPEC_VERSION
  • การขยาย XrStructureType :

    • XR_TYPE_CUBEMAP_LIGHTING_DATA_ANDROID
    • XR_TYPE_CUBEMAP_LIGHT_ESTIMATOR_CREATE_INFO_ANDROID
    • XR_TYPE_SYSTEM_CUBEMAP_LIGHT_ESTIMATION_PROPERTIES_ANDROID

ปัญหา

ประวัติเวอร์ชัน

  • ฉบับแก้ไข 1, 2025-12-05 (Salar Khan)

    • คำอธิบายส่วนขยายเริ่มต้น