浏览代码

[ReflectionProbeEditor] Initialize probe data in the Editor

/feature-ReflectionProbeFit
Frédéric Vauchelles 7 年前
当前提交
d9adbc5a
共有 6 个文件被更改,包括 35 次插入67 次删除
  1. 3
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.Data.cs
  2. 6
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.Drawers.cs
  3. 23
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.ProbeUtility.cs
  4. 29
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.cs
  5. 36
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/HDAdditionalReflectionData.cs
  6. 5
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightLoop/LightLoop.cs

3
ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.Data.cs


internal enum Operation
{
None = 0,
UpdateOldLocalSpace = 1 << 0,
FitVolumeToSurroundings = 1 << 1
FitVolumeToSurroundings = 1 << 0
}
internal class UIState

6
ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.Drawers.cs


{
var mode = (int)data;
if (mode == 0)
{
ResetAllProbeSceneTextureInMaterial();
}
},
GUILayout.ExpandWidth(true)))
{

static void Drawer_InfluenceSphereSettings(UIState s, SerializedReflectionProbe p, Editor owner)
{
EditorGUILayout.PropertyField(p.influenceSphereRadius, CoreEditorUtils.GetContent("Radius"));
EditorGUILayout.PropertyField(p.boxProjection, CoreEditorUtils.GetContent("Sphere Projection|Sphere projection causes reflections to appear to change based on the object's position within the probe's sphere, while still using a single probe as the source of the reflection. This works well for reflections on objects that are moving through enclosed spaces such as corridors and rooms. Setting sphere projection to False and the cubemap reflection will be treated as coming from infinitely far away. Note that this feature can be globally disabled from Graphics Settings -> Tier Settings"));
}
#endregion

switch (EditMode.editMode)
{
case EditMode.SceneViewEditMode.ReflectionProbeOrigin:
s.AddOperation(Operation.UpdateOldLocalSpace);
s.UpdateOldLocalSpace((ReflectionProbe)p.so.targetObject);
break;
}
}

23
ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.ProbeUtility.cs


hideFlags = HideFlags.HideAndDontSave
};
s_SphereMesh = Resources.GetBuiltinResource(typeof(Mesh), "New-Sphere.fbx") as Mesh;
HDAdditionalReflectionData.OnNewItem += OnNewProbe;
foreach (var data in HDAdditionalReflectionData.AllDatas)
OnNewProbe(data);
}
static void OnNewProbe(HDAdditionalReflectionData value)
{
InitializeProbe(value.GetComponent<ReflectionProbe>(), value);
}
static void InitializeProbe(ReflectionProbe p, HDAdditionalReflectionData data)

meshFilter.sharedMesh = s_SphereMesh;
var material = Object.Instantiate(s_PreviewMaterial);
material.SetTexture(_Cubemap, p.texture);
material.hideFlags = HideFlags.HideAndDontSave;
meshRenderer.material = material;
var material = meshRenderer.sharedMaterial;
if (material == null
|| material == s_PreviewMaterial
|| material.shader != s_PreviewMaterial.shader)
{
material = Object.Instantiate(s_PreviewMaterial);
material.SetTexture(_Cubemap, p.texture);
material.hideFlags = HideFlags.HideAndDontSave;
meshRenderer.material = material;
}
meshRenderer.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off;
meshRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;

29
ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.cs


var p = (ReflectionProbe)t;
s_ReflectionProbeEditors[p] = this;
}
for (var i = 0; i < targets.Length; ++i)
{
var p = (ReflectionProbe)targets[i];
var a = additionalData[i];
InitializeProbe(p, a);
ChangeVisibility(p, true);
}
}
void OnDisable()
{
for (var i = 0; i < targets.Length; ++i)
{
var p = (ReflectionProbe)targets[i];
ChangeVisibility(p, false);
}
}
public override void OnInspectorGUI()

static void PerformOperations(UIState s, SerializedReflectionProbe p, HDReflectionProbeEditor o)
{
if (s.HasAndClearOperation(Operation.UpdateOldLocalSpace))
s.UpdateOldLocalSpace((ReflectionProbe)p.so.targetObject);
}
void HideAdditionalComponents(bool visible)

{
var renderer = p.GetComponent<Renderer>();
renderer.sharedMaterial.SetTexture(_Cubemap, p.texture);
}
static void ResetAllProbeSceneTextureInMaterial()
{
foreach (var data in HDAdditionalReflectionData.AllDatas)
{
var p = data.GetComponent<ReflectionProbe>();
ResetProbeSceneTextureInMaterial(p);
}
}
}
}

36
ScriptableRenderPipeline/HDRenderPipeline/Lighting/HDAdditionalReflectionData.cs


using System;
using System.Collections.Generic;
namespace UnityEngine.Experimental.Rendering
namespace UnityEngine.Experimental.Rendering
[ExecuteInEditMode]
#region Registration
// We need to notify when a data is enabled
// So it can be properly initialized in the editor
public static event Action<HDAdditionalReflectionData> OnNewItem;
static List<HDAdditionalReflectionData> s_AllDatas = new List<HDAdditionalReflectionData>();
public static IEnumerable<HDAdditionalReflectionData> AllDatas { get { return s_AllDatas; } }
static void AddData(HDAdditionalReflectionData value)
{
s_AllDatas.Add(value);
if (OnNewItem != null)
OnNewItem(value);
}
static void RemoveData(HDAdditionalReflectionData value)
{
s_AllDatas.Remove(value);
}
#endregion
public ReflectionInfluenceShape influenceShape;
[Range(0.0f,1.0f)]
public float dimmer = 1.0f;

public Vector3 boxReprojectionVolumeCenter = Vector3.zero;
public float maxSearchDistance = 8.0f;
public Texture previewCubemap;
void OnEnable()
{
AddData(this);
}
void OnDisable()
{
RemoveData(this);
}
}
}

5
ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightLoop/LightLoop.cs


case ReflectionInfluenceShape.Box:
{
envLightData.envShapeType = EnvShapeType.Box;
if (probe.boxProjection == 0)
envLightData.minProjectionDistance = 65504.0f;
break;
}
case ReflectionInfluenceShape.Sphere:

}
if (probe.boxProjection == 0)
envLightData.minProjectionDistance = 65504.0f;
}
else
{

正在加载...
取消
保存