浏览代码

[ReflectionProbeEditor] Updated handles and color scheme

/feature-ReflectionProbeFit
Frédéric Vauchelles 7 年前
当前提交
7651d620
共有 5 个文件被更改,包括 100 次插入58 次删除
  1. 14
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.Data.cs
  2. 118
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.Handles.cs
  3. 19
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.cs
  4. 1
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/HDAdditionalReflectionData.cs
  5. 6
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightLoop/LightLoop.cs

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


internal SerializedProperty refreshMode;
internal SerializedProperty timeSlicingMode;
internal SerializedProperty intensityMultiplier;
internal SerializedProperty blendDistance;
internal SerializedProperty legacyBlendDistance;
internal SerializedProperty boxSize;
internal SerializedProperty boxOffset;
internal SerializedProperty resolution;

internal SerializedProperty boxReprojectionVolumeSize;
internal SerializedProperty boxReprojectionVolumeCenter;
internal SerializedProperty sphereReprojectionVolumeRadius;
internal SerializedProperty blendDistance;
internal SerializedProperty blendNormalDistance;
internal SerializedProperty dimmer;

refreshMode = so.FindProperty("m_RefreshMode");
timeSlicingMode = so.FindProperty("m_TimeSlicingMode");
intensityMultiplier = so.FindProperty("m_IntensityMultiplier");
blendDistance = so.FindProperty("m_BlendDistance");
boxSize = so.FindProperty("m_BoxSize");
boxOffset = so.FindProperty("m_BoxOffset");
resolution = so.FindProperty("m_Resolution");

nearClip = so.FindProperty("m_NearClip");
farClip = so.FindProperty("m_FarClip");
boxProjection = so.FindProperty("m_BoxProjection");
legacyBlendDistance = so.FindProperty("m_BlendDistance");
influenceShape = addso.Find((HDAdditionalReflectionData d) => d.influenceShape);
influenceSphereRadius = addso.Find((HDAdditionalReflectionData d) => d.influenceSphereRadius);

sphereReprojectionVolumeRadius = addso.Find((HDAdditionalReflectionData d) => d.sphereReprojectionVolumeRadius);
dimmer = addso.Find((HDAdditionalReflectionData d) => d.dimmer);
blendDistance = addso.Find((HDAdditionalReflectionData d) => d.blendDistance);
blendNormalDistance = addso.Find((HDAdditionalReflectionData d) => d.blendNormalDistance);
}
}

public void ClearOperation(Operation op) { operations &= ~op; }
public void AddOperation(Operation op) { operations |= op; }
public BoxBoundsHandle boxInfluenceBoundsHandle = new BoxBoundsHandle();
public BoxBoundsHandle boxProjectionBoundsHandle = new BoxBoundsHandle();
public BoxBoundsHandle boxExtentHandle = new BoxBoundsHandle();
public BoxBoundsHandle boxProjectionHandle = new BoxBoundsHandle();
public SphereBoundsHandle influenceSphereHandle = new SphereBoundsHandle();
public SphereBoundsHandle projectionSphereHandle = new SphereBoundsHandle();
public SphereBoundsHandle sphereExtentHandle = new SphereBoundsHandle();
public SphereBoundsHandle sphereProjectionHandle = new SphereBoundsHandle();
public SphereBoundsHandle sphereBlendHandle = new SphereBoundsHandle();
public SphereBoundsHandle sphereBlendNormalHandle = new SphereBoundsHandle();
public Matrix4x4 oldLocalSpace = Matrix4x4.identity;

118
ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.Handles.cs


{
partial class HDReflectionProbeEditor
{
internal static Color k_GizmoInfluenceVolume = new Color(0xFF / 255f, 0xE5 / 255f, 0x94 / 255f, 0x20 / 255f);
internal static Color k_GizmoInfluenceNormalVolume = new Color(0x00 / 255f, 0xE5 / 255f, 0xFF / 255f, 0x20 / 255f);
internal static Color k_GizmoReflectionProbeDisabled = new Color(0x99 / 255f, 0x89 / 255f, 0x59 / 255f, 0x10 / 255f);
internal static Color k_GizmoHandleReflectionProbe = new Color(0xFF / 255f, 0xE5 / 255f, 0xAA / 255f, 0xFF / 255f);
internal static Color k_GizmoThemeColorExtent = new Color(255f / 255f, 229f / 255f, 148f / 255f, 80f / 255f);
internal static Color k_GizmoThemeColorExtentFace = new Color(255f / 255f, 229f / 255f, 148f / 255f, 45f / 255f);
internal static Color k_GizmoThemeColorInfluenceBlend = new Color(83f / 255f, 255f / 255f, 95f / 255f, 75f / 255f);
internal static Color k_GizmoThemeColorInfluenceBlendFace = new Color(83f / 255f, 255f / 255f, 95f / 255f, 17f / 255f);
internal static Color k_GizmoThemeColorInfluenceNormalBlend = new Color(0f / 255f, 229f / 255f, 255f / 255f, 80f / 255f);
internal static Color k_GizmoThemeColorInfluenceNormalBlendFace = new Color(0f / 255f, 229f / 255f, 255f / 255f, 36f / 255f);
internal static Color k_GizmoThemeColorProjection = new Color(0x00 / 255f, 0xE5 / 255f, 0xFF / 255f, 0x20 / 255f);
internal static Color k_GizmoThemeColorProjectionFace = new Color(0x00 / 255f, 0xE5 / 255f, 0xFF / 255f, 0x20 / 255f);
internal static Color k_GizmoThemeColorDisabled = new Color(0x99 / 255f, 0x89 / 255f, 0x59 / 255f, 0x10 / 255f);
internal static Color k_GizmoThemeColorDisabledFace = new Color(0x99 / 255f, 0x89 / 255f, 0x59 / 255f, 0x10 / 255f);
void OnSceneGUI()
{

static void Handle_InfluenceBoxEditing(UIState s, SerializedReflectionProbe sp, Editor o)
{
var blendDistance = sp.target.blendDistance;
Handle_InfluenceBoxEditing_Internal(s, sp, o, s.boxBlendHandle, k_GizmoInfluenceVolume, ref blendDistance);
sp.target.blendDistance = blendDistance;
Handle_InfluenceBoxEditing_Internal(s, sp, o, s.boxBlendHandle, k_GizmoThemeColorInfluenceBlend, ref sp.targetData.blendDistance);
Handle_InfluenceBoxEditing_Internal(s, sp, o, s.boxBlendHandle, k_GizmoInfluenceNormalVolume, ref sp.targetData.blendNormalDistance);
Handle_InfluenceBoxEditing_Internal(s, sp, o, s.boxBlendHandle, k_GizmoThemeColorInfluenceNormalBlend, ref sp.targetData.blendNormalDistance);
static void Handle_InfluenceBoxEditing_Internal(UIState s, SerializedReflectionProbe sp, Editor o, BoxBoundsHandle blendBox, Color blendHandleColor, ref float probeBlendDistance)
static void Handle_InfluenceBoxEditing_Internal(
UIState s, SerializedReflectionProbe sp, Editor o,
BoxBoundsHandle blendBox,
Color blendHandleColor,
ref float probeBlendDistance)
s.boxInfluenceBoundsHandle.center = p.center;
s.boxInfluenceBoundsHandle.size = p.size;
s.boxExtentHandle.center = p.center;
s.boxExtentHandle.size = p.size;
Handles.color = k_GizmoThemeColorExtent;
s.boxInfluenceBoundsHandle.DrawHandle();
s.boxExtentHandle.DrawHandle();
var influenceChanged = EditorGUI.EndChangeCheck();
EditorGUI.BeginChangeCheck();
Handles.color = blendHandleColor;

Undo.RecordObject(p, "Modified Reflection Probe AABB");
var center = s.boxInfluenceBoundsHandle.center;
var influenceSize = s.boxInfluenceBoundsHandle.size;
var center = s.boxExtentHandle.center;
var influenceSize = s.boxExtentHandle.size;
var blendSize = blendBox.size;
ValidateAABB(p, ref center, ref influenceSize);
var blendDistance = influenceChanged

using (new Handles.DrawingScope(GetLocalSpace(p)))
{
s.boxProjectionBoundsHandle.center = reflectionData.boxReprojectionVolumeCenter;
s.boxProjectionBoundsHandle.size = reflectionData.boxReprojectionVolumeSize;
s.boxProjectionHandle.center = reflectionData.boxReprojectionVolumeCenter;
s.boxProjectionHandle.size = reflectionData.boxReprojectionVolumeSize;
s.boxProjectionBoundsHandle.DrawHandle();
s.boxProjectionHandle.DrawHandle();
var center = s.boxProjectionBoundsHandle.center;
var size = s.boxProjectionBoundsHandle.size;
var center = s.boxProjectionHandle.center;
var size = s.boxProjectionHandle.size;
ValidateAABB(p, ref center, ref size);
reflectionData.boxReprojectionVolumeCenter = center;
reflectionData.boxReprojectionVolumeSize = size;

static void Handle_InfluenceSphereEditing(UIState s, SerializedReflectionProbe sp, Editor o)
{
var blendDistance = sp.target.blendDistance;
Handle_InfluenceSphereEditing_Internal(s, sp, o, s.sphereBlendHandle, ref blendDistance);
sp.target.blendDistance = blendDistance;
Handle_InfluenceSphereEditing_Internal(s, sp, o, s.sphereBlendHandle, k_GizmoThemeColorInfluenceBlend, ref sp.targetData.blendDistance);
Handle_InfluenceSphereEditing_Internal(s, sp, o, s.sphereBlendHandle, ref sp.targetData.blendNormalDistance);
Handle_InfluenceSphereEditing_Internal(s, sp, o, s.sphereBlendHandle, k_GizmoThemeColorInfluenceNormalBlend, ref sp.targetData.blendNormalDistance);
static void Handle_InfluenceSphereEditing_Internal(UIState s, SerializedReflectionProbe sp, Editor o, SphereBoundsHandle sphereBlend, ref float probeBlendDistance)
static void Handle_InfluenceSphereEditing_Internal(
UIState s, SerializedReflectionProbe sp, Editor o,
SphereBoundsHandle sphereBlend,
Color blendHandleColor,
ref float probeBlendDistance)
{
var p = (ReflectionProbe)sp.so.targetObject;
var reflectionData = p.GetComponent<HDAdditionalReflectionData>();

s.influenceSphereHandle.center = p.center;
s.influenceSphereHandle.radius = reflectionData.influenceSphereRadius;
s.sphereExtentHandle.center = p.center;
s.sphereExtentHandle.radius = reflectionData.influenceSphereRadius;
Handles.color = k_GizmoThemeColorExtent;
s.influenceSphereHandle.DrawHandle();
s.sphereExtentHandle.DrawHandle();
Handles.color = blendHandleColor;
var influenceRadius = s.influenceSphereHandle.radius;
var influenceRadius = s.sphereExtentHandle.radius;
var blendRadius = influenceChanged
? Mathf.Max(influenceRadius - probeBlendDistance * 2, 0)
: sphereBlend.radius;

using (new Handles.DrawingScope(GetLocalSpace(p)))
{
s.projectionSphereHandle.center = p.center;
s.projectionSphereHandle.radius = reflectionData.sphereReprojectionVolumeRadius;
s.sphereProjectionHandle.center = p.center;
s.sphereProjectionHandle.radius = reflectionData.sphereReprojectionVolumeRadius;
s.projectionSphereHandle.DrawHandle();
s.sphereProjectionHandle.DrawHandle();
var center = s.projectionSphereHandle.center;
var radius = s.projectionSphereHandle.radius;
var center = s.sphereProjectionHandle.center;
var radius = s.sphereProjectionHandle.radius;
//ValidateAABB(ref center, ref radius);
reflectionData.sphereReprojectionVolumeRadius = radius;
EditorUtility.SetDirty(reflectionData);

case EditMode.SceneViewEditMode.ReflectionProbeBox:
{
var oldColor = Gizmos.color;
Gizmos.color = k_GizmoInfluenceVolume;
{
Gizmos.color = k_GizmoThemeColorExtentFace;
Gizmos.color = k_GizmoThemeColorInfluenceBlendFace;
Gizmos.DrawCube(reflectionProbe.center, -1f * reflectionProbe.size + Vector3.one * 2f * reflectionData.blendDistance);
}
{
Gizmos.color = k_GizmoThemeColorExtentFace;
Gizmos.color = k_GizmoThemeColorInfluenceBlendFace;
Gizmos.DrawSphere(reflectionProbe.center, reflectionData.influenceSphereRadius - reflectionData.blendDistance * 2f);
}
break;
break;
Gizmos.color = k_GizmoInfluenceNormalVolume;
Gizmos.color = k_GizmoThemeColorInfluenceNormalBlendFace;
Gizmos.matrix = GetLocalSpace(reflectionProbe);
if (reflectionData.influenceShape == ReflectionInfluenceShape.Box)

static void DrawBoxInfluenceGizmo(ReflectionProbe reflectionProbe, HDAdditionalReflectionData reflectionData)
{
var influenceColor = reflectionProbe.isActiveAndEnabled ? k_GizmoInfluenceVolume : k_GizmoReflectionProbeDisabled;
var influenceNormalColor = reflectionProbe.isActiveAndEnabled ? k_GizmoInfluenceNormalVolume : k_GizmoReflectionProbeDisabled;
Gizmos.color = influenceColor;
Gizmos.color = reflectionProbe.isActiveAndEnabled ? k_GizmoThemeColorExtent : k_GizmoThemeColorDisabled;
if (reflectionProbe.blendDistance > 0)
if (reflectionData.blendDistance > 0)
Gizmos.color = new Color(Gizmos.color.r, Gizmos.color.g, Gizmos.color.b, 0.3f);
Gizmos.DrawWireCube(reflectionProbe.center, GetBlendBoxSize(reflectionProbe, reflectionProbe.blendDistance));
Gizmos.color = reflectionProbe.isActiveAndEnabled ? k_GizmoThemeColorInfluenceBlend : k_GizmoThemeColorDisabled;
Gizmos.DrawWireCube(reflectionProbe.center, GetBlendBoxSize(reflectionProbe, reflectionData.blendDistance));
Gizmos.color = new Color(influenceNormalColor.r, influenceNormalColor.g, Gizmos.color.b, 0.3f);
Gizmos.color = reflectionProbe.isActiveAndEnabled ? k_GizmoThemeColorInfluenceNormalBlend : k_GizmoThemeColorDisabled;
Gizmos.DrawWireCube(reflectionProbe.center, GetBlendBoxSize(reflectionProbe, reflectionData.blendNormalDistance));
}
Gizmos.matrix = Matrix4x4.identity;

static void DrawSphereInfluenceGizmo(ReflectionProbe reflectionProbe, HDAdditionalReflectionData reflectionData)
{
var influenceColor = reflectionProbe.isActiveAndEnabled ? k_GizmoInfluenceVolume : k_GizmoReflectionProbeDisabled;
var influenceNormalColor = reflectionProbe.isActiveAndEnabled ? k_GizmoInfluenceNormalVolume : k_GizmoReflectionProbeDisabled;
Gizmos.color = influenceColor;
Gizmos.color = reflectionProbe.isActiveAndEnabled ? k_GizmoThemeColorExtent : k_GizmoThemeColorDisabled;
if (reflectionProbe.blendDistance > 0)
if (reflectionData.blendDistance > 0)
Gizmos.color = new Color(Gizmos.color.r, Gizmos.color.g, Gizmos.color.b, 0.3f);
Gizmos.DrawWireSphere(reflectionProbe.center, reflectionData.influenceSphereRadius - 2 * reflectionProbe.blendDistance);
Gizmos.color = reflectionProbe.isActiveAndEnabled ? k_GizmoThemeColorInfluenceBlend : k_GizmoThemeColorDisabled;
Gizmos.DrawWireSphere(reflectionProbe.center, reflectionData.influenceSphereRadius - 2 * reflectionData.blendDistance);
Gizmos.color = new Color(influenceNormalColor.r, influenceNormalColor.g, influenceNormalColor.b, 0.3f);
Gizmos.color = reflectionProbe.isActiveAndEnabled ? k_GizmoThemeColorInfluenceNormalBlend : k_GizmoThemeColorDisabled;
Gizmos.DrawWireSphere(reflectionProbe.center, reflectionData.influenceSphereRadius - 2 * reflectionData.blendNormalDistance);
}
Gizmos.matrix = Matrix4x4.identity;

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


public override void OnInspectorGUI()
{
//InspectColorsGUI();
// Set the legacy blend distance to 0 so the legacy culling system use the probe extent
p.legacyBlendDistance.floatValue = 0;
k_PrimarySection.Draw(s, p, this);
k_InfluenceVolumeSection.Draw(s, p, this);

{
return editMode == EditMode.SceneViewEditMode.ReflectionProbeBox || editMode == EditMode.SceneViewEditMode.Collider || editMode == EditMode.SceneViewEditMode.GridBox ||
editMode == EditMode.SceneViewEditMode.ReflectionProbeOrigin;
}
static void InspectColorsGUI()
{
EditorGUILayout.LabelField("Color Theme", EditorStyles.largeLabel);
k_GizmoThemeColorExtent = EditorGUILayout.ColorField("Extent", k_GizmoThemeColorExtent);
k_GizmoThemeColorExtentFace = EditorGUILayout.ColorField("Extent Face", k_GizmoThemeColorExtentFace);
k_GizmoThemeColorInfluenceBlend = EditorGUILayout.ColorField("Influence Blend", k_GizmoThemeColorInfluenceBlend);
k_GizmoThemeColorInfluenceBlendFace = EditorGUILayout.ColorField("Influence Blend Face", k_GizmoThemeColorInfluenceBlendFace);
k_GizmoThemeColorInfluenceNormalBlend = EditorGUILayout.ColorField("Influence Normal Blend", k_GizmoThemeColorInfluenceNormalBlend);
k_GizmoThemeColorInfluenceNormalBlendFace = EditorGUILayout.ColorField("Influence Normal Blend Face", k_GizmoThemeColorInfluenceNormalBlendFace);
k_GizmoThemeColorProjection = EditorGUILayout.ColorField("Projection", k_GizmoThemeColorProjection);
k_GizmoThemeColorProjectionFace = EditorGUILayout.ColorField("Projection Face", k_GizmoThemeColorProjectionFace);
k_GizmoThemeColorDisabled = EditorGUILayout.ColorField("Disabled", k_GizmoThemeColorDisabled);
k_GizmoThemeColorDisabledFace = EditorGUILayout.ColorField("Disabled Face", k_GizmoThemeColorDisabledFace);
}
static void BakeCustomReflectionProbe(ReflectionProbe probe, bool usePreviousAssetPath, bool custom)

1
ScriptableRenderPipeline/HDRenderPipeline/Lighting/HDAdditionalReflectionData.cs


public Vector3 boxReprojectionVolumeCenter = Vector3.zero;
public float maxSearchDistance = 8.0f;
public Texture previewCubemap;
public float blendDistance = 0f;
public float blendNormalDistance = 0f;
}
}

6
ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightLoop/LightLoop.cs


{
var additionalData = probe.probe.GetComponent<HDAdditionalReflectionData>();
var extents = probe.bounds.extents;
var influenceBlendDistance = probe.blendDistance;
// For now we won't display real time probe when rendering one.
// TODO: We may want to display last frame result but in this case we need to be careful not to update the atlas before all realtime probes are rendered (for frame coherency).

envLightData.dimmer = additionalData.dimmer;
envLightData.blendNormalDistance = additionalData.blendNormalDistance;
influenceBlendDistance = additionalData.blendDistance;
}
else
{

// So we let the current UI but we assume blendDistance is an inside factor instead
// Blend distance can't be larger than the max radius
// probe.bounds.extents is BoxSize / 2
float maxBlendDist = Mathf.Min(probe.bounds.extents.x, Mathf.Min(probe.bounds.extents.y, probe.bounds.extents.z));
float blendDistance = Mathf.Min(maxBlendDist, probe.blendDistance);
var maxBlendDist = Mathf.Min(probe.bounds.extents.x, Mathf.Min(probe.bounds.extents.y, probe.bounds.extents.z));
var blendDistance = Mathf.Min(maxBlendDist, influenceBlendDistance);
envLightData.innerDistance = extents - new Vector3(blendDistance, blendDistance, blendDistance);
envLightData.envIndex = envIndex;
envLightData.offsetLS = probe.center; // center is misnamed, it is the offset (in local space) from center of the bounding box to the cubemap capture point

正在加载...
取消
保存