浏览代码

Updated API

/feature-ReflectionProbeBaking
Frédéric Vauchelles 7 年前
当前提交
88dddd64
共有 1 个文件被更改,包括 35 次插入16 次删除
  1. 51
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Reflection/EditorReflectionSystem.cs

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


using System.IO;
using System.Linq;
using System.Reflection;
using UnityEditor.Callbacks;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Experimental.Rendering.HDPipeline;

{
RenderSettings.enableLegacyReflectionProbeSystem = false;
Lightmapping.BakeReflectionProbeRequest += LightmappingOnBakeReflectionProbeRequest;
Lightmapping.BakeReflectionProbeRequestCancelled += LightmappingOnBakeReflectionProbeRequestCancelled;
EditorApplication.update += Update;
}

static void LightmappingOnBakeReflectionProbeRequest(BakeReflectionProbeRequest request)
{
if (request.completed)
return;
// Custom probe hashes should be handled here by the user
// var customProbeHash = CalculateCustomProbeHashes()
// dependencyHash = CombineHashes(dependencyHash, customProbeHash);

s_CurrentBakeJob.Dispose();
s_CurrentBakeJob = null;
}
Debug.Log(request.requestHash.ToString());
var job = new ReflectionBakeJob();
var job = new ReflectionBakeJob(request);
request.Cancelled += LightmappingOnBakeReflectionProbeRequestCancelled;
request.Cancelled -= LightmappingOnBakeReflectionProbeRequestCancelled;
if (s_CurrentBakeJob != null && s_CurrentBakeJob.request == request)
{
s_CurrentBakeJob.Dispose();

public List<ReflectionProbe> reflectionProbesToBake = new List<ReflectionProbe>();
public List<PlanarReflectionProbe> planarReflectionProbesToBake = new List<PlanarReflectionProbe>();
public ReflectionBakeJob(BakeReflectionProbeRequest request)
{
this.request = request;
}
public void Tick()
{

if (m_CurrentStage == Stage.Completed)
{
request.progress = 1;
request.progress = 1;
return;
}

static void StageBakeReflectionProbe(ReflectionBakeJob job)
{
if (m_StageIndex >= job.reflectionProbesToBake.Count)
if (job.m_StageIndex >= job.reflectionProbesToBake.Count)
m_StageIndex = -1;
job.m_StageIndex = -1;
job.request.progress = (float)Stage.BakeReflectionProbe / (float)Stage.Completed;
job.request.progressMessage = string.Format("Reflection Probes ({0}/{1})", m_StageIndex + 1, job.reflectionProbesToBake.Count);
var stageProgress = job.reflectionProbesToBake.Count > 0
? 1f - job.m_StageIndex / (float)job.reflectionProbesToBake.Count
: 1f;
var probe = job.reflectionProbesToBake[m_StageIndex];
job.request.progress = ((float)Stage.BakeReflectionProbe + stageProgress) / (float)Stage.Completed;
job.request.progressMessage = string.Format("Reflection Probes ({0}/{1})", job.m_StageIndex + 1, job.reflectionProbesToBake.Count);
var probe = job.reflectionProbesToBake[job.m_StageIndex];
var target = s_ReflectionProbeBaker.NewRenderTarget(
probe,

importer.SaveAndReimport();
}
++m_StageIndex;
++job.m_StageIndex;
if (m_StageIndex >= job.planarReflectionProbesToBake.Count)
if (job.m_StageIndex >= job.planarReflectionProbesToBake.Count)
m_StageIndex = -1;
job.m_StageIndex = -1;
job.request.progress = (float)Stage.BakePlanarProbe / (float)Stage.Completed;
job.request.progressMessage = string.Format("Reflection Probes ({0}/{1})", m_StageIndex + 1, job.planarReflectionProbesToBake.Count);
var stageProgress = job.planarReflectionProbesToBake.Count > 0
? 1f - job.m_StageIndex / (float)job.planarReflectionProbesToBake.Count
: 1f;
var probe = job.planarReflectionProbesToBake[m_StageIndex];
job.request.progress = ((float)Stage.BakePlanarProbe + stageProgress) / (float)Stage.Completed;
job.request.progressMessage = string.Format("Reflection Probes ({0}/{1})", job.m_StageIndex + 1, job.planarReflectionProbesToBake.Count);
var probe = job.planarReflectionProbesToBake[job.m_StageIndex];
s_PlanarReflectionProbeBaker.Render(target, target);
s_PlanarReflectionProbeBaker.Render(probe, target);
var bakedTexture = probe.bakedTexture;

importer.SaveAndReimport();
}
++m_StageIndex;
++job.m_StageIndex;
}
}
}
正在加载...
取消
保存