【Unity3D自学记录】Unity5之实时GI环境光

时间:2022-12-09 05:22:26

快速实时GI环境光
  快速实时GI环境光可以用天空盒直接驱动环境光输入。这在环境光每帧都会发生变化的情况下非常不理想。所以替代方法是,由当前时间来控制环境光,并转换为关照渐变和环境光强度用于驱动实时GI系统。这些都可以在光照面板中设置:
【Unity3D自学记录】Unity5之实时GI环境光    更新环境光代码如下:
using System;

using UnityEngine;

using System.Collections;

using System.Collections.Generic;

[ExecuteInEditMode]

public class EnvironmentUpdater : MonoBehaviour {

public Gradient groundGradient, equatorGradient, skyGradient;

private TimeOfDayManager m_TimeOfDayManager;

void OnEnable () {

m_TimeOfDayManager = FindObjectOfType<timeofdaymanager> ();

}

void Update () {

float currentTime = m_TimeOfDayManager.time;

RenderSettings.ambientGroundColor = groundGradient.Evaluate(currentTime);

RenderSettings.ambientEquatorColor = equatorGradient.Evaluate(currentTime);

RenderSettings.ambientSkyColor = skyGradient.Evaluate(currentTime);

}

}