Version: 2022.3

DynamicGI.SetEnvironmentData

切换到手册
public static void SetEnvironmentData (float[] input);

参数

input Array of float values to be used for Enlighten Realtime Global Illumination environment lighting.

描述

Allows overriding the distant environment lighting for Enlighten Realtime Global Illumination, without changing the Skybox Material.

该输入数组表示一个立方体,其每个面均为 8 x 8 个纹理像素,每个纹理像素均为 4 个浮点值(对于纹理像素颜色的 RGBA 值),因此该数组的大小为 8*8*6*4 = 1536 个浮点值。
注意,更改远处环境光源或环境光照强度将覆盖使用此函数设置的数据。

using UnityEngine;

public class ExampleScript : MonoBehaviour { void Start() { // Set custom environment data for Enlighten Realtime Global Illumination. const int kCubeSize = 8 * 8; const int kEnvironmentDataSize = kCubeSize * 6 * 4; float[] envData = new float[kEnvironmentDataSize];

for (int c = 0; c < 6; ++c) // cube has 6 sides. { for (int i = 0; i < kCubeSize; i += 4) { int index = c * kCubeSize;

// Fill with default values. envData[index + i + 0] = 0.0f; envData[index + i + 1] = 0.0f; envData[index + i + 2] = 0.0f; envData[index + i + 3] = 1.0f;

// Funky colors on each cube face. envData[index + i + (c / 2)] = 4.0f * (float)i / (float)kCubeSize; } }

// Send the generated environment data to the GI system. DynamicGI.SetEnvironmentData(envData); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961