Version: 2017.3 (switch to 2017.4)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

DynamicGI.SetEnvironmentData

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static method SetEnvironmentData(input: float[]): void;
public static void SetEnvironmentData(float[] input);

Parameters

input Array of float values to be used for Realtime GI environment lighting.

Description

Allows overriding the distant environment lighting for Realtime GI, without changing the Skybox Material.

The input array represents a cube with each face being 8 x 8 texels and each texel being 4 floats (for the RGBA values of the texel's color), so the size of the array is 8*8*6*4 = 1536 floats.
Note that changing the Distant Environment Lighting Source or Environment Lighting Intensity will overwrite the data set with this function.

#pragma strict
public class ExampleScript extends MonoBehaviour {
	function Start() {
		// Set custom environment data for Realtime GI.
		const var kCubeSize: int = 8 * 8;
		const var kEnvironmentDataSize: int = kCubeSize * 6 * 4;
		var envData: float[] = new float[kEnvironmentDataSize];
		for (var c: int = 0; c < 6; ++c) {
			for (var i: int = 0; i < kCubeSize; i += 4) {
				var index: int = 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 * floati / floatkCubeSize;
			}
		}
		// Send the generated environment data to the GI system.
		DynamicGI.SetEnvironmentData(envData);
	}
}
using UnityEngine;

public class ExampleScript : MonoBehaviour { void Start() { // Set custom environment data for Realtime GI. 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); } }
对文档有任何疑问,请移步至开发者社区提问,我们将尽快为您解答