Paul Melamed
6 年前
当前提交
f1d163d5
共有 75 个文件被更改,包括 3088 次插入 和 2605 次删除
-
999TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/2207_ReflectionProbeVFace.png
-
15TestProjects/HDRP_Tests/ProjectSettings/EditorBuildSettings.asset
-
15com.unity.render-pipelines.core/CoreRP/CoreResources/TexturePadding.cs
-
29com.unity.render-pipelines.core/CoreRP/Editor/CoreEditorUtils.cs
-
2com.unity.render-pipelines.core/CoreRP/Textures/RTHandleSystem.cs
-
1com.unity.render-pipelines.high-definition/CHANGELOG.md
-
8com.unity.render-pipelines.high-definition/HDRP/Camera/HDCamera.cs
-
2com.unity.render-pipelines.high-definition/HDRP/Debug/DebugDisplay.cs
-
2com.unity.render-pipelines.high-definition/HDRP/Debug/LightingDebug.cs
-
3com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/EditorReflectionSystem.cs
-
2com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Gizmos.cs
-
34com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Preview.cs
-
2com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.ProbeUtility.cs
-
133com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.cs
-
532com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeUI.Drawers.cs
-
102com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeUI.cs
-
89com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeEditor.cs
-
2com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeEditor.cs.meta
-
212com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.Handles.cs
-
2com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.Handles.cs.meta
-
121com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.cs
-
2com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.cs.meta
-
109com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDReflectionProbe.cs
-
81com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedPlanarReflectionProbe.cs
-
163com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Drawers.cs
-
311com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Handles.cs
-
20com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.cs
-
135com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/ProxyVolumeUI.cs
-
9com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/ReflectionProxyVolumeComponentUI.cs
-
29com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/SerializedInfluenceVolume.cs
-
2com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.ContextualMenu.cs
-
3com.unity.render-pipelines.high-definition/HDRP/Editor/ShaderGraph/SharedCode.template.hlsl
-
4com.unity.render-pipelines.high-definition/HDRP/Lighting/Light/HDAdditionalLightData.cs
-
317com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoop.cs
-
10com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoopDef.hlsl
-
69com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDAdditionalReflectionData.cs
-
25com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDProbe.cs
-
19com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/PlanarReflectionProbe.cs
-
29com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ProbeWrapper.cs
-
10com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ReflectionSystem.cs
-
166com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ReflectionSystemInternal.cs
-
14com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ReflectionSystemParameters.cs
-
16com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/Volumes/InfluenceVolume.cs
-
8com.unity.render-pipelines.high-definition/HDRP/Lighting/Volumetrics/VolumetricLighting.cs
-
22com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs
-
4com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipelineAsset.cs
-
1com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDStringConstants.cs
-
1com.unity.render-pipelines.high-definition/HDRP/RenderPipelineResources/HDRenderPipelineResources.asset
-
2com.unity.render-pipelines.high-definition/HDRP/RenderPipelineResources/RenderPipelineResources.cs
-
3com.unity.render-pipelines.high-definition/HDRP/ShaderPass/VaryingMesh.hlsl
-
1com.unity.render-pipelines.high-definition/HDRP/ShaderVariables.hlsl
-
3com.unity.testframework.graphics/Runtime/EditorGraphicsTestCaseProvider.cs
-
506com.unity.render-pipelines.core/CoreRP/Debugging/DebugShapes.cs
-
11com.unity.render-pipelines.core/CoreRP/Debugging/DebugShapes.cs.meta
-
58com.unity.render-pipelines.high-definition/HDRP/Debug/DebugLightVolume.shader
-
9com.unity.render-pipelines.high-definition/HDRP/Debug/DebugLightVolume.shader.meta
-
80com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeEditor.cs
-
11com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeEditor.cs.meta
-
297com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Drawers.cs
-
101com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Handles.cs
-
11com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Handles.cs.meta
-
77com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Skin.cs
-
11com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Skin.cs.meta
-
90com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.cs
-
11com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.cs.meta
-
57com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDProbe.cs
-
11com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDProbe.cs.meta
-
34com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Skin.cs
-
11com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Skin.cs.meta
-
11com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Handles.cs.meta
-
312com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.Drawers.cs
-
89com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Handles.cs
-
0/com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Drawers.cs.meta
-
0/com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.ContextualMenu.cs.meta
-
0/com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.ContextualMenu.cs
999
TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/2207_ReflectionProbeVFace.png
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
using System; |
|||
using UnityEditor.AnimatedValues; |
|||
using UnityEngine.Events; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
using UnityEngine.Rendering; |
|||
|
|||
partial class PlanarReflectionProbeUI : BaseUI<SerializedPlanarReflectionProbe> |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
using UnityEngine.Rendering; |
|||
using CED = CoreEditorDrawer<HDProbeUI, SerializedHDProbe>; |
|||
|
|||
partial class PlanarReflectionProbeUI : HDProbeUI |
|||
const int k_AnimBoolFields = 6; |
|||
static readonly int k_ReflectionProbeModeModeCount = Enum.GetValues(typeof(ReflectionProbeMode)).Length; |
|||
static readonly int k_AnimBoolTotal = k_AnimBoolFields + k_ReflectionProbeModeModeCount; |
|||
static readonly GUIContent overrideFieldOfViewContent = CoreEditorUtils.GetContent("Override Field Of View"); |
|||
static readonly GUIContent fieldOfViewSolidAngleContent = CoreEditorUtils.GetContent("Field Of View"); |
|||
public InfluenceVolumeUI influenceVolume = new InfluenceVolumeUI(); |
|||
public FrameSettingsUI frameSettings = new FrameSettingsUI(); |
|||
public ReflectionProxyVolumeComponentUI reflectionProxyVolume = new ReflectionProxyVolumeComponentUI(); |
|||
public static CED.IDrawer Inspector; |
|||
|
|||
public static readonly CED.IDrawer SectionFoldoutCaptureSettings = CED.FoldoutGroup( |
|||
"Capture Settings", |
|||
(s, d, o) => s.isSectionExpandedCaptureSettings, |
|||
FoldoutOption.Indent, |
|||
CED.Action(Drawer_SectionCaptureSettings) |
|||
); |
|||
public AnimBool isSectionExpandedInfluenceSettings { get { return m_AnimBools[k_ReflectionProbeModeModeCount]; } } |
|||
public AnimBool isSectionExpandedCaptureSettings { get { return m_AnimBools[k_ReflectionProbeModeModeCount + 1]; } } |
|||
|
|||
public AnimBool isSectionExpandedCaptureMirrorSettings { get { return m_AnimBools[k_ReflectionProbeModeModeCount + 2]; } } |
|||
public AnimBool isSectionExpandedCaptureStaticSettings { get { return m_AnimBools[k_ReflectionProbeModeModeCount + 3]; } } |
|||
public AnimBool isSectionExpendedProxyVolume { get { return m_AnimBools[k_ReflectionProbeModeModeCount + 4]; } } |
|||
public AnimBool isSectionExpendedAdditionalSettings { get { return m_AnimBools[k_ReflectionProbeModeModeCount + 5]; } } |
|||
|
|||
public bool showCaptureHandles { get; set; } |
|||
|
|||
public PlanarReflectionProbeUI() |
|||
: base(k_AnimBoolTotal) |
|||
static PlanarReflectionProbeUI() |
|||
isSectionExpandedInfluenceSettings.value = true; |
|||
isSectionExpandedCaptureSettings.value = true; |
|||
isSectionExpendedProxyVolume.value = true; |
|||
isSectionExpendedAdditionalSettings.value = false; |
|||
Inspector = CED.Group( |
|||
CED.Action(Drawer_Toolbars), |
|||
CED.space, |
|||
ProxyVolumeSettings, |
|||
CED.Select( |
|||
(s, d, o) => s.influenceVolume, |
|||
(s, d, o) => d.influenceVolume, |
|||
InfluenceVolumeUI.SectionFoldoutShapePlanar |
|||
), |
|||
CED.Action(Drawer_DifferentShapeError), |
|||
SectionFoldoutCaptureSettings, |
|||
SectionFoldoutAdditionalSettings, |
|||
CED.Select( |
|||
(s, d, o) => s.frameSettings, |
|||
(s, d, o) => d.frameSettings, |
|||
FrameSettingsUI.Inspector |
|||
), |
|||
CED.space, |
|||
CED.Action(Drawer_SectionBakeButton) |
|||
); |
|||
public AnimBool IsSectionExpandedReflectionProbeMode(ReflectionProbeMode mode) |
|||
protected static void Drawer_SectionCaptureSettings(HDProbeUI s, SerializedHDProbe d, Editor o) |
|||
return m_AnimBools[(int)mode]; |
|||
SerializedPlanarReflectionProbe serialized = (SerializedPlanarReflectionProbe)d; |
|||
var hdrp = GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset; |
|||
GUI.enabled = false; |
|||
EditorGUILayout.LabelField( |
|||
CoreEditorUtils.GetContent("Probe Texture Size (Set By HDRP)"), |
|||
CoreEditorUtils.GetContent(hdrp.renderPipelineSettings.lightLoopSettings.planarReflectionTextureSize.ToString()), |
|||
EditorStyles.label); |
|||
EditorGUILayout.Toggle( |
|||
CoreEditorUtils.GetContent("Probe Compression (Set By HDRP)"), |
|||
hdrp.renderPipelineSettings.lightLoopSettings.planarReflectionCacheCompressed); |
|||
GUI.enabled = true; |
|||
|
|||
bool on = serialized.overrideFieldOfView.boolValue; |
|||
EditorGUI.BeginChangeCheck(); |
|||
on = EditorGUILayout.Toggle(overrideFieldOfViewContent, on); |
|||
if (on) |
|||
{ |
|||
serialized.fieldOfViewOverride.floatValue = EditorGUILayout.FloatField(fieldOfViewSolidAngleContent, serialized.fieldOfViewOverride.floatValue); |
|||
} |
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
serialized.overrideFieldOfView.boolValue = on; |
|||
serialized.Apply(); |
|||
} |
|||
|
|||
//GUI.enabled = false;
|
|||
//EditorGUILayout.LabelField(resolutionContent, CoreEditorUtils.GetContent(((int)hdrp.GetRenderPipelineSettings().lightLoopSettings.reflectionCubemapSize).ToString()));
|
|||
//EditorGUILayout.LabelField(shadowDistanceContent, EditorStyles.label);
|
|||
//EditorGUILayout.LabelField(cullingMaskContent, EditorStyles.label);
|
|||
//EditorGUILayout.LabelField(useOcclusionCullingContent, EditorStyles.label);
|
|||
//EditorGUILayout.LabelField(nearClipCullingContent, EditorStyles.label);
|
|||
//EditorGUILayout.LabelField(farClipCullingContent, EditorStyles.label);
|
|||
//GUI.enabled = true;
|
|||
public override void Reset(SerializedPlanarReflectionProbe data, UnityAction repaint) |
|||
internal PlanarReflectionProbeUI() |
|||
reflectionProxyVolume.Reset(data.reflectionProxyVolume, repaint); |
|||
frameSettings.Reset(data.frameSettings, repaint); |
|||
influenceVolume.Reset(data.influenceVolume, repaint); |
|||
base.Reset(data, repaint); |
|||
toolBars = new[] { ToolBar.InfluenceShape | ToolBar.Blend }; |
|||
for (var i = 0; i < k_ReflectionProbeModeModeCount; i++) |
|||
m_AnimBools[i].target = i == data.mode.intValue; |
|||
|
|||
isSectionExpandedCaptureMirrorSettings.target = data.isMirrored; |
|||
isSectionExpandedCaptureStaticSettings.target = !data.isMirrored; |
|||
|
|||
reflectionProxyVolume.Update(); |
|||
frameSettings.Update(); |
|||
influenceVolume.Update(); |
|||
SerializedPlanarReflectionProbe serialized = data as SerializedPlanarReflectionProbe; |
|||
isSectionExpandedCaptureMirrorSettings.target = serialized.isMirrored; |
|||
isSectionExpandedCaptureStaticSettings.target = !serialized.isMirrored; |
|||
base.Update(); |
|||
} |
|||
} |
|
|||
namespace UnityEngine.Experimental.Rendering |
|||
{ |
|||
public partial class DebugShapes |
|||
{ |
|||
// Singleton
|
|||
static DebugShapes s_Instance = null; |
|||
|
|||
static public DebugShapes instance |
|||
{ |
|||
get |
|||
{ |
|||
if (s_Instance == null) |
|||
{ |
|||
s_Instance = new DebugShapes(); |
|||
} |
|||
|
|||
return s_Instance; |
|||
} |
|||
} |
|||
|
|||
Mesh m_sphereMesh = null; |
|||
Mesh m_boxMesh = null; |
|||
Mesh m_coneMesh = null; |
|||
Mesh m_pyramidMesh = null; |
|||
|
|||
// This code has been grabbed from http://wiki.unity3d.com/index.php/ProceduralPrimitives
|
|||
void BuildSphere(ref Mesh outputMesh, float radius, uint longSubdiv, uint latSubdiv) |
|||
{ |
|||
// Make sure it is empty before pushing anything to it
|
|||
outputMesh.Clear(); |
|||
|
|||
// Build the vertices array
|
|||
Vector3[] vertices = new Vector3[(longSubdiv + 1) * latSubdiv + 2]; |
|||
float _pi = Mathf.PI; |
|||
float _2pi = _pi * 2f; |
|||
|
|||
vertices[0] = Vector3.up * radius; |
|||
for (int lat = 0; lat < latSubdiv; lat++) |
|||
{ |
|||
float a1 = _pi * (float)(lat + 1) / (latSubdiv + 1); |
|||
float sin1 = Mathf.Sin(a1); |
|||
float cos1 = Mathf.Cos(a1); |
|||
|
|||
for (int lon = 0; lon <= longSubdiv; lon++) |
|||
{ |
|||
float a2 = _2pi * (float)(lon == longSubdiv ? 0 : lon) / longSubdiv; |
|||
float sin2 = Mathf.Sin(a2); |
|||
float cos2 = Mathf.Cos(a2); |
|||
|
|||
vertices[lon + lat * (longSubdiv + 1) + 1] = new Vector3(sin1 * cos2, cos1, sin1 * sin2) * radius; |
|||
} |
|||
} |
|||
vertices[vertices.Length - 1] = Vector3.up * -radius; |
|||
|
|||
// Build the normals array
|
|||
Vector3[] normals = new Vector3[vertices.Length]; |
|||
for (int n = 0; n < vertices.Length; n++) |
|||
{ |
|||
normals[n] = vertices[n].normalized; |
|||
} |
|||
|
|||
// Build the UV array
|
|||
Vector2[] uvs = new Vector2[vertices.Length]; |
|||
uvs[0] = Vector2.up; |
|||
uvs[uvs.Length - 1] = Vector2.zero; |
|||
for (int lat = 0; lat < latSubdiv; lat++) |
|||
{ |
|||
for (int lon = 0; lon <= longSubdiv; lon++) |
|||
{ |
|||
uvs[lon + lat * (longSubdiv + 1) + 1] = new Vector2((float)lon / longSubdiv, 1f - (float)(lat + 1) / (latSubdiv + 1)); |
|||
} |
|||
} |
|||
|
|||
// Build the index array
|
|||
int nbFaces = vertices.Length; |
|||
int nbTriangles = nbFaces * 2; |
|||
int nbIndexes = nbTriangles * 3; |
|||
int[] triangles = new int[nbIndexes]; |
|||
|
|||
// Top Cap
|
|||
int i = 0; |
|||
for (int lon = 0; lon < longSubdiv; lon++) |
|||
{ |
|||
triangles[i++] = lon + 2; |
|||
triangles[i++] = lon + 1; |
|||
triangles[i++] = 0; |
|||
} |
|||
|
|||
//Middle
|
|||
for (uint lat = 0; lat < latSubdiv - 1; lat++) |
|||
{ |
|||
for (uint lon = 0; lon < longSubdiv; lon++) |
|||
{ |
|||
uint current = lon + lat * (longSubdiv + 1) + 1; |
|||
uint next = current + longSubdiv + 1; |
|||
|
|||
triangles[i++] = (int)current; |
|||
triangles[i++] = (int)current + 1; |
|||
triangles[i++] = (int)next + 1; |
|||
|
|||
triangles[i++] = (int)current; |
|||
triangles[i++] = (int)next + 1; |
|||
triangles[i++] = (int)next; |
|||
} |
|||
} |
|||
|
|||
// Bottom Cap
|
|||
for (int lon = 0; lon < longSubdiv; lon++) |
|||
{ |
|||
triangles[i++] = vertices.Length - 1; |
|||
triangles[i++] = vertices.Length - (lon + 2) - 1; |
|||
triangles[i++] = vertices.Length - (lon + 1) - 1; |
|||
} |
|||
|
|||
// Assign them to
|
|||
outputMesh.vertices = vertices; |
|||
outputMesh.normals = normals; |
|||
outputMesh.uv = uvs; |
|||
outputMesh.triangles = triangles; |
|||
|
|||
outputMesh.RecalculateBounds(); |
|||
} |
|||
|
|||
void BuildBox(ref Mesh outputMesh, float length, float width, float height) |
|||
{ |
|||
outputMesh.Clear(); |
|||
|
|||
Vector3 p0 = new Vector3(-length * .5f, -width * .5f, height * .5f); |
|||
Vector3 p1 = new Vector3(length * .5f, -width * .5f, height * .5f); |
|||
Vector3 p2 = new Vector3(length * .5f, -width * .5f, -height * .5f); |
|||
Vector3 p3 = new Vector3(-length * .5f, -width * .5f, -height * .5f); |
|||
|
|||
Vector3 p4 = new Vector3(-length * .5f, width * .5f, height * .5f); |
|||
Vector3 p5 = new Vector3(length * .5f, width * .5f, height * .5f); |
|||
Vector3 p6 = new Vector3(length * .5f, width * .5f, -height * .5f); |
|||
Vector3 p7 = new Vector3(-length * .5f, width * .5f, -height * .5f); |
|||
|
|||
Vector3[] vertices = new Vector3[] |
|||
{ |
|||
// Bottom
|
|||
p0, p1, p2, p3, |
|||
// Left
|
|||
p7, p4, p0, p3, |
|||
// Front
|
|||
p4, p5, p1, p0, |
|||
// Back
|
|||
p6, p7, p3, p2, |
|||
// Right
|
|||
p5, p6, p2, p1, |
|||
// Top
|
|||
p7, p6, p5, p4 |
|||
}; |
|||
|
|||
Vector3 up = Vector3.up; |
|||
Vector3 down = Vector3.down; |
|||
Vector3 front = Vector3.forward; |
|||
Vector3 back = Vector3.back; |
|||
Vector3 left = Vector3.left; |
|||
Vector3 right = Vector3.right; |
|||
|
|||
Vector3[] normales = new Vector3[] |
|||
{ |
|||
// Bottom
|
|||
down, down, down, down, |
|||
// Left
|
|||
left, left, left, left, |
|||
// Front
|
|||
front, front, front, front, |
|||
// Back
|
|||
back, back, back, back, |
|||
// Right
|
|||
right, right, right, right, |
|||
// Top
|
|||
up, up, up, up |
|||
}; |
|||
|
|||
Vector2 _00 = new Vector2(0f, 0f); |
|||
Vector2 _10 = new Vector2(1f, 0f); |
|||
Vector2 _01 = new Vector2(0f, 1f); |
|||
Vector2 _11 = new Vector2(1f, 1f); |
|||
|
|||
Vector2[] uvs = new Vector2[] |
|||
{ |
|||
// Bottom
|
|||
_11, _01, _00, _10, |
|||
// Left
|
|||
_11, _01, _00, _10, |
|||
// Front
|
|||
_11, _01, _00, _10, |
|||
// Back
|
|||
_11, _01, _00, _10, |
|||
// Right
|
|||
_11, _01, _00, _10, |
|||
// Top
|
|||
_11, _01, _00, _10, |
|||
}; |
|||
|
|||
int[] triangles = new int[] |
|||
{ |
|||
// Bottom
|
|||
3, 1, 0, |
|||
3, 2, 1, |
|||
// Left
|
|||
3 + 4 * 1, 1 + 4 * 1, 0 + 4 * 1, |
|||
3 + 4 * 1, 2 + 4 * 1, 1 + 4 * 1, |
|||
// Front
|
|||
3 + 4 * 2, 1 + 4 * 2, 0 + 4 * 2, |
|||
3 + 4 * 2, 2 + 4 * 2, 1 + 4 * 2, |
|||
// Back
|
|||
3 + 4 * 3, 1 + 4 * 3, 0 + 4 * 3, |
|||
3 + 4 * 3, 2 + 4 * 3, 1 + 4 * 3, |
|||
// Right
|
|||
3 + 4 * 4, 1 + 4 * 4, 0 + 4 * 4, |
|||
3 + 4 * 4, 2 + 4 * 4, 1 + 4 * 4, |
|||
// Top
|
|||
3 + 4 * 5, 1 + 4 * 5, 0 + 4 * 5, |
|||
3 + 4 * 5, 2 + 4 * 5, 1 + 4 * 5, |
|||
}; |
|||
|
|||
outputMesh.vertices = vertices; |
|||
outputMesh.normals = normales; |
|||
outputMesh.uv = uvs; |
|||
outputMesh.triangles = triangles; |
|||
|
|||
outputMesh.RecalculateBounds(); |
|||
} |
|||
|
|||
void BuildCone(ref Mesh outputMesh, float height, float topRadius, float bottomRadius, int nbSides) |
|||
{ |
|||
outputMesh.Clear(); |
|||
|
|||
int nbVerticesCap = nbSides + 1; |
|||
|
|||
// bottom + top + sides
|
|||
Vector3[] vertices = new Vector3[nbVerticesCap + nbVerticesCap + nbSides * 2 + 2]; |
|||
int vert = 0; |
|||
float _2pi = Mathf.PI * 2f; |
|||
|
|||
// Bottom cap
|
|||
vertices[vert++] = new Vector3(0f, 0f, 0f); |
|||
while (vert <= nbSides) |
|||
{ |
|||
float rad = (float)vert / nbSides * _2pi; |
|||
vertices[vert] = new Vector3(Mathf.Sin(rad) * bottomRadius, Mathf.Cos(rad) * bottomRadius, 0f); |
|||
vert++; |
|||
} |
|||
|
|||
// Top cap
|
|||
vertices[vert++] = new Vector3(0f, 0f , height); |
|||
while (vert <= nbSides * 2 + 1) |
|||
{ |
|||
float rad = (float)(vert - nbSides - 1) / nbSides * _2pi; |
|||
vertices[vert] = new Vector3(Mathf.Sin(rad) * topRadius, Mathf.Cos(rad) * topRadius, height); |
|||
vert++; |
|||
} |
|||
|
|||
// Sides
|
|||
int v = 0; |
|||
while (vert <= vertices.Length - 4) |
|||
{ |
|||
float rad = (float)v / nbSides * _2pi; |
|||
vertices[vert] = new Vector3(Mathf.Sin(rad) * topRadius, Mathf.Cos(rad) * topRadius, height); |
|||
vertices[vert + 1] = new Vector3(Mathf.Sin(rad) * bottomRadius, Mathf.Cos(rad) * bottomRadius, 0); |
|||
vert += 2; |
|||
v++; |
|||
} |
|||
vertices[vert] = vertices[nbSides * 2 + 2]; |
|||
vertices[vert + 1] = vertices[nbSides * 2 + 3]; |
|||
|
|||
// bottom + top + sides
|
|||
Vector3[] normales = new Vector3[vertices.Length]; |
|||
vert = 0; |
|||
|
|||
// Bottom cap
|
|||
while (vert <= nbSides) |
|||
{ |
|||
normales[vert++] = new Vector3(0, 0, -1); |
|||
} |
|||
|
|||
// Top cap
|
|||
while (vert <= nbSides * 2 + 1) |
|||
{ |
|||
normales[vert++] = new Vector3(0, 0, 1); |
|||
} |
|||
|
|||
// Sides
|
|||
v = 0; |
|||
while (vert <= vertices.Length - 4) |
|||
{ |
|||
float rad = (float)v / nbSides * _2pi; |
|||
float cos = Mathf.Cos(rad); |
|||
float sin = Mathf.Sin(rad); |
|||
|
|||
normales[vert] = new Vector3(sin, cos, 0f); |
|||
normales[vert + 1] = normales[vert]; |
|||
|
|||
vert += 2; |
|||
v++; |
|||
} |
|||
normales[vert] = normales[nbSides * 2 + 2]; |
|||
normales[vert + 1] = normales[nbSides * 2 + 3]; |
|||
|
|||
Vector2[] uvs = new Vector2[vertices.Length]; |
|||
|
|||
// Bottom cap
|
|||
int u = 0; |
|||
uvs[u++] = new Vector2(0.5f, 0.5f); |
|||
while (u <= nbSides) |
|||
{ |
|||
float rad = (float)u / nbSides * _2pi; |
|||
uvs[u] = new Vector2(Mathf.Cos(rad) * .5f + .5f, Mathf.Sin(rad) * .5f + .5f); |
|||
u++; |
|||
} |
|||
|
|||
// Top cap
|
|||
uvs[u++] = new Vector2(0.5f, 0.5f); |
|||
while (u <= nbSides * 2 + 1) |
|||
{ |
|||
float rad = (float)u / nbSides * _2pi; |
|||
uvs[u] = new Vector2(Mathf.Cos(rad) * .5f + .5f, Mathf.Sin(rad) * .5f + .5f); |
|||
u++; |
|||
} |
|||
|
|||
// Sides
|
|||
int u_sides = 0; |
|||
while (u <= uvs.Length - 4) |
|||
{ |
|||
float t = (float)u_sides / nbSides; |
|||
uvs[u] = new Vector3(t, 1f); |
|||
uvs[u + 1] = new Vector3(t, 0f); |
|||
u += 2; |
|||
u_sides++; |
|||
} |
|||
uvs[u] = new Vector2(1f, 1f); |
|||
uvs[u + 1] = new Vector2(1f, 0f); |
|||
|
|||
int nbTriangles = nbSides + nbSides + nbSides * 2; |
|||
int[] triangles = new int[nbTriangles * 3 + 3]; |
|||
|
|||
// Bottom cap
|
|||
int tri = 0; |
|||
int i = 0; |
|||
while (tri < nbSides - 1) |
|||
{ |
|||
triangles[i] = 0; |
|||
triangles[i + 1] = tri + 1; |
|||
triangles[i + 2] = tri + 2; |
|||
tri++; |
|||
i += 3; |
|||
} |
|||
triangles[i] = 0; |
|||
triangles[i + 1] = tri + 1; |
|||
triangles[i + 2] = 1; |
|||
tri++; |
|||
i += 3; |
|||
|
|||
// Top cap
|
|||
//tri++;
|
|||
while (tri < nbSides * 2) |
|||
{ |
|||
triangles[i] = tri + 2; |
|||
triangles[i + 1] = tri + 1; |
|||
triangles[i + 2] = nbVerticesCap; |
|||
tri++; |
|||
i += 3; |
|||
} |
|||
|
|||
triangles[i] = nbVerticesCap + 1; |
|||
triangles[i + 1] = tri + 1; |
|||
triangles[i + 2] = nbVerticesCap; |
|||
tri++; |
|||
i += 3; |
|||
tri++; |
|||
|
|||
// Sides
|
|||
while (tri <= nbTriangles) |
|||
{ |
|||
triangles[i] = tri + 2; |
|||
triangles[i + 1] = tri + 1; |
|||
triangles[i + 2] = tri + 0; |
|||
tri++; |
|||
i += 3; |
|||
|
|||
triangles[i] = tri + 1; |
|||
triangles[i + 1] = tri + 2; |
|||
triangles[i + 2] = tri + 0; |
|||
tri++; |
|||
i += 3; |
|||
} |
|||
|
|||
outputMesh.vertices = vertices; |
|||
outputMesh.normals = normales; |
|||
outputMesh.uv = uvs; |
|||
outputMesh.triangles = triangles; |
|||
|
|||
outputMesh.RecalculateBounds(); |
|||
} |
|||
|
|||
void BuildPyramid(ref Mesh outputMesh, float width, float height, float depth) |
|||
{ |
|||
outputMesh.Clear(); |
|||
|
|||
// Allocate the buffer
|
|||
Vector3[] vertices = new Vector3[16]; |
|||
|
|||
// Top Face
|
|||
vertices[0] = new Vector3(0f, 0f, 0f); |
|||
vertices[1] = new Vector3(-width/2.0f, height / 2.0f, depth); |
|||
vertices[2] = new Vector3( width / 2.0f, height / 2.0f, depth); |
|||
|
|||
// Left Face
|
|||
vertices[3] = new Vector3(0f, 0f, 0f); |
|||
vertices[4] = new Vector3(width / 2.0f, height / 2.0f, depth); |
|||
vertices[5] = new Vector3(width / 2.0f, -height / 2.0f, depth); |
|||
|
|||
// Bottom Face
|
|||
vertices[6] = new Vector3(0f, 0f, 0f); |
|||
vertices[7] = new Vector3(width / 2.0f, -height / 2.0f, depth); |
|||
vertices[8] = new Vector3(-width / 2.0f, -height / 2.0f, depth); |
|||
|
|||
// Right Face
|
|||
vertices[9] = new Vector3(0f, 0f, 0f); |
|||
vertices[10] = new Vector3(-width / 2.0f, -height / 2.0f, depth); |
|||
vertices[11] = new Vector3(-width / 2.0f, height / 2.0f, depth); |
|||
|
|||
// Cap
|
|||
vertices[12] = new Vector3(-width / 2.0f, height / 2.0f, depth); |
|||
vertices[13] = new Vector3(-width / 2.0f, -height / 2.0f, depth); |
|||
vertices[14] = new Vector3(width / 2.0f, -height / 2.0f, depth); |
|||
vertices[15] = new Vector3(width / 2.0f, height / 2.0f, depth); |
|||
|
|||
// TODO: support the uv/normals
|
|||
Vector3[] normals = new Vector3[vertices.Length]; |
|||
Vector2[] uvs = new Vector2[vertices.Length]; |
|||
|
|||
// The indexes for the side part is simple
|
|||
int[] triangles = new int[18]; |
|||
for(int idx = 0; idx < 12; ++idx) |
|||
{ |
|||
triangles[idx] = idx; |
|||
} |
|||
|
|||
// Cap indexes
|
|||
triangles[12] = 12; |
|||
triangles[13] = 13; |
|||
triangles[14] = 14; |
|||
triangles[15] = 12; |
|||
triangles[16] = 14; |
|||
triangles[17] = 15; |
|||
|
|||
outputMesh.vertices = vertices; |
|||
outputMesh.normals = normals; |
|||
outputMesh.uv = uvs; |
|||
outputMesh.triangles = triangles; |
|||
|
|||
outputMesh.RecalculateBounds(); |
|||
} |
|||
|
|||
void BuildShapes() |
|||
{ |
|||
m_sphereMesh = new Mesh(); |
|||
BuildSphere(ref m_sphereMesh, 1.0f, 24, 16); |
|||
|
|||
m_boxMesh = new Mesh(); |
|||
BuildBox(ref m_boxMesh, 1.0f, 1.0f, 1.0f); |
|||
|
|||
m_coneMesh = new Mesh(); |
|||
BuildCone(ref m_coneMesh, 1.0f, 1.0f, 0.0f, 16); |
|||
|
|||
m_pyramidMesh = new Mesh(); |
|||
BuildPyramid(ref m_pyramidMesh, 1.0f, 1.0f, 1.0f); |
|||
} |
|||
|
|||
public void CheckResources() |
|||
{ |
|||
if (m_sphereMesh == null || m_boxMesh == null || m_coneMesh == null || m_pyramidMesh == null) |
|||
{ |
|||
BuildShapes(); |
|||
} |
|||
} |
|||
|
|||
public Mesh RequestSphereMesh() |
|||
{ |
|||
CheckResources(); |
|||
return m_sphereMesh; |
|||
} |
|||
|
|||
public Mesh RequestBoxMesh() |
|||
{ |
|||
CheckResources(); |
|||
return m_boxMesh; |
|||
} |
|||
|
|||
public Mesh RequestConeMesh() |
|||
{ |
|||
CheckResources(); |
|||
return m_coneMesh; |
|||
} |
|||
|
|||
public Mesh RequestPyramidMesh() |
|||
{ |
|||
CheckResources(); |
|||
return m_pyramidMesh; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: a164ae4d75dc0074b966a2efdf0a5700 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
Shader "Hidden/HDRenderPipeline/DebugLightVolume" |
|||
{ |
|||
Properties |
|||
{ |
|||
_Color ("Color", Color) = (1.0, 1.0, 1.0, 1.0) |
|||
_Range("Range", Vector) = (1.0, 1.0, 1.0, 1.0) |
|||
_Offset("Offset", Vector) = (1.0, 1.0, 1.0, 1.0) |
|||
} |
|||
SubShader |
|||
{ |
|||
Tags { "Queue" = "Transparent" } |
|||
Tags {"Queue"="Transparent" "RenderType"="Transparent" } |
|||
Cull Off |
|||
|
|||
ZWrite Off |
|||
Blend SrcAlpha OneMinusSrcAlpha |
|||
|
|||
Pass |
|||
{ |
|||
HLSLPROGRAM |
|||
#pragma vertex vert |
|||
#pragma fragment frag |
|||
|
|||
#include "CoreRP/ShaderLibrary/Common.hlsl" |
|||
#include "HDRP/ShaderVariables.hlsl" |
|||
|
|||
struct AttributesDefault |
|||
{ |
|||
float4 positionOS : POSITION; |
|||
}; |
|||
|
|||
struct VaryingsDefault |
|||
{ |
|||
float4 positionCS : SV_POSITION; |
|||
}; |
|||
|
|||
float3 _Range; |
|||
float3 _Offset; |
|||
float4 _Color; |
|||
|
|||
VaryingsDefault vert(AttributesDefault att) |
|||
{ |
|||
VaryingsDefault output; |
|||
|
|||
float3 positionRWS = TransformObjectToWorld(att.positionOS * _Range + _Offset); |
|||
output.positionCS = TransformWorldToHClip(positionRWS); |
|||
return output; |
|||
} |
|||
|
|||
float4 frag(VaryingsDefault varying) : SV_TARGET0 |
|||
{ |
|||
return _Color; |
|||
} |
|||
|
|||
ENDHLSL |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: f62fc49f20e79e64ba43db3cfd447d80 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Reflection; |
|||
using UnityEditor.Callbacks; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
using Object = UnityEngine.Object; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
abstract class HDProbeEditor : Editor |
|||
{ |
|||
static Dictionary<HDProbe, HDProbeUI> s_StateMap = new Dictionary<HDProbe, HDProbeUI>(); |
|||
|
|||
internal static bool TryGetUIStateFor(HDProbe p, out HDProbeUI r) |
|||
{ |
|||
return s_StateMap.TryGetValue(p, out r); |
|||
} |
|||
|
|||
internal abstract HDProbe GetTarget(Object editorTarget); |
|||
|
|||
protected SerializedHDProbe m_SerializedHDProbe; |
|||
HDProbeUI m_UIState; |
|||
HDProbeUI[] m_UIHandleState; |
|||
protected HDProbe[] m_TypedTargets; |
|||
|
|||
protected virtual void OnEnable() |
|||
{ |
|||
if(m_UIState == null) |
|||
{ |
|||
m_UIState = HDProbeUI.CreateFor(this); |
|||
} |
|||
m_UIState.Reset(m_SerializedHDProbe, Repaint); |
|||
|
|||
m_TypedTargets = new HDProbe[targets.Length]; |
|||
m_UIHandleState = new HDProbeUI[m_TypedTargets.Length]; |
|||
for (var i = 0; i < m_TypedTargets.Length; i++) |
|||
{ |
|||
m_TypedTargets[i] = GetTarget(targets[i]); |
|||
m_UIHandleState[i] = HDProbeUI.CreateFor(m_TypedTargets[i]); |
|||
m_UIHandleState[i].Reset(m_SerializedHDProbe, null); |
|||
|
|||
s_StateMap[m_TypedTargets[i]] = m_UIHandleState[i]; |
|||
} |
|||
} |
|||
|
|||
protected virtual void OnDisable() |
|||
{ |
|||
for (var i = 0; i < m_TypedTargets.Length; i++) |
|||
s_StateMap.Remove(m_TypedTargets[i]); |
|||
} |
|||
|
|||
protected abstract void Draw(HDProbeUI s, SerializedHDProbe serialized, Editor owner); |
|||
|
|||
public override void OnInspectorGUI() |
|||
{ |
|||
var s = m_UIState; |
|||
var d = m_SerializedHDProbe; |
|||
var o = this; |
|||
|
|||
s.Update(); |
|||
d.Update(); |
|||
|
|||
Draw(s, d, o); |
|||
|
|||
d.Apply(); |
|||
} |
|||
|
|||
protected virtual void OnSceneGUI() |
|||
{ |
|||
//mandatory update as for strange reason the serialized rollback one update here
|
|||
m_UIState.Update(); |
|||
m_SerializedHDProbe.Update(); |
|||
|
|||
HDProbeUI.DrawHandles(m_UIState, m_SerializedHDProbe, this); |
|||
m_UIState.DoShortcutKey(this); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 7f189b572cf7bf04d9f1976dcc75c942 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEditorInternal; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
using UnityEngine.Rendering; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
using _ = CoreEditorUtils; |
|||
using CED = CoreEditorDrawer<HDProbeUI, SerializedHDProbe>; |
|||
|
|||
partial class HDProbeUI |
|||
{ |
|||
public static readonly CED.IDrawer SectionProbeModeSettings; |
|||
public static readonly CED.IDrawer ProxyVolumeSettings = CED.FoldoutGroup( |
|||
proxySettingsHeader, |
|||
(s, d, o) => s.isSectionExpendedProxyVolume, |
|||
FoldoutOption.Indent, |
|||
CED.Action(Drawer_SectionProxySettings) |
|||
); |
|||
public static readonly CED.IDrawer SectionProbeModeBakedSettings = CED.noop; |
|||
public static readonly CED.IDrawer SectionProbeModeRealtimeSettings = CED.Action(Drawer_SectionProbeModeRealtimeSettings); |
|||
public static readonly CED.IDrawer SectionBakeButton = CED.Action(Drawer_SectionBakeButton); |
|||
|
|||
public static readonly CED.IDrawer SectionFoldoutAdditionalSettings = CED.FoldoutGroup( |
|||
additionnalSettingsHeader, |
|||
(s, d, o) => s.isSectionExpendedAdditionalSettings, |
|||
FoldoutOption.Indent, |
|||
CED.Action(Drawer_SectionCustomSettings) |
|||
); |
|||
|
|||
static HDProbeUI() |
|||
{ |
|||
SectionProbeModeSettings = CED.Group( |
|||
CED.Action(Drawer_FieldCaptureType), |
|||
CED.FadeGroup( |
|||
(s, d, o, i) => s.IsSectionExpandedReflectionProbeMode((ReflectionProbeMode)i), |
|||
FadeOption.Indent, |
|||
SectionProbeModeBakedSettings, |
|||
SectionProbeModeRealtimeSettings |
|||
) |
|||
); |
|||
} |
|||
|
|||
protected static void Drawer_DifferentShapeError(HDProbeUI s, SerializedHDProbe d, Editor o) |
|||
{ |
|||
var proxy = d.proxyVolumeReference.objectReferenceValue as ReflectionProxyVolumeComponent; |
|||
if (proxy != null |
|||
&& (int)proxy.proxyVolume.shape != d.influenceVolume.shape.enumValueIndex |
|||
&& proxy.proxyVolume.shape != ProxyShape.Infinite) |
|||
{ |
|||
EditorGUILayout.HelpBox( |
|||
proxyInfluenceShapeMismatchHelpBoxText, |
|||
MessageType.Error, |
|||
true |
|||
); |
|||
} |
|||
} |
|||
|
|||
static GUIStyle disabled; |
|||
static void PropertyField(SerializedProperty prop, GUIContent content) |
|||
{ |
|||
if(prop != null) |
|||
{ |
|||
EditorGUILayout.PropertyField(prop, content); |
|||
} |
|||
else |
|||
{ |
|||
if(disabled == null) |
|||
{ |
|||
disabled = new GUIStyle(GUI.skin.label); |
|||
disabled.onNormal.textColor *= 0.5f; |
|||
} |
|||
EditorGUILayout.LabelField(content, disabled); |
|||
} |
|||
} |
|||
|
|||
protected static void Drawer_SectionBakeButton(HDProbeUI s, SerializedHDProbe d, Editor o) |
|||
{ |
|||
if (d.target is HDAdditionalReflectionData) |
|||
EditorReflectionSystemGUI.DrawBakeButton((ReflectionProbeMode)d.mode.intValue, ((HDAdditionalReflectionData)d.target).reflectionProbe); |
|||
else //PlanarReflectionProbe
|
|||
EditorReflectionSystemGUI.DrawBakeButton((ReflectionProbeMode)d.mode.intValue, d.target as PlanarReflectionProbe); |
|||
} |
|||
|
|||
static void Drawer_SectionProbeModeRealtimeSettings(HDProbeUI s, SerializedHDProbe d, Editor o) |
|||
{ |
|||
GUI.enabled = false; |
|||
EditorGUILayout.PropertyField(d.refreshMode, _.GetContent("Refresh Mode")); |
|||
GUI.enabled = true; |
|||
} |
|||
|
|||
protected static void Drawer_SectionProxySettings(HDProbeUI s, SerializedHDProbe d, Editor o) |
|||
{ |
|||
EditorGUILayout.PropertyField(d.proxyVolumeReference, proxyVolumeContent); |
|||
|
|||
if (d.target.proxyVolume == null) |
|||
{ |
|||
EditorGUI.BeginChangeCheck(); |
|||
d.infiniteProjection.boolValue = !EditorGUILayout.Toggle(useInfiniteProjectionContent, !d.infiniteProjection.boolValue); |
|||
if(EditorGUI.EndChangeCheck()) |
|||
{ |
|||
d.Apply(); |
|||
} |
|||
} |
|||
|
|||
if (d.proxyVolumeReference.objectReferenceValue != null) |
|||
{ |
|||
var proxy = (ReflectionProxyVolumeComponent)d.proxyVolumeReference.objectReferenceValue; |
|||
if ((int)proxy.proxyVolume.shape != d.influenceVolume.shape.enumValueIndex |
|||
&& proxy.proxyVolume.shape != ProxyShape.Infinite) |
|||
EditorGUILayout.HelpBox( |
|||
proxyInfluenceShapeMismatchHelpBoxText, |
|||
MessageType.Error, |
|||
true |
|||
); |
|||
} |
|||
else |
|||
{ |
|||
EditorGUILayout.HelpBox( |
|||
d.infiniteProjection.boolValue ? noProxyInfiniteHelpBoxText : noProxyHelpBoxText, |
|||
MessageType.Info, |
|||
true |
|||
); |
|||
} |
|||
} |
|||
|
|||
protected static void Drawer_SectionCustomSettings(HDProbeUI s, SerializedHDProbe d, Editor o) |
|||
{ |
|||
EditorGUILayout.PropertyField(d.weight, weightContent); |
|||
|
|||
EditorGUI.BeginChangeCheck(); |
|||
EditorGUILayout.PropertyField(d.multiplier, multiplierContent); |
|||
if (EditorGUI.EndChangeCheck()) |
|||
d.multiplier.floatValue = Mathf.Max(0.0f, d.multiplier.floatValue); |
|||
} |
|||
|
|||
static void Drawer_FieldCaptureType(HDProbeUI s, SerializedHDProbe d, Editor o) |
|||
{ |
|||
GUI.enabled = false; |
|||
EditorGUILayout.PropertyField(d.mode, fieldCaptureTypeContent); |
|||
GUI.enabled = true; |
|||
} |
|||
|
|||
|
|||
[Flags] |
|||
internal enum ToolBar |
|||
{ |
|||
InfluenceShape = 1<<0, |
|||
Blend = 1<<1, |
|||
NormalBlend = 1<<2, |
|||
CapturePosition = 1<<3 |
|||
} |
|||
protected ToolBar[] toolBars = null; |
|||
|
|||
protected const EditMode.SceneViewEditMode EditBaseShape = EditMode.SceneViewEditMode.ReflectionProbeBox; |
|||
protected const EditMode.SceneViewEditMode EditInfluenceShape = EditMode.SceneViewEditMode.GridBox; |
|||
protected const EditMode.SceneViewEditMode EditInfluenceNormalShape = EditMode.SceneViewEditMode.Collider; |
|||
protected const EditMode.SceneViewEditMode EditCenter = EditMode.SceneViewEditMode.GridMove; |
|||
//Note: EditMode.SceneViewEditMode.ReflectionProbeOrigin is still used
|
|||
//by legacy reflection probe and have its own mecanism that we don't want
|
|||
|
|||
internal static bool IsProbeEditMode(EditMode.SceneViewEditMode editMode) |
|||
{ |
|||
return editMode == EditBaseShape |
|||
|| editMode == EditInfluenceShape |
|||
|| editMode == EditInfluenceNormalShape |
|||
|| editMode == EditCenter; |
|||
} |
|||
|
|||
static Dictionary<ToolBar, EditMode.SceneViewEditMode> s_Toolbar_Mode = null; |
|||
protected static Dictionary<ToolBar, EditMode.SceneViewEditMode> toolbar_Mode |
|||
{ |
|||
get |
|||
{ |
|||
return s_Toolbar_Mode ?? (s_Toolbar_Mode = new Dictionary<ToolBar, EditMode.SceneViewEditMode> |
|||
{ |
|||
{ ToolBar.InfluenceShape, EditBaseShape }, |
|||
{ ToolBar.Blend, EditInfluenceShape }, |
|||
{ ToolBar.NormalBlend, EditInfluenceNormalShape }, |
|||
{ ToolBar.CapturePosition, EditCenter } |
|||
}); |
|||
} |
|||
} |
|||
|
|||
//[TODO] change this to be modifiable shortcuts
|
|||
static Dictionary<KeyCode, ToolBar> s_Toolbar_ShortCutKey = null; |
|||
protected static Dictionary<KeyCode, ToolBar> toolbar_ShortCutKey |
|||
{ |
|||
get |
|||
{ |
|||
return s_Toolbar_ShortCutKey ?? (s_Toolbar_ShortCutKey = new Dictionary<KeyCode, ToolBar> |
|||
{ |
|||
{ KeyCode.Alpha1, ToolBar.InfluenceShape }, |
|||
{ KeyCode.Alpha2, ToolBar.Blend }, |
|||
{ KeyCode.Alpha3, ToolBar.NormalBlend }, |
|||
{ KeyCode.Alpha4, ToolBar.CapturePosition } |
|||
}); |
|||
} |
|||
} |
|||
|
|||
protected static void Drawer_Toolbars(HDProbeUI s, SerializedHDProbe d, Editor o) |
|||
{ |
|||
GUILayout.BeginHorizontal(); |
|||
GUILayout.FlexibleSpace(); |
|||
GUI.changed = false; |
|||
|
|||
foreach(ToolBar toolBar in s.toolBars) |
|||
{ |
|||
List<EditMode.SceneViewEditMode> listMode = new List<EditMode.SceneViewEditMode>(); |
|||
List<GUIContent> listContent = new List<GUIContent>(); |
|||
if ((toolBar & ToolBar.InfluenceShape) > 0) |
|||
{ |
|||
listMode.Add(toolbar_Mode[ToolBar.InfluenceShape]); |
|||
listContent.Add(toolbar_Contents[ToolBar.InfluenceShape]); |
|||
} |
|||
if ((toolBar & ToolBar.Blend) > 0) |
|||
{ |
|||
listMode.Add(toolbar_Mode[ToolBar.Blend]); |
|||
listContent.Add(toolbar_Contents[ToolBar.Blend]); |
|||
} |
|||
if ((toolBar & ToolBar.NormalBlend) > 0) |
|||
{ |
|||
listMode.Add(toolbar_Mode[ToolBar.NormalBlend]); |
|||
listContent.Add(toolbar_Contents[ToolBar.NormalBlend]); |
|||
} |
|||
if ((toolBar & ToolBar.CapturePosition) > 0) |
|||
{ |
|||
listMode.Add(toolbar_Mode[ToolBar.CapturePosition]); |
|||
listContent.Add(toolbar_Contents[ToolBar.CapturePosition]); |
|||
} |
|||
EditMode.DoInspectorToolbar(listMode.ToArray(), listContent.ToArray(), GetBoundsGetter(o), o); |
|||
} |
|||
GUILayout.FlexibleSpace(); |
|||
GUILayout.EndHorizontal(); |
|||
} |
|||
|
|||
|
|||
static internal void Drawer_ToolBarButton(ToolBar button, Editor owner, params GUILayoutOption[] options) |
|||
{ |
|||
bool enabled = toolbar_Mode[button] == EditMode.editMode; |
|||
EditorGUI.BeginChangeCheck(); |
|||
enabled = GUILayout.Toggle(enabled, toolbar_Contents[button], EditorStyles.miniButton, options); |
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
EditMode.SceneViewEditMode targetMode = EditMode.editMode == toolbar_Mode[button] ? EditMode.SceneViewEditMode.None : toolbar_Mode[button]; |
|||
EditMode.ChangeEditMode(targetMode, GetBoundsGetter(owner)(), owner); |
|||
} |
|||
} |
|||
|
|||
static Func<Bounds> GetBoundsGetter(Editor o) |
|||
{ |
|||
return () => |
|||
{ |
|||
var bounds = new Bounds(); |
|||
foreach (Component targetObject in o.targets) |
|||
{ |
|||
var rp = targetObject.transform; |
|||
var b = rp.position; |
|||
bounds.Encapsulate(b); |
|||
} |
|||
return bounds; |
|||
}; |
|||
} |
|||
|
|||
public void DoShortcutKey(Editor owner) |
|||
{ |
|||
var evt = Event.current; |
|||
if (evt.type != EventType.KeyDown || !evt.shift) |
|||
return; |
|||
|
|||
ToolBar toolbar; |
|||
if(toolbar_ShortCutKey.TryGetValue(evt.keyCode, out toolbar)) |
|||
{ |
|||
bool used = false; |
|||
foreach(ToolBar t in toolBars) |
|||
{ |
|||
if((t&toolbar)>0) |
|||
{ |
|||
used = true; |
|||
break; |
|||
} |
|||
} |
|||
if (!used) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
var targetMode = toolbar_Mode[toolbar]; |
|||
var mode = EditMode.editMode == targetMode ? EditMode.SceneViewEditMode.None : targetMode; |
|||
EditMode.ChangeEditMode(mode, GetBoundsGetter(owner)(), owner); |
|||
evt.Use(); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
using UnityEditorInternal; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
partial class HDProbeUI |
|||
{ |
|||
|
|||
internal static void DrawHandles(HDProbeUI s, SerializedHDProbe d, Editor o) |
|||
{ |
|||
HDProbe probe = d.target as HDProbe; |
|||
var mat = Matrix4x4.TRS(probe.transform.position, probe.transform.rotation, Vector3.one); |
|||
|
|||
switch (EditMode.editMode) |
|||
{ |
|||
case EditBaseShape: |
|||
InfluenceVolumeUI.DrawHandles_EditBase(s.influenceVolume, d.influenceVolume, o, mat, probe); |
|||
break; |
|||
case EditInfluenceShape: |
|||
InfluenceVolumeUI.DrawHandles_EditInfluence(s.influenceVolume, d.influenceVolume, o, mat, probe); |
|||
break; |
|||
case EditInfluenceNormalShape: |
|||
InfluenceVolumeUI.DrawHandles_EditInfluenceNormal(s.influenceVolume, d.influenceVolume, o, mat, probe); |
|||
break; |
|||
case EditCenter: |
|||
{ |
|||
using (new Handles.DrawingScope(Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one))) |
|||
{ |
|||
Vector3 offsetWorld = probe.transform.position + probe.transform.rotation * probe.influenceVolume.offset; |
|||
EditorGUI.BeginChangeCheck(); |
|||
var newOffsetWorld = Handles.PositionHandle(offsetWorld, probe.transform.rotation); |
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
Vector3 newOffset = Quaternion.Inverse(probe.transform.rotation) * (newOffsetWorld - probe.transform.position); |
|||
Undo.RecordObjects(new Object[] { probe, probe.transform }, "Translate Influence Position"); |
|||
d.influenceVolume.offset.vector3Value = newOffset; |
|||
d.influenceVolume.Apply(); |
|||
|
|||
//call modification to legacy ReflectionProbe
|
|||
probe.influenceVolume.offset = newOffset; |
|||
} |
|||
} |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
[DrawGizmo(GizmoType.Selected)] |
|||
internal static void DrawGizmos(HDProbe d, GizmoType gizmoType) |
|||
{ |
|||
HDProbeUI s; |
|||
if (!HDProbeEditor.TryGetUIStateFor(d, out s)) |
|||
return; |
|||
|
|||
var mat = Matrix4x4.TRS(d.transform.position, d.transform.rotation, Vector3.one); |
|||
|
|||
switch (EditMode.editMode) |
|||
{ |
|||
case EditBaseShape: |
|||
InfluenceVolumeUI.DrawGizmos( |
|||
s.influenceVolume, d.influenceVolume, mat, |
|||
InfluenceVolumeUI.HandleType.Base, |
|||
InfluenceVolumeUI.HandleType.All); |
|||
break; |
|||
case EditInfluenceShape: |
|||
InfluenceVolumeUI.DrawGizmos( |
|||
s.influenceVolume, |
|||
d.influenceVolume, |
|||
mat, |
|||
InfluenceVolumeUI.HandleType.Influence, |
|||
InfluenceVolumeUI.HandleType.All); |
|||
break; |
|||
case EditInfluenceNormalShape: |
|||
InfluenceVolumeUI.DrawGizmos( |
|||
s.influenceVolume, |
|||
d.influenceVolume, |
|||
mat, |
|||
InfluenceVolumeUI.HandleType.InfluenceNormal, |
|||
InfluenceVolumeUI.HandleType.All); |
|||
break; |
|||
default: |
|||
{ |
|||
var showedHandles = s.influenceVolume.showInfluenceHandles |
|||
? InfluenceVolumeUI.HandleType.All |
|||
: InfluenceVolumeUI.HandleType.Base; |
|||
InfluenceVolumeUI.DrawGizmos( |
|||
s.influenceVolume, |
|||
d.influenceVolume, |
|||
mat, |
|||
InfluenceVolumeUI.HandleType.None, |
|||
showedHandles); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
if (d.proxyVolume != null) |
|||
ReflectionProxyVolumeComponentUI.DrawGizmos_EditNone(d.proxyVolume); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 8ee668677cd59784d8fb06a531b49a77 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEditor.AnimatedValues; |
|||
using UnityEngine; |
|||
using UnityEngine.Events; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
using UnityEngine.Rendering; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
partial class HDProbeUI |
|||
{ |
|||
static readonly Color[][] k_handlesColor = new Color[][] |
|||
{ |
|||
new Color[] |
|||
{ |
|||
Color.red, |
|||
Color.green, |
|||
Color.blue |
|||
}, |
|||
new Color[] |
|||
{ |
|||
new Color(.5f, 0f, 0f, 1f), |
|||
new Color(0f, .5f, 0f, 1f), |
|||
new Color(0f, 0f, .5f, 1f) |
|||
} |
|||
}; |
|||
|
|||
static readonly GUIContent bakeTypeContent = CoreEditorUtils.GetContent("Type|'Baked Cubemap' uses the 'Auto Baking' mode from the Lighting window. If it is enabled then baking is automatic otherwise manual bake is needed (use the bake button below). \n'Custom' can be used if a custom cubemap is wanted. \n'Realtime' can be used to dynamically re-render the cubemap during runtime (via scripting)."); |
|||
|
|||
static readonly GUIContent proxyVolumeContent = CoreEditorUtils.GetContent("Proxy Volume"); |
|||
protected static readonly GUIContent useInfiniteProjectionContent = CoreEditorUtils.GetContent("Same As Influence Volume|If enabled, parallax correction will occure, causing reflections to appear to change based on the object's position within the probe's box, 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. When disabled, 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"); |
|||
|
|||
static readonly GUIContent normalModeContent = CoreEditorUtils.GetContent("Normal|Normal parameters mode (only change for box shape)."); |
|||
static readonly GUIContent advancedModeContent = CoreEditorUtils.GetContent("Advanced|Advanced parameters mode (only change for box shape)."); |
|||
|
|||
protected static readonly GUIContent fieldCaptureTypeContent = CoreEditorUtils.GetContent("Type"); |
|||
protected static readonly GUIContent resolutionContent = CoreEditorUtils.GetContent("Resolution"); |
|||
protected static readonly GUIContent shadowDistanceContent = CoreEditorUtils.GetContent("Shadow Distance"); |
|||
protected static readonly GUIContent cullingMaskContent = CoreEditorUtils.GetContent("Culling Mask"); |
|||
protected static readonly GUIContent useOcclusionCullingContent = CoreEditorUtils.GetContent("Use Occlusion Culling"); |
|||
protected static readonly GUIContent nearClipCullingContent = CoreEditorUtils.GetContent("Near Clip"); |
|||
protected static readonly GUIContent farClipCullingContent = CoreEditorUtils.GetContent("Far Clip"); |
|||
|
|||
static readonly GUIContent weightContent = CoreEditorUtils.GetContent("Weight|Blend weight applied on this reflection probe. This can be used for fading in or out a reflection probe."); |
|||
static readonly GUIContent multiplierContent = CoreEditorUtils.GetContent("Intensity Multiplier|Allows you to boost or dimmer the reflected cubemap. Values above 1 will make reflections brighter and values under 1 will make reflections darker. Using values different than 1 is not physically correct."); |
|||
|
|||
static readonly GUIContent textureSizeContent = CoreEditorUtils.GetContent("Probe Texture Size (Set By HDRP)"); |
|||
static readonly GUIContent compressionTextureContent = CoreEditorUtils.GetContent("Probe Compression (Set By HDRP)"); |
|||
|
|||
|
|||
const string mimapHelpBoxText = "No mipmaps in the cubemap, Smoothness value in Standard shader will be ignored."; |
|||
const string noProxyHelpBoxText = "Influence shape will be used as Projection shape too."; |
|||
const string noProxyInfiniteHelpBoxText = "Projection will be at infinite."; |
|||
const string proxyInfluenceShapeMismatchHelpBoxText = "Proxy volume and influence volume have different shapes, this is not supported."; |
|||
|
|||
const string proxySettingsHeader = "Projection Settings"; |
|||
//influenceVolume have its own header
|
|||
protected const string captureSettingsHeader = "Capture Settings"; |
|||
const string additionnalSettingsHeader = "Custom Settings"; |
|||
|
|||
static Dictionary<ToolBar, GUIContent> s_Toolbar_Contents = null; |
|||
protected static Dictionary<ToolBar, GUIContent> toolbar_Contents |
|||
{ |
|||
get |
|||
{ |
|||
return s_Toolbar_Contents ?? (s_Toolbar_Contents = new Dictionary<ToolBar, GUIContent> |
|||
{ |
|||
{ ToolBar.InfluenceShape, EditorGUIUtility.IconContent("EditCollider", "|Modify the base shape. (SHIFT+1)") }, |
|||
{ ToolBar.Blend, EditorGUIUtility.IconContent("PreMatCube", "|Modify the influence volume. (SHIFT+2)") }, |
|||
{ ToolBar.NormalBlend, EditorGUIUtility.IconContent("SceneViewOrtho", "|Modify the influence normal volume. (SHIFT+3)") }, |
|||
{ ToolBar.CapturePosition, EditorGUIUtility.IconContent("MoveTool", "|Change the Offset of the shape.") } |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 43443fcbe23ff044eb73250a6d34cedd |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using UnityEditor.AnimatedValues; |
|||
using UnityEngine.Events; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
using UnityEngine.Rendering; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
abstract partial class HDProbeUI : BaseUI<SerializedHDProbe> |
|||
{ |
|||
const int k_AnimBoolSingleFieldCount = 6; |
|||
static readonly int k_ReflectionProbeModeCount = Enum.GetValues(typeof(ReflectionProbeMode)).Length; |
|||
static readonly int k_ReflectionInfluenceShapeCount = Enum.GetValues(typeof(InfluenceShape)).Length; |
|||
static readonly int k_AnimBoolTotal = k_ReflectionProbeModeCount + k_AnimBoolSingleFieldCount + k_ReflectionInfluenceShapeCount; |
|||
|
|||
public InfluenceVolumeUI influenceVolume = new InfluenceVolumeUI(); |
|||
public FrameSettingsUI frameSettings = new FrameSettingsUI(); |
|||
public ReflectionProxyVolumeComponentUI reflectionProxyVolume = new ReflectionProxyVolumeComponentUI(); |
|||
|
|||
public AnimBool isSectionExpandedInfluenceSettings { get { return m_AnimBools[k_ReflectionProbeModeCount]; } } |
|||
public AnimBool isSectionExpandedCaptureSettings { get { return m_AnimBools[k_ReflectionProbeModeCount + 1]; } } |
|||
|
|||
public AnimBool isSectionExpandedCaptureMirrorSettings { get { return m_AnimBools[k_ReflectionProbeModeCount + 2]; } } |
|||
public AnimBool isSectionExpandedCaptureStaticSettings { get { return m_AnimBools[k_ReflectionProbeModeCount + 3]; } } |
|||
public AnimBool isSectionExpendedProxyVolume { get { return m_AnimBools[k_ReflectionProbeModeCount + 4]; } } |
|||
public AnimBool isSectionExpendedAdditionalSettings { get { return m_AnimBools[k_ReflectionProbeModeCount + 5]; } } |
|||
|
|||
public bool showCaptureHandles { get; set; } |
|||
|
|||
internal static HDProbeUI CreateFor(HDProbeEditor o) |
|||
{ |
|||
if (o is PlanarReflectionProbeEditor) |
|||
return new PlanarReflectionProbeUI(); |
|||
else |
|||
return new HDReflectionProbeUI(); |
|||
} |
|||
internal static HDProbeUI CreateFor(HDProbe p) |
|||
{ |
|||
if (p is PlanarReflectionProbe) |
|||
return new PlanarReflectionProbeUI(); |
|||
else |
|||
return new HDReflectionProbeUI(); |
|||
} |
|||
|
|||
public HDProbeUI() |
|||
: base(k_AnimBoolTotal) |
|||
{ |
|||
isSectionExpandedInfluenceSettings.value = true; |
|||
isSectionExpandedCaptureSettings.value = true; |
|||
isSectionExpendedProxyVolume.value = true; |
|||
isSectionExpendedAdditionalSettings.value = false; |
|||
} |
|||
|
|||
public AnimBool IsSectionExpandedReflectionProbeMode(ReflectionProbeMode mode) |
|||
{ |
|||
return m_AnimBools[(int)mode]; |
|||
} |
|||
|
|||
public void SetModeTarget(int value) |
|||
{ |
|||
for (var i = 0; i < k_ReflectionProbeModeCount; i++) |
|||
GetReflectionProbeModeBool(i).target = i == value; |
|||
} |
|||
|
|||
AnimBool GetReflectionProbeModeBool(int i) |
|||
{ |
|||
return m_AnimBools[i]; |
|||
} |
|||
|
|||
public override void Reset(SerializedHDProbe data, UnityAction repaint) |
|||
{ |
|||
frameSettings.Reset(data.frameSettings, repaint); |
|||
influenceVolume.Reset(data.influenceVolume, repaint); |
|||
base.Reset(data, repaint); |
|||
} |
|||
|
|||
public override void Update() |
|||
{ |
|||
for (var i = 0; i < k_ReflectionProbeModeCount; i++) |
|||
m_AnimBools[i].target = i == data.mode.intValue; |
|||
|
|||
SetModeTarget(data.mode.hasMultipleDifferentValues ? -1 : data.mode.intValue); |
|||
influenceVolume.SetIsSectionExpanded_Shape(data.influenceVolume.shape.hasMultipleDifferentValues ? -1 : data.influenceVolume.shape.intValue); |
|||
|
|||
frameSettings.Update(); |
|||
influenceVolume.Update(); |
|||
base.Update(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: f23cf1efede7335468bfa23bd1838cd2 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
internal abstract class SerializedHDProbe |
|||
{ |
|||
internal SerializedObject serializedObject; |
|||
|
|||
internal SerializedProperty proxyVolumeReference; |
|||
internal SerializedProperty infiniteProjection; |
|||
|
|||
internal SerializedInfluenceVolume influenceVolume; |
|||
|
|||
internal SerializedFrameSettings frameSettings; |
|||
|
|||
internal SerializedProperty weight; |
|||
internal SerializedProperty multiplier; |
|||
internal SerializedProperty mode; |
|||
internal SerializedProperty refreshMode; |
|||
|
|||
internal SerializedProperty resolution; |
|||
internal SerializedProperty shadowDistance; |
|||
internal SerializedProperty cullingMask; |
|||
internal SerializedProperty useOcclusionCulling; |
|||
internal SerializedProperty nearClip; |
|||
internal SerializedProperty farClip; |
|||
|
|||
internal HDProbe target { get { return serializedObject.targetObject as HDProbe; } } |
|||
|
|||
internal SerializedHDProbe(SerializedObject serializedObject) |
|||
{ |
|||
this.serializedObject = serializedObject; |
|||
|
|||
proxyVolumeReference = serializedObject.Find((HDProbe p) => p.proxyVolume); |
|||
influenceVolume = new SerializedInfluenceVolume(serializedObject.Find((HDProbe p) => p.influenceVolume)); |
|||
infiniteProjection = serializedObject.Find((HDProbe p) => p.infiniteProjection); |
|||
|
|||
frameSettings = new SerializedFrameSettings(serializedObject.Find((HDProbe p) => p.frameSettings)); |
|||
|
|||
weight = serializedObject.Find((HDProbe p) => p.weight); |
|||
multiplier = serializedObject.Find((HDProbe p) => p.multiplier); |
|||
mode = serializedObject.Find((HDProbe p) => p.mode); |
|||
refreshMode = serializedObject.Find((HDProbe p) => p.refreshMode); |
|||
} |
|||
|
|||
internal virtual void Update() |
|||
{ |
|||
serializedObject.Update(); |
|||
//InfluenceVolume does not have Update. Add it here if it have in the future.
|
|||
} |
|||
|
|||
internal virtual void Apply() |
|||
{ |
|||
serializedObject.ApplyModifiedProperties(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: fe06aab2f0da27148b61819e1ce565a1 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
|
|||
partial class InfluenceVolumeUI |
|||
{ |
|||
static readonly Color k_GizmoThemeColorBase = new Color(255f / 255f, 229f / 255f, 148f / 255f, 80f / 255f); |
|||
static readonly Color k_GizmoThemeColorBaseFace = new Color(255f / 255f, 229f / 255f, 148f / 255f, 45f / 255f); |
|||
static readonly Color k_GizmoThemeColorInfluence = new Color(83f / 255f, 255f / 255f, 95f / 255f, 75f / 255f); |
|||
static readonly Color k_GizmoThemeColorInfluenceFace = new Color(83f / 255f, 255f / 255f, 95f / 255f, 17f / 255f); |
|||
static readonly Color k_GizmoThemeColorInfluenceNormal = new Color(0f / 255f, 229f / 255f, 255f / 255f, 80f / 255f); |
|||
static readonly Color k_GizmoThemeColorInfluenceNormalFace = new Color(0f / 255f, 229f / 255f, 255f / 255f, 36f / 255f); |
|||
static readonly Color k_GizmoThemeColorProjection = new Color(0x00 / 255f, 0xE5 / 255f, 0xFF / 255f, 0x20 / 255f); |
|||
static readonly Color k_GizmoThemeColorProjectionFace = new Color(0x00 / 255f, 0xE5 / 255f, 0xFF / 255f, 0x20 / 255f); |
|||
static readonly Color k_GizmoThemeColorDisabled = new Color(0x99 / 255f, 0x89 / 255f, 0x59 / 255f, 0x10 / 255f); |
|||
static readonly Color k_GizmoThemeColorDisabledFace = new Color(0x99 / 255f, 0x89 / 255f, 0x59 / 255f, 0x10 / 255f); |
|||
|
|||
static readonly GUIContent shapeContent = CoreEditorUtils.GetContent("Shape"); |
|||
static readonly GUIContent boxSizeContent = CoreEditorUtils.GetContent("Box Size|The size of the box in which the reflections will be applied to objects. The value is not affected by the Transform of the Game Object."); |
|||
static readonly GUIContent offsetContent = CoreEditorUtils.GetContent("Offset|The center of the InfluenceVolume in which the reflections will be applied to objects. The value is relative to the position of the Game Object."); |
|||
static readonly GUIContent blendDistanceContent = CoreEditorUtils.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes."); |
|||
static readonly GUIContent blendNormalDistanceContent = CoreEditorUtils.GetContent("Blend Normal Distance|Area around the probe where the normals influence the probe. Only used in deferred probes."); |
|||
static readonly GUIContent faceFadeContent = CoreEditorUtils.GetContent("Face fade|Fade faces of the cubemap."); |
|||
|
|||
static readonly GUIContent radiusContent = CoreEditorUtils.GetContent("Radius"); |
|||
|
|||
static readonly GUIContent normalModeContent = CoreEditorUtils.GetContent("Normal|Normal parameters mode (only change for box shape)."); |
|||
static readonly GUIContent advancedModeContent = CoreEditorUtils.GetContent("Advanced|Advanced parameters mode (only change for box shape)."); |
|||
|
|||
static readonly string influenceVolumeHeader = "Influence Volume"; |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 28a19c3a1179dbd4698bf2618c4c5fb4 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: e389a5db9b96c2a4ba5f60f6a402d6f4 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using UnityEditorInternal; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
using UnityEngine.Rendering; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
using _ = CoreEditorUtils; |
|||
using CED = CoreEditorDrawer<PlanarReflectionProbeUI, SerializedPlanarReflectionProbe>; |
|||
|
|||
partial class PlanarReflectionProbeUI |
|||
{ |
|||
public static readonly CED.IDrawer Inspector; |
|||
|
|||
public static readonly CED.IDrawer SectionProbeModeSettings; |
|||
public static readonly CED.IDrawer ProxyVolumeSettings = CED.FoldoutGroup( |
|||
"Proxy Volume", |
|||
(s, d, o) => s.isSectionExpendedProxyVolume, |
|||
FoldoutOption.Indent, |
|||
CED.Action(Drawer_SectionProxySettings) |
|||
); |
|||
public static readonly CED.IDrawer SectionProbeModeBakedSettings = CED.noop; |
|||
public static readonly CED.IDrawer SectionProbeModeCustomSettings = CED.Action(Drawer_SectionProbeModeCustomSettings); |
|||
public static readonly CED.IDrawer SectionProbeModeRealtimeSettings = CED.Action(Drawer_SectionProbeModeRealtimeSettings); |
|||
public static readonly CED.IDrawer SectionBakeButton = CED.Action(Drawer_SectionBakeButton); |
|||
|
|||
public static readonly CED.IDrawer SectionFoldoutAdditionalSettings = CED.FoldoutGroup( |
|||
"Artistic Settings", |
|||
(s, d, o) => s.isSectionExpendedAdditionalSettings, |
|||
FoldoutOption.Indent, |
|||
CED.Action(Drawer_SectionInfluenceSettings) |
|||
); |
|||
|
|||
public static readonly CED.IDrawer SectionFoldoutCaptureSettings; |
|||
|
|||
public static readonly CED.IDrawer SectionCaptureMirrorSettings = CED.Action(Drawer_SectionCaptureMirror); |
|||
public static readonly CED.IDrawer SectionCaptureStaticSettings = CED.Action(Drawer_SectionCaptureStatic); |
|||
|
|||
static PlanarReflectionProbeUI() |
|||
{ |
|||
SectionFoldoutCaptureSettings = CED.FoldoutGroup( |
|||
"Capture Settings", |
|||
(s, d, o) => s.isSectionExpandedCaptureSettings, |
|||
FoldoutOption.Indent, |
|||
CED.Action(Drawer_SectionCaptureSettings), |
|||
CED.FadeGroup( |
|||
(s, d, o, i) => |
|||
{ |
|||
switch (i) |
|||
{ |
|||
default: |
|||
case 0: return s.isSectionExpandedCaptureMirrorSettings; |
|||
case 1: return s.isSectionExpandedCaptureStaticSettings; |
|||
} |
|||
}, |
|||
FadeOption.None, |
|||
SectionCaptureMirrorSettings, |
|||
SectionCaptureStaticSettings) |
|||
); |
|||
|
|||
SectionProbeModeSettings = CED.Group( |
|||
CED.Action(Drawer_FieldCaptureType), |
|||
CED.FadeGroup( |
|||
(s, d, o, i) => s.IsSectionExpandedReflectionProbeMode((ReflectionProbeMode)i), |
|||
FadeOption.Indent, |
|||
SectionProbeModeBakedSettings, |
|||
SectionProbeModeRealtimeSettings, |
|||
SectionProbeModeCustomSettings |
|||
) |
|||
); |
|||
|
|||
Inspector = CED.Group( |
|||
CED.Action(Drawer_Toolbar), |
|||
CED.space, |
|||
ProxyVolumeSettings, |
|||
CED.Select( |
|||
(s, d, o) => s.influenceVolume, |
|||
(s, d, o) => d.influenceVolume, |
|||
InfluenceVolumeUI.SectionFoldoutShapePlanar |
|||
), |
|||
CED.Action(Drawer_DifferentShapeError), |
|||
SectionFoldoutCaptureSettings, |
|||
SectionFoldoutAdditionalSettings, |
|||
CED.Select( |
|||
(s, d, o) => s.frameSettings, |
|||
(s, d, o) => d.frameSettings, |
|||
FrameSettingsUI.Inspector |
|||
), |
|||
CED.space, |
|||
CED.Action(Drawer_SectionBakeButton) |
|||
); |
|||
} |
|||
|
|||
const EditMode.SceneViewEditMode EditBaseShape = EditMode.SceneViewEditMode.ReflectionProbeBox; |
|||
const EditMode.SceneViewEditMode EditInfluenceShape = EditMode.SceneViewEditMode.GridBox; |
|||
const EditMode.SceneViewEditMode EditInfluenceNormalShape = EditMode.SceneViewEditMode.Collider; |
|||
const EditMode.SceneViewEditMode EditCenter = EditMode.SceneViewEditMode.ReflectionProbeOrigin; |
|||
const EditMode.SceneViewEditMode EditMirrorPosition = EditMode.SceneViewEditMode.GridMove; |
|||
const EditMode.SceneViewEditMode EditMirrorRotation = EditMode.SceneViewEditMode.GridSelect; |
|||
|
|||
static void Drawer_SectionCaptureStatic(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) |
|||
{ |
|||
EditorGUILayout.PropertyField(d.captureLocalPosition, _.GetContent("Capture Local Position")); |
|||
|
|||
_.DrawMultipleFields( |
|||
"Clipping Planes", |
|||
new[] { d.captureNearPlane, d.captureFarPlane }, |
|||
new[] { _.GetContent("Near|The closest point relative to the camera that drawing will occur."), _.GetContent("Far|The furthest point relative to the camera that drawing will occur.\n") }); |
|||
} |
|||
|
|||
static void Drawer_SectionCaptureMirror(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) |
|||
{ |
|||
// EditorGUILayout.PropertyField(d.captureMirrorPlaneLocalPosition, _.GetContent("Plane Position"));
|
|||
// EditorGUILayout.PropertyField(d.captureMirrorPlaneLocalNormal, _.GetContent("Plane Normal"));
|
|||
} |
|||
|
|||
static void Drawer_DifferentShapeError(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) |
|||
{ |
|||
var proxy = d.proxyVolumeReference.objectReferenceValue as ReflectionProxyVolumeComponent; |
|||
if (proxy != null && (int)proxy.proxyVolume.shape != d.influenceVolume.shape.enumValueIndex) |
|||
{ |
|||
EditorGUILayout.HelpBox( |
|||
"Proxy volume and influence volume have different shape types, this is not supported.", |
|||
MessageType.Error, |
|||
true |
|||
); |
|||
} |
|||
} |
|||
|
|||
static void Drawer_SectionCaptureSettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) |
|||
{ |
|||
var hdrp = GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset; |
|||
GUI.enabled = false; |
|||
EditorGUILayout.LabelField( |
|||
_.GetContent("Probe Texture Size (Set By HDRP)"), |
|||
_.GetContent(hdrp.renderPipelineSettings.lightLoopSettings.planarReflectionTextureSize.ToString()), |
|||
EditorStyles.label); |
|||
EditorGUILayout.Toggle( |
|||
_.GetContent("Probe Compression (Set By HDRP)"), |
|||
hdrp.renderPipelineSettings.lightLoopSettings.planarReflectionCacheCompressed); |
|||
GUI.enabled = true; |
|||
|
|||
EditorGUILayout.PropertyField(d.overrideFieldOfView, _.GetContent("Override FOV")); |
|||
if (d.overrideFieldOfView.boolValue) |
|||
{ |
|||
++EditorGUI.indentLevel; |
|||
EditorGUILayout.PropertyField(d.fieldOfViewOverride, _.GetContent("Field Of View")); |
|||
--EditorGUI.indentLevel; |
|||
} |
|||
} |
|||
|
|||
static void Drawer_SectionProbeModeCustomSettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) |
|||
{ |
|||
d.customTexture.objectReferenceValue = EditorGUILayout.ObjectField(_.GetContent("Capture"), d.customTexture.objectReferenceValue, typeof(Texture), false); |
|||
var texture = d.customTexture.objectReferenceValue as Texture; |
|||
if (texture != null && texture.dimension != TextureDimension.Tex2D) |
|||
EditorGUILayout.HelpBox("Provided Texture is not a 2D Texture, it will be ignored", MessageType.Warning); |
|||
} |
|||
|
|||
static void Drawer_SectionBakeButton(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) |
|||
{ |
|||
EditorReflectionSystemGUI.DrawBakeButton((ReflectionProbeMode)d.mode.intValue, d.target); |
|||
} |
|||
|
|||
static void Drawer_SectionProbeModeRealtimeSettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) |
|||
{ |
|||
GUI.enabled = false; |
|||
EditorGUILayout.PropertyField(d.refreshMode, _.GetContent("Refresh Mode")); |
|||
EditorGUILayout.PropertyField(d.capturePositionMode, _.GetContent("Capture Position Mode")); |
|||
GUI.enabled = true; |
|||
} |
|||
|
|||
static void Drawer_SectionProxySettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) |
|||
{ |
|||
EditorGUILayout.PropertyField(d.proxyVolumeReference, _.GetContent("Reference")); |
|||
|
|||
if (d.proxyVolumeReference.objectReferenceValue != null) |
|||
{ |
|||
var proxy = (ReflectionProxyVolumeComponent)d.proxyVolumeReference.objectReferenceValue; |
|||
if ((int)proxy.proxyVolume.shape != d.influenceVolume.shape.enumValueIndex) |
|||
EditorGUILayout.HelpBox( |
|||
"Proxy volume and influence volume have different shape types, this is not supported.", |
|||
MessageType.Error, |
|||
true |
|||
); |
|||
} |
|||
else |
|||
{ |
|||
EditorGUILayout.HelpBox( |
|||
"When no Proxy setted, Influence shape will be used as Proxy shape too.", |
|||
MessageType.Info, |
|||
true |
|||
); |
|||
} |
|||
} |
|||
|
|||
static void Drawer_SectionInfluenceSettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) |
|||
{ |
|||
EditorGUILayout.PropertyField(d.weight, _.GetContent("Weight")); |
|||
|
|||
|
|||
EditorGUI.BeginChangeCheck(); |
|||
EditorGUILayout.PropertyField(d.multiplier, _.GetContent("Multiplier")); |
|||
if (EditorGUI.EndChangeCheck()) |
|||
d.multiplier.floatValue = Mathf.Max(0.0f, d.multiplier.floatValue); |
|||
} |
|||
|
|||
static void Drawer_FieldCaptureType(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) |
|||
{ |
|||
GUI.enabled = false; |
|||
EditorGUILayout.PropertyField(d.mode, _.GetContent("Type")); |
|||
GUI.enabled = true; |
|||
} |
|||
|
|||
static readonly EditMode.SceneViewEditMode[] k_Toolbar_SceneViewEditModes = |
|||
{ |
|||
EditBaseShape, |
|||
EditInfluenceShape, |
|||
EditInfluenceNormalShape, |
|||
//EditCenter
|
|||
}; |
|||
|
|||
static readonly EditMode.SceneViewEditMode[] k_Toolbar_Static_SceneViewEditModes = |
|||
{ |
|||
//EditCenter //offset have no meanings with planar
|
|||
}; |
|||
static readonly EditMode.SceneViewEditMode[] k_Toolbar_Mirror_SceneViewEditModes = |
|||
{ |
|||
//EditMirrorPosition, //offset have no meanings with planar
|
|||
EditMirrorRotation |
|||
}; |
|||
static GUIContent[] s_Toolbar_Contents = null; |
|||
static GUIContent[] toolbar_Contents |
|||
{ |
|||
get |
|||
{ |
|||
return s_Toolbar_Contents ?? (s_Toolbar_Contents = new[] |
|||
{ |
|||
EditorGUIUtility.IconContent("EditCollider", "|Modify the base shape. (SHIFT+1)"), |
|||
EditorGUIUtility.IconContent("PreMatCube", "|Modify the influence volume. (SHIFT+2)"), |
|||
EditorGUIUtility.IconContent("SceneViewOrtho", "|Modify the influence normal volume. (SHIFT+3)"), |
|||
}); |
|||
} |
|||
} |
|||
|
|||
static GUIContent[] s_Toolbar_Static_Contents = null; |
|||
static GUIContent[] toolbar_Static_Contents |
|||
{ |
|||
get |
|||
{ |
|||
return s_Toolbar_Static_Contents ?? (s_Toolbar_Static_Contents = new GUIContent[] |
|||
{ |
|||
//EditorGUIUtility.IconContent("MoveTool", "|Move the capture position.") //offset have no meanings with planar
|
|||
}); |
|||
} |
|||
} |
|||
|
|||
static GUIContent[] s_Toolbar_Mirror_Contents = null; |
|||
static GUIContent[] toolbar_Mirror_Contents |
|||
{ |
|||
get |
|||
{ |
|||
return s_Toolbar_Mirror_Contents ?? (s_Toolbar_Mirror_Contents = new[] |
|||
{ |
|||
//EditorGUIUtility.IconContent("MoveTool", "|Move the mirror plane."), //offset have no meanings with planar
|
|||
EditorGUIUtility.IconContent("RotateTool", "|Rotate the mirror plane.") |
|||
}); |
|||
} |
|||
} |
|||
|
|||
static void Drawer_Toolbar(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) |
|||
{ |
|||
GUILayout.BeginHorizontal(); |
|||
GUILayout.FlexibleSpace(); |
|||
GUI.changed = false; |
|||
|
|||
EditMode.DoInspectorToolbar(k_Toolbar_SceneViewEditModes, toolbar_Contents, GetBoundsGetter(o), o); |
|||
|
|||
if (d.isMirrored) |
|||
EditMode.DoInspectorToolbar(k_Toolbar_Mirror_SceneViewEditModes, toolbar_Mirror_Contents, GetBoundsGetter(o), o); |
|||
else |
|||
EditMode.DoInspectorToolbar(k_Toolbar_Static_SceneViewEditModes, toolbar_Static_Contents, GetBoundsGetter(o), o); |
|||
|
|||
GUILayout.FlexibleSpace(); |
|||
GUILayout.EndHorizontal(); |
|||
} |
|||
|
|||
static public void Drawer_ToolBarButton(int buttonIndex, Editor owner, params GUILayoutOption[] styles) |
|||
{ |
|||
if (GUILayout.Button(toolbar_Contents[buttonIndex], styles)) |
|||
{ |
|||
EditMode.ChangeEditMode(k_Toolbar_SceneViewEditModes[buttonIndex], GetBoundsGetter(owner)(), owner); |
|||
} |
|||
} |
|||
|
|||
static Func<Bounds> GetBoundsGetter(Editor o) |
|||
{ |
|||
return () => |
|||
{ |
|||
var bounds = new Bounds(); |
|||
foreach (Component targetObject in o.targets) |
|||
{ |
|||
var rp = targetObject.transform; |
|||
var b = rp.position; |
|||
bounds.Encapsulate(b); |
|||
} |
|||
return bounds; |
|||
}; |
|||
} |
|||
} |
|||
} |
|
|||
using UnityEditor.IMGUI.Controls; |
|||
using UnityEditorInternal; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
using UnityEditor.Experimental.Rendering.HDPipeline; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
partial class HDReflectionProbeEditor |
|||
{ |
|||
enum InfluenceType |
|||
{ |
|||
Standard, |
|||
Normal |
|||
} |
|||
|
|||
void OnSceneGUI() |
|||
{ |
|||
var s = m_UIState; |
|||
var p = m_SerializedHdReflectionProbe; |
|||
var o = this; |
|||
|
|||
BakeRealtimeProbeIfPositionChanged(s, p, o); |
|||
|
|||
HDReflectionProbeUI.DoShortcutKey(p, o); |
|||
|
|||
if (!s.sceneViewEditing) |
|||
return; |
|||
|
|||
var mat = Matrix4x4.TRS(p.target.transform.position, p.target.transform.rotation, Vector3.one); |
|||
|
|||
EditorGUI.BeginChangeCheck(); |
|||
|
|||
switch (EditMode.editMode) |
|||
{ |
|||
// Influence editing
|
|||
case EditMode.SceneViewEditMode.ReflectionProbeBox: |
|||
InfluenceVolumeUI.DrawHandles_EditBase(s.influenceVolume, p.targetData.influenceVolume, o, mat, p.targetData); |
|||
break; |
|||
// Influence fade editing
|
|||
case EditMode.SceneViewEditMode.GridBox: |
|||
InfluenceVolumeUI.DrawHandles_EditInfluence(s.influenceVolume, p.targetData.influenceVolume, o, mat, p.targetData); |
|||
break; |
|||
// Influence normal fade editing
|
|||
case EditMode.SceneViewEditMode.Collider: |
|||
InfluenceVolumeUI.DrawHandles_EditInfluenceNormal(s.influenceVolume, p.targetData.influenceVolume, o, mat, p.targetData); |
|||
break; |
|||
// Origin editing
|
|||
case EditMode.SceneViewEditMode.ReflectionProbeOrigin: |
|||
Handle_OriginEditing(s, p, o); |
|||
break; |
|||
} |
|||
|
|||
if (EditorGUI.EndChangeCheck()) |
|||
Repaint(); |
|||
} |
|||
|
|||
static void Handle_OriginEditing(HDReflectionProbeUI s, SerializedHDReflectionProbe sp, Editor o) |
|||
{ |
|||
var p = (ReflectionProbe)sp.so.targetObject; |
|||
var transformPosition = p.transform.position; |
|||
var size = p.size; |
|||
|
|||
EditorGUI.BeginChangeCheck(); |
|||
var newPostion = Handles.PositionHandle(transformPosition, HDReflectionProbeEditorUtility.GetLocalSpaceRotation(p)); |
|||
|
|||
var changed = EditorGUI.EndChangeCheck(); |
|||
|
|||
if (changed || s.oldLocalSpace != HDReflectionProbeEditorUtility.GetLocalSpace(p)) |
|||
{ |
|||
var localNewPosition = s.oldLocalSpace.inverse.MultiplyPoint3x4(newPostion); |
|||
|
|||
var b = new Bounds(p.center, size); |
|||
localNewPosition = b.ClosestPoint(localNewPosition); |
|||
|
|||
Undo.RecordObject(p.transform, "Modified Reflection Probe Origin"); |
|||
p.transform.position = s.oldLocalSpace.MultiplyPoint3x4(localNewPosition); |
|||
|
|||
Undo.RecordObject(p, "Modified Reflection Probe Origin"); |
|||
p.center = HDReflectionProbeEditorUtility.GetLocalSpace(p).inverse.MultiplyPoint3x4(s.oldLocalSpace.MultiplyPoint3x4(p.center)); |
|||
|
|||
EditorUtility.SetDirty(p); |
|||
|
|||
s.UpdateOldLocalSpace(p); |
|||
} |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue