Version: 2022.2

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); } }