浏览代码

Fix multi gizmo texture previews

/hdrp-staging
RSlysz 6 年前
当前提交
c569ce67
共有 3 个文件被更改,包括 22 次插入12 次删除
  1. 18
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Gizmos.cs
  2. 12
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Preview.cs
  3. 4
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.cs

18
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Gizmos.cs


return;
var reflectionData = reflectionProbe.GetComponent<HDAdditionalReflectionData>();
Gizmos_CapturePoint(reflectionProbe, reflectionData, e);
if (reflectionProbe == e.target)
{
//will draw every preview, thus no need to do it multiple times
Gizmos_CapturePoint(e);
}
var mat = Matrix4x4.TRS(reflectionProbe.transform.position, reflectionProbe.transform.rotation, Vector3.one);
InfluenceVolumeUI.DrawGizmos(e.m_UIState.influenceVolume, reflectionData.influenceVolume, mat, InfluenceVolumeUI.HandleType.None, InfluenceVolumeUI.HandleType.Base);

}
}
static void Gizmos_CapturePoint(ReflectionProbe p, HDAdditionalReflectionData a, HDReflectionProbeEditor e)
static void Gizmos_CapturePoint(HDReflectionProbeEditor e)
{
if(sphere == null)
{

{
material = new Material(Shader.Find("Debug/ReflectionProbePreview"));
}
material.SetTexture("_Cubemap", e.GetTexture());
material.SetPass(0);
Graphics.DrawMeshNow(sphere, Matrix4x4.TRS(p.transform.position, Quaternion.identity, Vector3.one));
foreach (ReflectionProbe target in e.targets)
{
material.SetTexture("_Cubemap", GetTexture(e, target));
material.SetPass(0);
Graphics.DrawMeshNow(sphere, Matrix4x4.TRS(target.transform.position, Quaternion.identity, Vector3.one));
}
}
}
}

12
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Preview.cs


return false; // We only handle one preview for reflection probes
// Ensure valid cube map editor (if possible)
Texture texture = GetTexture();
Texture texture = GetTexture(this, target);
if (m_CubemapEditor != null && m_CubemapEditor.target as Texture != texture)
{
DestroyImmediate(m_CubemapEditor);

{
Editor editor = m_CubemapEditor;
CreateCachedEditor(GetTexture(), typeof(HDCubemapInspector), ref editor);
CreateCachedEditor(GetTexture(this, target), typeof(HDCubemapInspector), ref editor);
m_CubemapEditor = editor as HDCubemapInspector;
}

return;
}
Texture tex = GetTexture();
Texture tex = GetTexture(this, target);
if (tex != null && targets.Length == 1)
m_CubemapEditor.DrawPreview(position);
}

return GetTexture() != null;
return GetTexture(this, target) != null;
Texture GetTexture()
static Texture GetTexture(HDReflectionProbeEditor e, Object target)
HDProbe additional = GetTarget(target);
HDProbe additional = e.GetTarget(target);
if (additional != null && additional.mode == UnityEngine.Rendering.ReflectionProbeMode.Realtime)
{
return additional.realtimeTexture;

4
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.cs


using UnityEngine;
using UnityEngine.Assertions;
using UnityEngine.Experimental.Rendering.HDPipeline;
using System.Linq;
using UnityEngine.Rendering;
namespace UnityEditor.Experimental.Rendering.HDPipeline

internal override HDProbe GetTarget(Object editorTarget)
{
return (HDProbe)s_ReflectionProbeEditors[(ReflectionProbe)editorTarget].m_AdditionalDataSerializedObject.targetObject;
HDReflectionProbeEditor e = s_ReflectionProbeEditors[(ReflectionProbe)editorTarget];
return (HDProbe)e.m_AdditionalDataSerializedObject.targetObjects.First(a => ((HDAdditionalReflectionData)a).reflectionProbe == editorTarget);
}
protected override void Draw(HDProbeUI s, SerializedHDProbe serialized, Editor owner)

正在加载...
取消
保存