浏览代码

[ReflectionProbe] set baked data when a scene is opened in the editor

/feature-ReflectionProbeBaking
Frédéric Vauchelles 7 年前
当前提交
6221a594
共有 2 个文件被更改,包括 28 次插入4 次删除
  1. 28
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Reflection/EditorReflectionSystem.cs
  2. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Reflection/ReflectionSystem.cs

28
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Reflection/EditorReflectionSystem.cs


using System.IO;
using System.Linq;
using System.Reflection;
using UnityEditor.Callbacks;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.Assertions;

RenderSettings.enableLegacyReflectionProbeSystem = false;
Lightmapping.BakeReflectionProbeRequest += LightmappingOnBakeReflectionProbeRequest;
Lightmapping.ClearBakedReflectionProbeRequest += LightmappingOnClearBakedReflectionProbeRequest;
EditorSceneManager.sceneOpened += EditorSceneManagerOnSceneOpened;
}
static void EditorSceneManagerOnSceneOpened(Scene scene, OpenSceneMode mode)
{
var asset = GetLightingDataAssetForScene(scene);
if (asset == null)
return;
var roots = scene.GetRootGameObjects();
var probes = new List<ReflectionProbe>();
for (var i = 0; i < roots.Length; i++)
{
var root = roots[i];
root.GetComponentsInChildren(probes);
for (var j = 0; j < probes.Count; j++)
{
var probe = probes[j];
var id = EditorUtility.GetSceneObjectIdentifierFor(probe);
if (id == SceneObjectIdentifier.Null)
continue;
var bakedTexture = asset.GetBakedTextureFor(id);
if (bakedTexture == null)
continue;
probe.bakedTexture = bakedTexture;
}
}
}
static void LightmappingOnClearBakedReflectionProbeRequest()

4
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Reflection/ReflectionSystem.cs


using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Generic;
using UnityEngine.Experimental.Rendering.HDPipeline.Internal;
using UnityEngine.Rendering;

正在加载...
取消
保存