نور واقعی اشیاء مجازی در یک صحنه
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
Lighting Estimation API دادههای دقیقی را ارائه میدهد که به شما امکان میدهد در هنگام رندر کردن اشیاء مجازی، نشانههای مختلف نور را تقلید کنید. ARCore از سه حالت تخمین نور پشتیبانی می کند:
- از کار افتاده است
- حالت شدت محیط
- حالت HDR محیطی
پیش نیازها
قبل از ادامه، مطمئن شوید که مفاهیم اساسی AR و نحوه پیکربندی یک جلسه ARCore را درک کرده اید.
تخمین روشنایی را فعال کنید
این مراحل را دنبال کنید تا تخمین نور را در برنامه خود فعال کنید.
- یک پروژه AR Foundation یا پروژه ARCore Extensions راه اندازی کنید.
- در برگه Hierarchy ، به XR Session Origin > AR Camera بروید.

- در قسمت AR Camera Manager ، Light Estimation انتخاب کنید.
- در منوی کشویی Light Estimation ، حالت(های) مورد نظر خود را انتخاب کنید.

حالت Environmental HDR را فعال کنید
حالت HDR محیطی تنظیمات تخمین نور زیر را فعال می کند:
هنگامی که معیارهای زیر برآورده شوند، این حالت به طور خودکار فعال می شود:
حالت شدت محیط را فعال کنید
هنگامی که حالت شدت محیط در مؤلفه ARCameraManager
انتخاب می شود، برآورد نور پایه به طور خودکار فعال می شود.
حالت شدت محیط تنظیمات تخمین نور زیر را فعال می کند:
هنگامی که تنظیمات نورپردازی صحیح را به دست آوردید، می توانید اشیاء مجازی در صحنه خود را طوری روشن کنید که گویی بخشی از دنیای واقعی هستند.
مؤلفه ARCameraManager
میتواند یک رویداد frameReceived
ایجاد کند که شرایط نور فریمها را زمانی که تخمین نور فعال است، تخمین میزند. اطلاعات مربوط به رویدادهای frameReceived
در ساختارهای ARCameraFrameEventArgs
به عنوان ARLightEstimationData
ذخیره می شود.
این مراحل را برای تغییر پارامترهای یک چراغ در زمان اجرا دنبال کنید.
- نور جهت دار موجود در صحنه خود را ایجاد یا تغییر دهید.
یک اسکریپت جدید را به Directional Light متصل کنید.
// Sample Lighting Estimation script
Light light;
void Awake ()
{
light = GetComponent<Light>();
}
void OnEnable()
{
if (cameraManager != null)
cameraManager.frameReceived += FrameChanged;
}
void OnDisable()
{
if (cameraManager != null)
cameraManager.frameReceived -= FrameChanged;
}
void FrameChanged(ARCameraFrameEventArgs args)
{
// Modify `light` parameters using ARCameraFrameEventArgs.
}
این اسکریپت جدید را برای تشخیص تغییرات در نور تغییر دهید. برای نمونه هایی از نحوه انجام این کار، اسکریپت های BasicLightEstimation.cs
و HDRLightEstimation.cs
Unity را بررسی کنید.
از پروب های محیطی در صحنه خود استفاده کنید
این مراحل را برای فعال کردن کاوشگرهای محیطی در صحنه خود دنبال کنید.
- قرار دادن خودکار را در
ARSessionOrigin
صحنه خود فعال کنید. - یک جزء
AREnvironmentProbeManager
را به ARSessionOrigin
اضافه کنید.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-14 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-14 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eThe Lighting Estimation API enables virtual objects to realistically reflect real-world lighting conditions within AR experiences.\u003c/p\u003e\n"],["\u003cp\u003eARCore offers three light estimation modes: Disabled, Ambient Intensity, and Environmental HDR, each providing varying levels of lighting detail.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can enable lighting estimation by configuring settings on the AR Camera Manager component within their Unity project.\u003c/p\u003e\n"],["\u003cp\u003eTo utilize lighting data, developers can access light estimation information through the ARCameraManager's frameReceived event and apply it to virtual objects in the scene.\u003c/p\u003e\n"],["\u003cp\u003eEnvironment probes can be enabled to further enhance lighting realism by capturing and applying environmental reflections to virtual objects.\u003c/p\u003e\n"]]],[],null,["# Realistically light virtual objects in a scene\n\nThe [Lighting Estimation API](/ar/develop/unity-arf/lighting-estimation/introduction) provides detailed data that lets you mimic various lighting cues when rendering virtual objects. ARCore supports three light estimation modes:\n\n1. Disabled\n2. [Ambient Intensity mode](/ar/develop/unity-arf/lighting-estimation/introduction#ambient_intensity_mode)\n3. [Environmental HDR mode](/ar/develop/unity-arf/lighting-estimation/introduction#environmental_hdr_mode)\n\nPrerequisites\n-------------\n\nMake sure that you understand [fundamental AR concepts](/ar/develop/fundamentals)\nand how to [configure an ARCore session](/ar/develop/unity-arf/session-config) before proceeding.\n\nEnable Lighting Estimation\n--------------------------\n\nFollow these steps to enable lighting estimation in your app.\n\n1. Set up an [AR Foundation project](/ar/develop/unity-arf/getting-started-ar-foundation) or [ARCore Extensions project](/ar/develop/unity-arf/getting-started-extensions).\n2. In the **Hierarchy** tab, navigate to **XR Session Origin \\\u003e AR Camera**.\n\n1. Under the **AR Camera Manager** component, select **Light Estimation**.\n2. In the **Light Estimation** drop-down menu, select the mode(s) you wish to use.\n\n### Enable Environmental HDR mode\n\n[Environmental HDR mode](/ar/develop/unity-arf/lighting-estimation/introduction#environmental_hdr_mode) enables the following light estimation settings:\n\n- [Main Light Direction](/ar/develop/lighting-estimation#main-directional-light)\n- Main Light Intensity\n- [Ambient Spherical Harmonics](/ar/develop/unity-arf/lighting-estimation/introduction#ambient_spherical_harmonics)\n\nThis mode is automatically enabled when the following criteria are met:\n\n- Ambient Spherical Harmonics, Main Light Direction, and/or Main Light Intensity are selected in the Light Estimation mode provided by the [AR Camera manager](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/manual/#ar-camera-manager)\n- [Environment probes](/ar/develop/unity-arf/lighting-estimation/introduction#environment_probes) are enabled in an [`AREnvironmentProbeManager`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/manual/environment-probe-manager.html)\n- A compatible [camera configuration](/ar/develop/unity-arf/camera-configs) is selected\n\n### Enable Ambient Intensity mode\n\nBasic light estimation is automatically enabled when [Ambient Intensity mode](/ar/develop/unity-arf/lighting-estimation/introduction#ambient_intensity_mode) is selected in the [`ARCameraManager`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/manual/#ar-camera-manager) component.\n\nAmbient Intensity mode enables the following light estimation settings:\n\n- Ambient Color\n- Ambient Intensity\n\nUse lighting information in your scene\n--------------------------------------\n\nOnce you have obtained the correct lighting settings, you can light the virtual objects in your scene as if they were a part of the real world.\n\nThe [`ARCameraManager`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARCameraManager.html) component can raise a [`frameReceived`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARCameraManager.html#events) event that estimates frames' lighting conditions when lighting estimation is enabled. Information from [`frameReceived`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARCameraManager.html#events) events are stored in [`ARCameraFrameEventArgs`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARCameraFrameEventArgs.html) structs as [`ARLightEstimationData`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARLightEstimationData.html).\n\nFollow these steps to change a light's parameters at runtime.\n\n1. Create or modify the existing Directional Light in your scene.\n2. Attach a new script to the Directional Light.\n\n // Sample Lighting Estimation script\n\n Light light;\n void Awake ()\n {\n light = GetComponent\u003cLight\u003e();\n }\n\n void OnEnable()\n {\n if (cameraManager != null)\n cameraManager.frameReceived += FrameChanged;\n }\n\n void OnDisable()\n {\n if (cameraManager != null)\n cameraManager.frameReceived -= FrameChanged;\n }\n\n void FrameChanged(ARCameraFrameEventArgs args)\n {\n // Modify `light` parameters using ARCameraFrameEventArgs.\n }\n\n3. Modify this new script to detect changes in lighting. For examples of how to do this, check out Unity's [`BasicLightEstimation.cs`](https://github.com/Unity-Technologies/arfoundation-samples/blob/main/Assets/Scripts/BasicLightEstimation.cs) and [`HDRLightEstimation.cs`](https://github.com/Unity-Technologies/arfoundation-samples/blob/main/Assets/Scripts/HDRLightEstimation.cs) scripts.\n\n### Use environment probes in your scene\n\nFollow these steps to enable [environment probes](/ar/develop/unity-arf/lighting-estimation/introduction#environment_probes) in your scene.\n\n1. Enable automatic placement in your scene's [`ARSessionOrigin`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARSessionOrigin.html).\n2. Add an [`AREnvironmentProbeManager`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/manual/environment-probe-manager.html) component to the [`ARSessionOrigin`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARSessionOrigin.html)."]]