Yao Xiao Ling 6 年前
当前提交
6302a183
共有 311 个文件被更改,包括 5002 次插入2591 次删除
  1. 2
      README.md
  2. 999
      TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/2203_PlanarProbes.png
  3. 999
      TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/2207_ReflectionProbeVFace.png
  4. 3
      TestProjects/HDRP_Tests/ProjectSettings/EditorBuildSettings.asset
  5. 3
      TestProjects/LWGraphicsTest/ProjectSettings/EditorBuildSettings.asset
  6. 29
      com.unity.render-pipelines.core/CoreRP/Editor/CoreEditorUtils.cs
  7. 4
      com.unity.render-pipelines.core/CoreRP/ShaderLibrary/ImageBasedLighting.hlsl
  8. 2
      com.unity.render-pipelines.high-definition/CHANGELOG.md
  9. 6
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/HDLightEditor.cs
  10. 3
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/EditorReflectionSystem.cs
  11. 2
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Gizmos.cs
  12. 34
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Preview.cs
  13. 2
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.ProbeUtility.cs
  14. 133
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.cs
  15. 532
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeUI.Drawers.cs
  16. 102
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeUI.cs
  17. 89
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeEditor.cs
  18. 2
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeEditor.cs.meta
  19. 212
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.Handles.cs
  20. 2
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.Handles.cs.meta
  21. 121
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.cs
  22. 2
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.cs.meta
  23. 109
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDReflectionProbe.cs
  24. 81
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedPlanarReflectionProbe.cs
  25. 163
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Drawers.cs
  26. 311
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Handles.cs
  27. 20
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.cs
  28. 135
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/ProxyVolumeUI.cs
  29. 9
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/ReflectionProxyVolumeComponentUI.cs
  30. 29
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/SerializedInfluenceVolume.cs
  31. 1
      com.unity.render-pipelines.high-definition/HDRP/Lighting/LightDefinition.cs
  32. 1
      com.unity.render-pipelines.high-definition/HDRP/Lighting/LightDefinition.cs.hlsl
  33. 1
      com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoop.cs
  34. 14
      com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoop.hlsl
  35. 1
      com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoopDef.hlsl
  36. 61
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDAdditionalReflectionData.cs
  37. 36
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDProbe.cs
  38. 19
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/PlanarReflectionProbe.cs
  39. 34
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ProbeWrapper.cs
  40. 10
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ReflectionSystem.cs
  41. 167
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ReflectionSystemInternal.cs
  42. 14
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ReflectionSystemParameters.cs
  43. 16
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/Volumes/InfluenceVolume.cs
  44. 8
      com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs
  45. 4
      com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipelineAsset.cs
  46. 12
      com.unity.render-pipelines.lightweight/CHANGELOG.md
  47. 97
      com.unity.render-pipelines.lightweight/LWRP/DefaultRendererSetup.cs
  48. 2
      com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGUI/LightweightShaderGUI.cs
  49. 2
      com.unity.render-pipelines.lightweight/LWRP/IRendererSetup.cs
  50. 1
      com.unity.render-pipelines.lightweight/LWRP/LightweightAdditionalCameraData.cs
  51. 277
      com.unity.render-pipelines.lightweight/LWRP/LightweightPipeline.cs
  52. 2
      com.unity.render-pipelines.lightweight/LWRP/Passes/BeginXRRenderingPass.cs
  53. 4
      com.unity.render-pipelines.lightweight/LWRP/Passes/CopyColorPass.cs
  54. 8
      com.unity.render-pipelines.lightweight/LWRP/Passes/CopyDepthPass.cs
  55. 4
      com.unity.render-pipelines.lightweight/LWRP/Passes/CreateLightweightRenderTexturesPass.cs
  56. 6
      com.unity.render-pipelines.lightweight/LWRP/Passes/DepthOnlyPass.cs
  57. 2
      com.unity.render-pipelines.lightweight/LWRP/Passes/DirectionalShadowsPass.cs
  58. 21
      com.unity.render-pipelines.lightweight/LWRP/Passes/DrawSkyboxPass.cs
  59. 2
      com.unity.render-pipelines.lightweight/LWRP/Passes/EndXRRenderingPass.cs
  60. 2
      com.unity.render-pipelines.lightweight/LWRP/Passes/FinalBlitPass.cs
  61. 14
      com.unity.render-pipelines.lightweight/LWRP/Passes/LightweightForwardPass.cs
  62. 2
      com.unity.render-pipelines.lightweight/LWRP/Passes/LocalShadowsPass.cs
  63. 2
      com.unity.render-pipelines.lightweight/LWRP/Passes/OpaquePostProcessPass.cs
  64. 2
      com.unity.render-pipelines.lightweight/LWRP/Passes/RenderOpaqueForwardPass.cs
  65. 2
      com.unity.render-pipelines.lightweight/LWRP/Passes/RenderTransparentForwardPass.cs
  66. 2
      com.unity.render-pipelines.lightweight/LWRP/Passes/SceneViewDepthCopy.cs
  67. 2
      com.unity.render-pipelines.lightweight/LWRP/Passes/ScreenSpaceShadowResolvePass.cs
  68. 2
      com.unity.render-pipelines.lightweight/LWRP/Passes/ScriptableRenderPass.cs
  69. 2
      com.unity.render-pipelines.lightweight/LWRP/Passes/SetupForwardRenderingPass.cs
  70. 50
      com.unity.render-pipelines.lightweight/LWRP/Passes/SetupLightweightConstanstPass.cs
  71. 10
      com.unity.render-pipelines.lightweight/LWRP/Passes/TransparentPostProcessPass.cs
  72. 15
      com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/Core.hlsl
  73. 9
      com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/Input.hlsl
  74. 2
      com.unity.render-pipelines.lightweight/LWRP/ScriptableRenderer.cs.meta
  75. 15
      com.unity.render-pipelines.lightweight/LWRP/ScriptableRenderer.cs
  76. 26
      com.unity.testing.srp.lightweight/Tests/Scenes/028_PostProcessing_Custom/Scripts/InvertOpaque.cs
  77. 8
      com.unity.testing.srp.lightweight/Tests/Scenes/045_CustomLWPipe/CustomLWPipe.cs
  78. 447
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1213_Lit_Anisotropy.unity
  79. 7
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1213_Lit_Anisotropy.unity.meta
  80. 8
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1213_Lit_anisotropy.meta
  81. 1001
      TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/1213_Lit_Anisotropy.png
  82. 88
      TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/1213_Lit_Anisotropy.png.meta
  83. 23
      com.unity.render-pipelines.core/CoreRP/Editor/SettingsDisableScope.cs
  84. 11
      com.unity.render-pipelines.core/CoreRP/Editor/SettingsDisableScope.cs.meta
  85. 80
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeEditor.cs
  86. 11
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeEditor.cs.meta
  87. 45
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.ContextualMenu.cs
  88. 11
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.ContextualMenu.cs.meta
  89. 304
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Drawers.cs
  90. 11
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Drawers.cs.meta
  91. 101
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Handles.cs
  92. 11
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Handles.cs.meta
  93. 80
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Skin.cs
  94. 11
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Skin.cs.meta
  95. 90
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.cs
  96. 11
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.cs.meta
  97. 61
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDProbe.cs
  98. 11
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDProbe.cs.meta
  99. 36
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Skin.cs

2
README.md


[High Definition Pipeline Blogpost](https://blogs.unity3d.com/2018/03/16/the-high-definition-render-pipeline-focused-on-visual-quality/)
## How to use the latest version
__Note: The Master branch is our current development branch and may not work on the latest publicly available version of Unity. You should always use the latest release tag and latest Unity beta version for testing purposes.__
__Note: The Master branch is our current development branch and may not work on the latest publicly available version of Unity. To determine which version of SRP you should use with your version of Unity, go to Package Manager (Window > Package Manager) to see what versions of SRP are available for your version of Unity Editor. Then you can search the Tags tab of the Branch dropdown in the SRP GitHub for that tag number.__
To use the latest version of the SRP, follow the instructions below:
This repository consists of a folder that should be cloned outside the Assets\ folder of your Unity project. We recommend creating a new project to test SRP. Do not clone this repo into an existing project unless you want to break it, or unless you are updating to a newer version of the SRP repo.

999
TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/2203_PlanarProbes.png
文件差异内容过多而无法显示
查看文件

999
TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/2207_ReflectionProbeVFace.png
文件差异内容过多而无法显示
查看文件

3
TestProjects/HDRP_Tests/ProjectSettings/EditorBuildSettings.asset


path: Assets/GraphicTests/Scenes/1x_Materials/1212_Lit_Emission.unity
guid: f465136a9ac4cb1429a4a1761d07c3c3
- enabled: 1
path: Assets/GraphicTests/Scenes/1x_Materials/1213_Lit_Anisotropy.unity
guid: e0ebb398c814c2645af130d8b2e6b9aa
- enabled: 1
path: Assets/GraphicTests/Scenes/1x_Materials/1301_SubSurfaceScattering.unity
guid: 201c29a239df4c74ea9e1ab47082abea
- enabled: 1

3
TestProjects/LWGraphicsTest/ProjectSettings/EditorBuildSettings.asset


- enabled: 1
path: Packages/com.unity.testing.srp.lightweight/Tests/Scenes/050_Shader_Graphs.unity
guid: 6e7a83866a1e446b3becf7972371c5d0
- enabled: 0
path: Packages/com.unity.testing.srp.lightweight/Tests/Scenes/052_LWCallbacks.unity
guid: 58d22e8497ba91141b3ae7abd7b0bb41
m_configObjects: {}

29
com.unity.render-pipelines.core/CoreRP/Editor/CoreEditorUtils.cs


throw new System.ArgumentException("Colors must be a 2x3 array.");
GUILayout.BeginVertical();
if(label != GUIContent.none)
EditorGUILayout.LabelField(label);
++EditorGUI.indentLevel;
var rect = GUILayoutUtility.GetRect(0, float.MaxValue, EditorGUIUtility.singleLineHeight, EditorGUIUtility.singleLineHeight);
Rect rect = EditorGUI.IndentedRect(GUILayoutUtility.GetRect(0, float.MaxValue, EditorGUIUtility.singleLineHeight, EditorGUIUtility.singleLineHeight));
if (label != GUIContent.none)
{
var labelRect = rect;
labelRect.x -= 12f;
labelRect.width = EditorGUIUtility.labelWidth;
EditorGUI.LabelField(labelRect, label);
rect.x += EditorGUIUtility.labelWidth - 12f;
rect.width -= EditorGUIUtility.labelWidth - 12f;
}
var v = positive.vector3Value;
EditorGUI.BeginChangeCheck();
v = DrawVector3(rect, k_DrawVector6_Label, v, min, max, false, colors == null ? null : colors[0]);

GUILayout.Space(EditorGUIUtility.standardVerticalSpacing);
rect = GUILayoutUtility.GetRect(0, float.MaxValue, EditorGUIUtility.singleLineHeight, EditorGUIUtility.singleLineHeight);
rect = EditorGUI.IndentedRect(GUILayoutUtility.GetRect(0, float.MaxValue, EditorGUIUtility.singleLineHeight, EditorGUIUtility.singleLineHeight));
rect.x += EditorGUIUtility.labelWidth - 12f;
rect.width -= EditorGUIUtility.labelWidth - 12f;
--EditorGUI.indentLevel;
GUILayout.EndVertical();
}

rect = EditorGUI.IndentedRect(rect);
//rect = EditorGUI.IndentedRect(rect);
float fieldWidth = rect.width / 3f;
EditorGUI.BeginChangeCheck();
EditorGUI.MultiFloatField(rect, labels, multifloat);

//Suffix is a hack as sublabel only work with 1 character
if(addMinusPrefix)
{
Rect suffixRect = new Rect(rect.x-33, rect.y, 100, rect.height);
Rect suffixRect = new Rect(rect.x-19, rect.y, 100, rect.height);
suffixRect.x += fieldWidth + .5f;
suffixRect.x += fieldWidth + .66f;
}
}

if (colors.Length != 3)
throw new System.ArgumentException("colors must have 3 elements.");
Rect suffixRect = new Rect(rect.x - 23, rect.y, 100, rect.height);
Rect suffixRect = new Rect(rect.x - 8, rect.y, 100, rect.height);
GUIStyle colorMark = new GUIStyle(EditorStyles.label);
colorMark.normal.textColor = colors[0];
EditorGUI.LabelField(suffixRect, "|", colorMark);

4
com.unity.render-pipelines.core/CoreRP/ShaderLibrary/ImageBasedLighting.hlsl


{
// For positive anisotropy values: tangent = highlight stretch (anisotropy) direction, bitangent = grain (brush) direction.
float3 grainDirWS = (anisotropy >= 0.0) ? bitangentWS : tangentWS;
// Reduce stretching for (perceptualRoughness < 0.2).
float stretch = abs(anisotropy) * saturate(5.0 * perceptualRoughness);
// Reduce stretching depends on the perceptual roughness
float stretch = abs(anisotropy) * saturate(1.5 * sqrt(perceptualRoughness));
// NOTE: If we follow the theory we should use the modified normal for the different calculation implying a normal (like NdotV)
// However modified normal is just a hack. The goal is just to stretch a cubemap, no accuracy here. Let's save performance instead.
iblN = GetAnisotropicModifiedNormal(grainDirWS, N, V, stretch);

2
com.unity.render-pipelines.high-definition/CHANGELOG.md


- Added an error message to say to use Metal or Vulkan when trying to use OpenGL API
- Added a new Fabric shader model that supports Silk and Cotton/Wool
- Added a new HDRP Lighting Debug mode to visualize Light Volumes for Point, Spot, Line, Rectangular and Reflection Probes
- Add support for reflection probe light layers
- Improve quality of anisotropic on IBL
### Fixed
- Fix an issue where the screen where darken when rendering camera preview

6
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/HDLightEditor.cs


EditorGUILayout.Space();
EditorGUILayout.LabelField("Additional Settings", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
m_AdditionalLightData.lightLayers.intValue = Convert.ToInt32(EditorGUILayout.EnumFlagsField(s_Styles.lightLayer, (LightLayerEnum)m_AdditionalLightData.lightLayers.intValue));
var hdPipeline = RenderPipelineManager.currentPipeline as HDRenderPipeline;
using (new SettingsDisableScope(hdPipeline.asset.renderPipelineSettings.supportLightLayers))
{
m_AdditionalLightData.lightLayers.intValue = Convert.ToInt32(EditorGUILayout.EnumFlagsField(s_Styles.lightLayer, (LightLayerEnum)m_AdditionalLightData.lightLayers.intValue));
}
EditorGUILayout.PropertyField(m_AdditionalLightData.affectDiffuse, s_Styles.affectDiffuse);
EditorGUILayout.PropertyField(m_AdditionalLightData.affectSpecular, s_Styles.affectSpecular);
if (m_LightShape != LightShape.Directional)

3
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/EditorReflectionSystem.cs


AssetDatabase.ImportAsset(path);
probe.customTexture = AssetDatabase.LoadAssetAtPath<Texture2D>(path);
EditorUtility.SetDirty(probe);
}
public static void BakeAllPlanarReflectionProbes()

{
bakedTexture = new Texture2D(rt.width, rt.height, TextureFormat.RGBAHalf, true, false);
probe.bakedTexture = bakedTexture;
EditorUtility.SetDirty(probe);
}
ReflectionSystem.Render(probe, rt);

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


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

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


using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{

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

GUILayout.EndHorizontal();
return;
}
var p = target as ReflectionProbe;
if (p != null && p.texture != null && targets.Length == 1)
Texture tex = GetTexture();
if (tex != null && targets.Length == 1)
var p = target as ReflectionProbe;
return p != null && p.texture != null;
return GetTexture() != null;
}
Texture GetTexture()
{
HDProbe additional = GetTarget(target);
if (additional != null && additional.mode == UnityEngine.Rendering.ReflectionProbeMode.Realtime)
{
return additional.realtimeTexture;
}
else
{
var p = target as ReflectionProbe;
if (p != null)
return p.texture;
}
return null;
}
private void OnDestroy()

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


{
partial class HDReflectionProbeEditor
{
void InitializeAllTargetProbes()
void InitializeTargetProbe()
{
// For an unknown reason, newly created probes sometype have the type "Quad" (value = 1)
// This type of probe is not supported by Unity since 5.4

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


{
[CustomEditorForRenderPipeline(typeof(ReflectionProbe), typeof(HDRenderPipelineAsset))]
[CanEditMultipleObjects]
partial class HDReflectionProbeEditor : Editor
partial class HDReflectionProbeEditor : HDProbeEditor
{
[MenuItem("CONTEXT/ReflectionProbe/Remove Component", false, 0)]
static void RemoveReflectionProbe(MenuCommand menuCommand)

static Dictionary<ReflectionProbe, HDReflectionProbeEditor> s_ReflectionProbeEditors = new Dictionary<ReflectionProbe, HDReflectionProbeEditor>();
internal override HDProbe GetTarget(Object editorTarget)
{
return (HDProbe)s_ReflectionProbeEditors[(ReflectionProbe)editorTarget].m_AdditionalDataSerializedObject.targetObject;
}
protected override void Draw(HDProbeUI s, SerializedHDProbe serialized, Editor owner)
{
HDReflectionProbeUI.Inspector.Draw(s, serialized, owner);
}
static HDReflectionProbeEditor GetEditorFor(ReflectionProbe p)
{
HDReflectionProbeEditor e;

return null;
}
SerializedHDReflectionProbe m_SerializedHdReflectionProbe;
HDReflectionProbeUI m_UIState = new HDReflectionProbeUI();
int m_PositionHash = 0;
internal HDReflectionProbeUI m_UIState = new HDReflectionProbeUI();
get { return IsReflectionProbeEditMode(EditMode.editMode) && EditMode.IsOwner(this); }
get { return HDProbeUI.IsProbeEditMode(EditMode.editMode) && EditMode.IsOwner(this); }
void OnEnable()
protected override void OnEnable()
m_SerializedHdReflectionProbe = new SerializedHDReflectionProbe(serializedObject, m_AdditionalDataSerializedObject);
m_UIState.owner = this;
m_UIState.Reset(m_SerializedHdReflectionProbe, Repaint);
m_SerializedHDProbe = new SerializedHDReflectionProbe(serializedObject, m_AdditionalDataSerializedObject);
foreach (var t in targets)
{

InitializeAllTargetProbes();
base.OnEnable();
m_UIState.owner = this;
m_UIState.Reset(m_SerializedHDProbe, Repaint);
InitializeTargetProbe();
}
public override void OnInspectorGUI()
{
//InspectColorsGUI();
var s = m_UIState;
var p = m_SerializedHdReflectionProbe;
s.Update();
p.Update();
HDReflectionProbeUI.Inspector.Draw(s, p, this);
PerformOperations(s, p, this);
p.Apply();
//HideAdditionalComponents(false);
HDReflectionProbeUI.DoShortcutKey(p, this);
}
public static bool IsReflectionProbeEditMode(EditMode.SceneViewEditMode editMode)
{
return editMode == EditMode.SceneViewEditMode.ReflectionProbeBox || editMode == EditMode.SceneViewEditMode.Collider || editMode == EditMode.SceneViewEditMode.GridBox ||
editMode == EditMode.SceneViewEditMode.ReflectionProbeOrigin;
}
static void PerformOperations(HDReflectionProbeUI s, SerializedHDReflectionProbe p, HDReflectionProbeEditor o)
{
}
void HideAdditionalComponents(bool visible)
{
var adds = CoreEditorUtils.GetAdditionalData<HDAdditionalReflectionData>(targets);
var flags = visible ? HideFlags.None : HideFlags.HideInInspector;
for (var i = 0; i < targets.Length; ++i)
{
var addData = adds[i];
addData.hideFlags = flags;
}
}
void BakeRealtimeProbeIfPositionChanged(HDReflectionProbeUI s, SerializedHDReflectionProbe sp, Editor o)
{
if (Application.isPlaying
|| ((ReflectionProbeMode)sp.mode.intValue) != ReflectionProbeMode.Realtime)
{
m_PositionHash = 0;
return;
}
var hash = 0;
for (var i = 0; i < sp.so.targetObjects.Length; i++)
{
var p = (ReflectionProbe)sp.so.targetObjects[i];
var tr = p.GetComponent<Transform>();
hash ^= tr.position.GetHashCode();
}
if (hash != m_PositionHash)
{
m_PositionHash = hash;
for (var i = 0; i < sp.so.targetObjects.Length; i++)
{
var p = (ReflectionProbe)sp.so.targetObjects[i];
p.RenderProbe();
}
}
}
static void ApplyConstraintsOnTargets(HDReflectionProbeUI s, SerializedHDReflectionProbe sp, Editor o)
{
switch ((InfluenceShape)sp.influenceVolume.shape.enumValueIndex)
{
case InfluenceShape.Box:
{
var maxBlendDistance = sp.influenceVolume.boxSize.vector3Value;
sp.targetData.influenceVolume.boxBlendDistancePositive = Vector3.Min(sp.targetData.influenceVolume.boxBlendDistancePositive, maxBlendDistance);
sp.targetData.influenceVolume.boxBlendDistanceNegative = Vector3.Min(sp.targetData.influenceVolume.boxBlendDistanceNegative, maxBlendDistance);
sp.targetData.influenceVolume.boxBlendNormalDistancePositive = Vector3.Min(sp.targetData.influenceVolume.boxBlendNormalDistancePositive, maxBlendDistance);
sp.targetData.influenceVolume.boxBlendNormalDistanceNegative = Vector3.Min(sp.targetData.influenceVolume.boxBlendNormalDistanceNegative, maxBlendDistance);
break;
}
case InfluenceShape.Sphere:
{
var maxBlendDistance = Vector3.one * sp.influenceVolume.sphereRadius.floatValue;
sp.targetData.influenceVolume.boxBlendDistancePositive = Vector3.Min(sp.targetData.influenceVolume.boxBlendDistancePositive, maxBlendDistance);
sp.targetData.influenceVolume.boxBlendDistanceNegative = Vector3.Min(sp.targetData.influenceVolume.boxBlendDistanceNegative, maxBlendDistance);
sp.targetData.influenceVolume.boxBlendNormalDistancePositive = Vector3.Min(sp.targetData.influenceVolume.boxBlendNormalDistancePositive, maxBlendDistance);
sp.targetData.influenceVolume.boxBlendNormalDistanceNegative = Vector3.Min(sp.targetData.influenceVolume.boxBlendNormalDistanceNegative, maxBlendDistance);
break;
}
}
//unhide previously hidden components
probe.hideFlags = HideFlags.None;
}
}
}

532
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeUI.Drawers.cs


using System;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine.Rendering;

using CED = CoreEditorDrawer<HDReflectionProbeUI, SerializedHDReflectionProbe>;
using _ = CoreEditorUtils;
using CED = CoreEditorDrawer<HDProbeUI, SerializedHDProbe>;
public static readonly CED.IDrawer[] Inspector;
SectionProxyVolumeSettings,
ProxyVolumeSettings,
SectionInfluenceProxyMismatch,
CED.Action((s, d, o) => Drawer_DifferentShapeError(s, d, o)),
SectionAdditionalSettings,
ButtonBake
SectionFoldoutAdditionalSettings,
CED.Action((s, d, o) => Drawer_SectionBakeButton(s, d, o))
public static readonly CED.IDrawer[] Inspector;
public static readonly CED.IDrawer SectionPrimarySettings = CED.Group(
CED.Action(Drawer_Toolbar),
static readonly CED.IDrawer SectionPrimarySettings = CED.Group(
CED.Action((s, d, o) => Drawer_Toolbars(s, d, o)),
CED.FadeGroup((s, p, o, i) => s.IsSectionExpandedMode((ReflectionProbeMode)i),
CED.FadeGroup((s, p, o, i) => s.IsSectionExpandedReflectionProbeMode((ReflectionProbeMode)i),
CED.noop, // Baked
CED.Action(Drawer_ModeSettingsRealtime), // Realtime
CED.Action(Drawer_ModeSettingsCustom) // Custom
CED.noop, // Baked
CED.Action((s, d, o) => Drawer_ModeSettingsRealtime(s, d, o)), // Realtime
CED.Action((s, d, o) => Drawer_ModeSettingsCustom(s, d, o)) // Custom
public static readonly CED.IDrawer SectionProxyVolumeSettings = CED.FoldoutGroup(
"Proxy Volume",
(s, p, o) => s.isSectionExpandedProxyVolume,
FoldoutOption.Indent,
CED.Action(Drawer_ProxyVolume),
CED.space,
CED.Action(Drawer_ProjectionSettings)
);
public static readonly CED.IDrawer SectionInfluenceVolumeSettings = CED.FoldoutGroup(
"Influence Volume",
(s, p, o) => s.isSectionExpandedInfluenceVolume,
FoldoutOption.Indent,
CED.Action(Drawer_InfluenceAdvancedSwitch),
CED.space,
CED.Action(Drawer_InfluenceShape),
CED.space,
CED.Action(Drawer_InfluenceAreas)
);
public static readonly CED.IDrawer SectionInfluenceProxyMismatch = CED.Action(Drawer_InfluenceProxyMissmatch);
public static readonly CED.IDrawer SectionCaptureSettings = CED.FoldoutGroup(
"Capture Settings",
static readonly CED.IDrawer SectionCaptureSettings = CED.FoldoutGroup(
captureSettingsHeader,
public static readonly CED.IDrawer SectionAdditionalSettings = CED.FoldoutGroup(
"Artistic Settings",
(s, p, o) => s.isSectionExpandedAdditional,
FoldoutOption.Indent,
CED.Action(Drawer_AdditionalSettings)
);
public static readonly CED.IDrawer ButtonBake = CED.Action(Drawer_BakeActions);
static void Drawer_CaptureSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
static void Drawer_CaptureSettings(HDProbeUI s, SerializedHDProbe p, Editor owner)
EditorGUILayout.LabelField(CoreEditorUtils.GetContent("Resolution"), CoreEditorUtils.GetContent(p.resolution.intValue.ToString()));
EditorGUILayout.PropertyField(p.shadowDistance, CoreEditorUtils.GetContent("Shadow Distance"));
EditorGUILayout.PropertyField(p.cullingMask, CoreEditorUtils.GetContent("Culling Mask"));
EditorGUILayout.PropertyField(p.useOcclusionCulling, CoreEditorUtils.GetContent("Use Occlusion Culling"));
EditorGUILayout.PropertyField(p.nearClip, CoreEditorUtils.GetContent("Near Clip"));
EditorGUILayout.PropertyField(p.farClip, CoreEditorUtils.GetContent("Far Clip"));
}
static void Drawer_AdditionalSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
EditorGUILayout.PropertyField(p.weight, CoreEditorUtils.GetContent("Influence Volume Weight|Blending weight to use while interpolating between influence volume. (Reminder: Sky is an Influence Volume too)."));
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(p.multiplier, CoreEditorUtils.GetContent("Multiplier|Tweeking option to enhance reflection."));
if (EditorGUI.EndChangeCheck())
p.multiplier.floatValue = Mathf.Max(0.0f, p.multiplier.floatValue);
if (p.so.targetObjects.Length == 1)
{
var probe = p.target;
if (probe.mode == ReflectionProbeMode.Custom && probe.customBakedTexture != null)
{
var cubemap = probe.customBakedTexture as Cubemap;
if (cubemap && cubemap.mipmapCount == 1)
EditorGUILayout.HelpBox("No mipmaps in the cubemap, Smoothness value in Standard shader will be ignored.", MessageType.Warning);
}
}
}
static void Drawer_BakeActions(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
EditorReflectionSystemGUI.DrawBakeButton((ReflectionProbeMode)p.mode.intValue, p.target);
}
static void Drawer_ProxyVolume(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
EditorGUILayout.PropertyField(p.proxyVolumeComponent, _.GetContent("Proxy Volume"));
if (p.proxyVolumeComponent.objectReferenceValue == null)
{
EditorGUILayout.HelpBox(
"When no Proxy setted, Influence shape will be used as Proxy shape too.",
MessageType.Info,
true
);
}
}
#region Influence Volume
static void Drawer_InfluenceProxyMissmatch(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
if (p.proxyVolumeComponent.objectReferenceValue != null)
{
var proxy = (ReflectionProxyVolumeComponent)p.proxyVolumeComponent.objectReferenceValue;
if ((int)proxy.proxyVolume.shape != p.influenceVolume.shape.enumValueIndex)
EditorGUILayout.HelpBox(
"Proxy volume and influence volume have different shape types, this is not supported.",
MessageType.Error,
true
);
}
}
static void Drawer_InfluenceBoxSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
bool advanced = p.influenceVolume.editorAdvancedModeEnabled.boolValue;
var maxBlendDistance = p.boxSize.vector3Value * 0.5f;
EditorGUILayout.BeginHorizontal();
Drawer_AdvancedBlendDistance(
p,
false,
maxBlendDistance,
CoreEditorUtils.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes.")
);
if (GUILayout.Button(toolbar_Contents[1], GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight((advanced ? 3 : 1) * (EditorGUIUtility.singleLineHeight + 3))))
{
EditMode.ChangeEditMode(k_Toolbar_SceneViewEditModes[1], GetBoundsGetter(p)(), owner);
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.LabelField(resolutionContent, CoreEditorUtils.GetContent(p.resolution.intValue.ToString()));
EditorGUILayout.BeginHorizontal();
Drawer_AdvancedBlendDistance(
p,
true,
maxBlendDistance,
CoreEditorUtils.GetContent("Blend Normal Distance|Area around the probe where the normals influence the probe. Only used in deferred probes.")
);
if (GUILayout.Button(toolbar_Contents[2], GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight((advanced ? 3 : 1) * (EditorGUIUtility.singleLineHeight + 3))))
{
EditMode.ChangeEditMode(k_Toolbar_SceneViewEditModes[2], GetBoundsGetter(p)(), owner);
}
EditorGUILayout.EndHorizontal();
if (advanced)
{
CoreEditorUtils.DrawVector6(
CoreEditorUtils.GetContent("Face fade|Fade faces of the cubemap."),
p.influenceVolume.boxSideFadePositive, p.influenceVolume.boxSideFadeNegative, Vector3.zero, Vector3.one, HDReflectionProbeEditor.k_handlesColor);
}
EditorGUILayout.PropertyField(p.shadowDistance, shadowDistanceContent);
EditorGUILayout.PropertyField(p.cullingMask, cullingMaskContent);
EditorGUILayout.PropertyField(p.useOcclusionCulling, useOcclusionCullingContent);
EditorGUILayout.PropertyField(p.nearClip, nearClipCullingContent);
EditorGUILayout.PropertyField(p.farClip, farClipCullingContent);
static void Drawer_AdvancedBlendDistance(SerializedHDReflectionProbe p, bool isNormal, Vector3 maxBlendDistance, GUIContent content)
{
SerializedProperty blendDistancePositive = isNormal ? p.influenceVolume.boxBlendNormalDistancePositive : p.influenceVolume.boxBlendDistancePositive;
SerializedProperty blendDistanceNegative = isNormal ? p.influenceVolume.boxBlendNormalDistanceNegative : p.influenceVolume.boxBlendDistanceNegative;
SerializedProperty editorAdvancedModeBlendDistancePositive = isNormal ? p.influenceVolume.editorAdvancedModeBlendNormalDistancePositive : p.influenceVolume.editorAdvancedModeBlendDistancePositive;
SerializedProperty editorAdvancedModeBlendDistanceNegative = isNormal ? p.influenceVolume.editorAdvancedModeBlendNormalDistanceNegative : p.influenceVolume.editorAdvancedModeBlendDistanceNegative;
SerializedProperty editorSimplifiedModeBlendDistance = isNormal ? p.influenceVolume.editorSimplifiedModeBlendNormalDistance : p.influenceVolume.editorSimplifiedModeBlendDistance;
Vector3 bdp = blendDistancePositive.vector3Value;
Vector3 bdn = blendDistanceNegative.vector3Value;
EditorGUILayout.BeginVertical();
if (p.influenceVolume.editorAdvancedModeEnabled.boolValue)
{
EditorGUI.BeginChangeCheck();
CoreEditorUtils.DrawVector6(
content,
editorAdvancedModeBlendDistancePositive, editorAdvancedModeBlendDistanceNegative, Vector3.zero, maxBlendDistance, HDReflectionProbeEditor.k_handlesColor);
if(EditorGUI.EndChangeCheck())
{
blendDistancePositive.vector3Value = editorAdvancedModeBlendDistancePositive.vector3Value;
blendDistanceNegative.vector3Value = editorAdvancedModeBlendDistanceNegative.vector3Value;
p.Apply();
}
}
else
{
float distance = editorSimplifiedModeBlendDistance.floatValue;
EditorGUI.BeginChangeCheck();
distance = EditorGUILayout.FloatField(content, distance);
if (EditorGUI.EndChangeCheck())
{
Vector3 decal = Vector3.one * distance;
bdp.x = Mathf.Clamp(decal.x, 0f, maxBlendDistance.x);
bdp.y = Mathf.Clamp(decal.y, 0f, maxBlendDistance.y);
bdp.z = Mathf.Clamp(decal.z, 0f, maxBlendDistance.z);
bdn.x = Mathf.Clamp(decal.x, 0f, maxBlendDistance.x);
bdn.y = Mathf.Clamp(decal.y, 0f, maxBlendDistance.y);
bdn.z = Mathf.Clamp(decal.z, 0f, maxBlendDistance.z);
blendDistancePositive.vector3Value = bdp;
blendDistanceNegative.vector3Value = bdn;
editorSimplifiedModeBlendDistance.floatValue = distance;
p.Apply();
}
}
GUILayout.EndVertical();
}
static void Drawer_InfluenceSphereSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
var maxBlendDistance = p.influenceVolume.sphereRadius.floatValue;
var blendDistance = p.influenceVolume.boxBlendDistancePositive.vector3Value.x;
EditorGUILayout.BeginHorizontal();
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = p.influenceVolume.boxBlendDistancePositive.hasMultipleDifferentValues;
blendDistance = EditorGUILayout.Slider(CoreEditorUtils.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes."), blendDistance, 0, maxBlendDistance);
if (EditorGUI.EndChangeCheck())
{
p.influenceVolume.boxBlendDistancePositive.vector3Value = Vector3.one * blendDistance;
p.influenceVolume.boxBlendDistanceNegative.vector3Value = Vector3.one * blendDistance;
}
if (GUILayout.Button(toolbar_Contents[1], GUILayout.Width(28f), GUILayout.Height(EditorGUIUtility.singleLineHeight + 3)))
{
EditMode.ChangeEditMode(k_Toolbar_SceneViewEditModes[1], GetBoundsGetter(p)(), owner);
}
EditorGUILayout.EndHorizontal();
var blendNormalDistance = p.influenceVolume.boxBlendNormalDistancePositive.vector3Value.x;
EditorGUILayout.BeginHorizontal();
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = p.influenceVolume.boxBlendNormalDistancePositive.hasMultipleDifferentValues;
blendNormalDistance = EditorGUILayout.Slider(CoreEditorUtils.GetContent("Blend Normal Distance|Area around the probe where the normals influence the probe. Only used in deferred probes."), blendNormalDistance, 0, maxBlendDistance);
if (EditorGUI.EndChangeCheck())
{
p.influenceVolume.boxBlendNormalDistancePositive.vector3Value = Vector3.one * blendNormalDistance;
p.influenceVolume.boxBlendNormalDistanceNegative.vector3Value = Vector3.one * blendNormalDistance;
}
if (GUILayout.Button(toolbar_Contents[2], GUILayout.Width(28f), GUILayout.Height(EditorGUIUtility.singleLineHeight + 3)))
{
EditMode.ChangeEditMode(k_Toolbar_SceneViewEditModes[2], GetBoundsGetter(p)(), owner);
}
EditorGUILayout.EndHorizontal();
EditorGUI.showMixedValue = false;
}
#endregion
#region Field Drawers
static void Drawer_ReflectionProbeMode(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
static void Drawer_ReflectionProbeMode(HDProbeUI s, SerializedHDProbe p, Editor owner)
HDReflectionProbeUI ui = ((HDReflectionProbeEditor)owner).m_UIState;
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = p.mode.hasMultipleDifferentValues;
EditorGUILayout.IntPopup(p.mode, k_Content_ReflectionProbeMode, k_Content_ReflectionProbeModeValues, 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)."));

s.SetModeTarget(p.mode.intValue);
}
}
static void Drawer_InfluenceAdvancedSwitch(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
using (new EditorGUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
bool advanced = p.influenceVolume.editorAdvancedModeEnabled.boolValue;
advanced = !GUILayout.Toggle(!advanced, CoreEditorUtils.GetContent("Normal|Normal parameters mode (only change for box shape)."), EditorStyles.miniButtonLeft, GUILayout.Width(60f), GUILayout.ExpandWidth(false));
advanced = GUILayout.Toggle(advanced, CoreEditorUtils.GetContent("Advanced|Advanced parameters mode (only change for box shape)."), EditorStyles.miniButtonRight, GUILayout.Width(60f), GUILayout.ExpandWidth(false));
s.alternativeBoxBlendHandle.allHandleControledByOne = s.alternativeBoxBlendNormalHandle.allHandleControledByOne = !advanced;
if (p.influenceVolume.editorAdvancedModeEnabled.boolValue ^ advanced)
{
p.influenceVolume.editorAdvancedModeEnabled.boolValue = advanced;
if (advanced)
{
p.influenceVolume.boxBlendDistancePositive.vector3Value = p.influenceVolume.editorAdvancedModeBlendDistancePositive.vector3Value;
p.influenceVolume.boxBlendDistanceNegative.vector3Value = p.influenceVolume.editorAdvancedModeBlendDistanceNegative.vector3Value;
p.influenceVolume.boxBlendNormalDistancePositive.vector3Value = p.influenceVolume.editorAdvancedModeBlendNormalDistancePositive.vector3Value;
p.influenceVolume.boxBlendNormalDistanceNegative.vector3Value = p.influenceVolume.editorAdvancedModeBlendNormalDistanceNegative.vector3Value;
}
else
{
p.influenceVolume.boxBlendDistanceNegative.vector3Value = p.influenceVolume.boxBlendDistancePositive.vector3Value = Vector3.one * p.influenceVolume.editorSimplifiedModeBlendDistance.floatValue;
p.influenceVolume.boxBlendNormalDistanceNegative.vector3Value = p.influenceVolume.boxBlendNormalDistancePositive.vector3Value = Vector3.one * p.influenceVolume.editorSimplifiedModeBlendNormalDistance.floatValue;
}
p.Apply();
}
}
}
static void Drawer_InfluenceShape(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = p.influenceVolume.shape.hasMultipleDifferentValues;
EditorGUILayout.PropertyField(p.influenceVolume.shape, CoreEditorUtils.GetContent("Shape"));
EditorGUI.showMixedValue = false;
if (EditorGUI.EndChangeCheck())
s.SetShapeTarget(p.influenceVolume.shape.intValue);
switch ((InfluenceShape)p.influenceVolume.shape.enumValueIndex)
{
case InfluenceShape.Box:
Drawer_InfluenceShapeBoxSettings(s, p, owner);
break;
case InfluenceShape.Sphere:
Drawer_InfluenceShapeSphereSettings(s, p, owner);
break;
}
}
static void Drawer_InfluenceShapeBoxSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(p.boxSize, 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."));
if (GUILayout.Button(toolbar_Contents[0], GUILayout.Width(28f), GUILayout.Height(EditorGUIUtility.singleLineHeight + 3)))
{
EditMode.ChangeEditMode(EditMode.SceneViewEditMode.ReflectionProbeBox, GetBoundsGetter(p)(), owner);
}
EditorGUILayout.EndHorizontal();
EditorGUI.BeginChangeCheck();
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(p.boxOffset, CoreEditorUtils.GetContent("Box Offset|The center of the box in which the reflections will be applied to objects. The value is relative to the position of the Game Object."));
if (GUILayout.Button(toolbar_Contents[3], GUILayout.Width(28f), GUILayout.Height(EditorGUIUtility.singleLineHeight + 3)))
{
EditMode.ChangeEditMode(EditMode.SceneViewEditMode.ReflectionProbeOrigin, GetBoundsGetter(p)(), owner);
}
EditorGUILayout.EndHorizontal();
if (EditorGUI.EndChangeCheck())
{
var center = p.boxOffset.vector3Value;
var size = p.boxSize.vector3Value;
if (HDReflectionProbeEditorUtility.ValidateAABB(p.target, ref center, ref size))
{
//clamp to contains object center instead of resizing
Vector3 projector = (center - p.boxOffset.vector3Value).normalized;
p.boxOffset.vector3Value = center + Mathf.Abs(Vector3.Dot((p.boxSize.vector3Value - size) * .5f, projector)) * projector;
}
}
}
static void Drawer_InfluenceShapeSphereSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(p.influenceVolume.sphereRadius, CoreEditorUtils.GetContent("Radius"));
if (GUILayout.Button(toolbar_Contents[0], GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.Height(EditorGUIUtility.singleLineHeight + 3)))
{
EditMode.ChangeEditMode(EditMode.SceneViewEditMode.ReflectionProbeBox, GetBoundsGetter(p)(), owner);
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(p.boxOffset, CoreEditorUtils.GetContent("Sphere Offset|The center of the sphere in which the reflections will be applied to objects. The value is relative to the position of the Game Object."));
if (GUILayout.Button(toolbar_Contents[3], GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.Height(EditorGUIUtility.singleLineHeight + 3)))
{
EditMode.ChangeEditMode(EditMode.SceneViewEditMode.ReflectionProbeOrigin, GetBoundsGetter(p)(), owner);
}
EditorGUILayout.EndHorizontal();
}
static void Drawer_InfluenceAreas(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
if (s.IsSectionExpandedShape(InfluenceShape.Box).value)
{
Drawer_InfluenceBoxSettings(s, p, owner);
}
if (s.IsSectionExpandedShape(InfluenceShape.Sphere).value)
{
Drawer_InfluenceSphereSettings(s, p, owner);
}
}
static void Drawer_ProjectionSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
EditorGUILayout.PropertyField(p.boxProjection, CoreEditorUtils.GetContent("Parallax Correction|Parallax Correction causes 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. Setting Parallax Correction to False and the cubemap reflection will be treated as coming from infinitely far away. Note that this feature can be globally disabled from Graphics Settings -> Tier Settings"));
}
static void Drawer_IntensityMultiplier(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
EditorGUILayout.PropertyField(p.intensityMultiplier, CoreEditorUtils.GetContent("Intensity"));
}
#endregion
#region Toolbar
static readonly EditMode.SceneViewEditMode[] k_Toolbar_SceneViewEditModes =
{
EditMode.SceneViewEditMode.ReflectionProbeBox,
EditMode.SceneViewEditMode.GridBox,
EditMode.SceneViewEditMode.Collider,
EditMode.SceneViewEditMode.ReflectionProbeOrigin
};
static GUIContent[] s_Toolbar_Contents = null;
static GUIContent[] toolbar_Contents
{
get
{
return s_Toolbar_Contents ?? (s_Toolbar_Contents = new[]
{
EditorGUIUtility.IconContent("EditCollider", "|Modify the extents of the reflection probe. (SHIFT+1)"),
EditorGUIUtility.IconContent("PreMatCube", "|Modify the influence volume of the reflection probe. (SHIFT+2)"),
EditorGUIUtility.IconContent("SceneViewOrtho", "|Modify the influence normal volume of the reflection probe. (SHIFT+3)"),
EditorGUIUtility.IconContent("MoveTool", "|Move the selected objects.")
});
ui.SetModeTarget(p.mode.intValue);
p.Apply();
static void Drawer_Toolbar(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
if (p.so.targetObjects.Length > 1)
return;
// Show the master tool selector
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUI.changed = false;
var oldEditMode = EditMode.editMode;
EditMode.DoInspectorToolbar(k_Toolbar_SceneViewEditModes, toolbar_Contents, GetBoundsGetter(p), owner);
//if (GUILayout.Button(EditorGUIUtility.IconContent("Navigation", "|Fit the reflection probe volume to the surrounding colliders.")))
// s.AddOperation(Operation.FitVolumeToSurroundings);
if (oldEditMode != EditMode.editMode)
{
switch (EditMode.editMode)
{
case EditMode.SceneViewEditMode.ReflectionProbeOrigin:
s.UpdateOldLocalSpace(p.target);
break;
}
}
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(SerializedHDReflectionProbe p)
{
return () =>
{
var bounds = new Bounds();
foreach (var targetObject in p.so.targetObjects)
{
var rp = (ReflectionProbe)targetObject;
var b = rp.bounds;
bounds.Encapsulate(b);
}
return bounds;
};
}
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;
};
}
static readonly KeyCode[] k_ShortCutKeys =
{
KeyCode.Alpha1,
KeyCode.Alpha2,
KeyCode.Alpha3,
};
public static void DoShortcutKey(SerializedHDReflectionProbe p, Editor o)
{
var evt = Event.current;
if (evt.type != EventType.KeyDown || !evt.shift)
return;
for (var i = 0; i < k_ShortCutKeys.Length; ++i)
{
if (evt.keyCode == k_ShortCutKeys[i])
{
var mode = EditMode.editMode == k_Toolbar_SceneViewEditModes[i]
? EditMode.SceneViewEditMode.None
: k_Toolbar_SceneViewEditModes[i];
EditMode.ChangeEditMode(mode, GetBoundsGetter(p)(), o);
evt.Use();
break;
}
}
}
#endregion
static void Drawer_ModeSettingsCustom(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
static void Drawer_ModeSettingsCustom(HDProbeUI s, SerializedHDProbe p, Editor owner)
EditorGUILayout.PropertyField(p.renderDynamicObjects, CoreEditorUtils.GetContent("Dynamic Objects|If enabled dynamic objects are also rendered into the cubemap"));
SerializedHDReflectionProbe probe = (SerializedHDReflectionProbe)p;
EditorGUILayout.PropertyField(probe.renderDynamicObjects, CoreEditorUtils.GetContent("Dynamic Objects|If enabled dynamic objects are also rendered into the cubemap"));
EditorGUI.showMixedValue = p.customBakedTexture.hasMultipleDifferentValues;
EditorGUI.showMixedValue = probe.customBakedTexture.hasMultipleDifferentValues;
var customBakedTexture = EditorGUILayout.ObjectField(CoreEditorUtils.GetContent("Cubemap"), p.customBakedTexture.objectReferenceValue, typeof(Cubemap), false);
var customBakedTexture = EditorGUILayout.ObjectField(CoreEditorUtils.GetContent("Cubemap"), probe.customBakedTexture.objectReferenceValue, typeof(Cubemap), false);
p.customBakedTexture.objectReferenceValue = customBakedTexture;
probe.customBakedTexture.objectReferenceValue = customBakedTexture;
static void Drawer_ModeSettingsRealtime(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
static void Drawer_ModeSettingsRealtime(HDProbeUI s, SerializedHDProbe p, Editor owner)
EditorGUILayout.PropertyField(p.refreshMode, CoreEditorUtils.GetContent("Refresh Mode|Controls how this probe refreshes in the Player"));
EditorGUILayout.PropertyField(p.timeSlicingMode, CoreEditorUtils.GetContent("Time Slicing|If enabled this probe will update over several frames, to help reduce the impact on the frame rate"));
//SerializedHDReflectionProbe probe = (SerializedHDReflectionProbe)p;
//EditorGUILayout.PropertyField(p.refreshMode, CoreEditorUtils.GetContent("Refresh Mode|Controls how this probe refreshes in the Player"));
//EditorGUILayout.PropertyField(probe.timeSlicingMode, CoreEditorUtils.GetContent("Time Slicing|If enabled this probe will update over several frames, to help reduce the impact on the frame rate"));
}
#endregion

102
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeUI.cs


namespace UnityEditor.Experimental.Rendering.HDPipeline
{
internal partial class HDReflectionProbeUI : BaseUI<SerializedHDReflectionProbe>
internal partial class HDReflectionProbeUI : HDProbeUI
const int k_AnimBoolSingleFieldCount = 4;
static readonly int k_ReflectionProbeModeCount = Enum.GetValues(typeof(ReflectionProbeMode)).Length;
static readonly int k_ReflectionInfluenceShapeCount = Enum.GetValues(typeof(InfluenceShape)).Length;
static readonly int k_AnimBoolsCount = k_ReflectionProbeModeCount + k_ReflectionInfluenceShapeCount + k_AnimBoolSingleFieldCount;
public InfluenceVolumeUI influenceVolume = new InfluenceVolumeUI();
internal HDReflectionProbeUI()
{
toolBars = new[] { ToolBar.InfluenceShape | ToolBar.Blend | ToolBar.NormalBlend, ToolBar.CapturePosition };
}
[Flags]
public enum Operation

public void ClearOperation(Operation op) { operations &= ~op; }
public void AddOperation(Operation op) { operations |= op; }
public Gizmo6FacesBox alternativeBoxInfluenceHandle;
public Gizmo6FacesBoxContained alternativeBoxBlendHandle;
public Gizmo6FacesBoxContained alternativeBoxBlendNormalHandle;
public SphereBoundsHandle sphereInfluenceHandle = new SphereBoundsHandle();
public SphereBoundsHandle sphereProjectionHandle = new SphereBoundsHandle();
public SphereBoundsHandle sphereBlendHandle = new SphereBoundsHandle();
public SphereBoundsHandle sphereBlendNormalHandle = new SphereBoundsHandle();
public AnimBool isSectionExpandedProxyVolume { get { return m_AnimBools[0]; } }
public AnimBool isSectionExpandedInfluenceVolume { get { return m_AnimBools[1]; } }
public AnimBool isSectionExpandedCaptureSettings { get { return m_AnimBools[2]; } }
public AnimBool isSectionExpandedAdditional { get { return m_AnimBools[3]; } }
public bool HasAndClearOperation(Operation op)
{
var has = HasOperation(op);

public bool sceneViewEditing
{
get { return HDReflectionProbeEditor.IsReflectionProbeEditMode(EditMode.editMode) && EditMode.IsOwner(owner); }
}
public HDReflectionProbeUI()
: base(k_AnimBoolsCount)
{
isSectionExpandedProxyVolume.value = true;
isSectionExpandedCaptureSettings.value = true;
isSectionExpandedInfluenceVolume.value = true;
isSectionExpandedAdditional.value = false;
alternativeBoxInfluenceHandle = new Gizmo6FacesBox(monochromeFace:true, monochromeSelectedFace:true);
alternativeBoxBlendHandle = new Gizmo6FacesBoxContained(alternativeBoxInfluenceHandle, monochromeFace:true, monochromeSelectedFace:true);
alternativeBoxBlendNormalHandle = new Gizmo6FacesBoxContained(alternativeBoxInfluenceHandle, monochromeFace:true, monochromeSelectedFace:true);
Color[] handleColors = new Color[]
{
HDReflectionProbeEditor.k_handlesColor[0][0],
HDReflectionProbeEditor.k_handlesColor[0][1],
HDReflectionProbeEditor.k_handlesColor[0][2],
HDReflectionProbeEditor.k_handlesColor[1][0],
HDReflectionProbeEditor.k_handlesColor[1][1],
HDReflectionProbeEditor.k_handlesColor[1][2]
};
alternativeBoxInfluenceHandle.handleColors = handleColors;
alternativeBoxBlendHandle.handleColors = handleColors;
alternativeBoxBlendNormalHandle.handleColors = handleColors;
alternativeBoxInfluenceHandle.faceColors = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorExtent };
alternativeBoxInfluenceHandle.faceColorsSelected = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorExtentFace };
alternativeBoxBlendHandle.faceColors = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorInfluenceBlend };
alternativeBoxBlendHandle.faceColorsSelected = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorInfluenceBlendFace };
alternativeBoxBlendNormalHandle.faceColors = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorInfluenceNormalBlend };
alternativeBoxBlendNormalHandle.faceColorsSelected = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorInfluenceNormalBlendFace };
get { return HDProbeUI.IsProbeEditMode(EditMode.editMode) && EditMode.IsOwner(owner); }
SetModeTarget(data.mode.hasMultipleDifferentValues ? -1 : data.mode.intValue);
SetShapeTarget(data.influenceVolume.shape.hasMultipleDifferentValues ? -1 : data.influenceVolume.shape.intValue);
influenceVolume.Update();
public AnimBool IsSectionExpandedMode(ReflectionProbeMode mode)
{
return m_AnimBools[k_AnimBoolSingleFieldCount + (int)mode];
}
public void SetModeTarget(int value)
{
for (var i = 0; i < k_ReflectionProbeModeCount; i++)
GetReflectionProbeModeBool(i).target = i == value;
}
public AnimBool IsSectionExpandedShape(InfluenceShape value)
{
return m_AnimBools[k_AnimBoolSingleFieldCount + k_ReflectionProbeModeCount + (int)value];
}
public void SetShapeTarget(int value)
{
for (var i = 0; i < k_ReflectionInfluenceShapeCount; i++)
GetReflectionInfluenceShapeBool(i).target = i == value;
}
}
AnimBool GetReflectionProbeModeBool(int i)
{
return m_AnimBools[k_AnimBoolSingleFieldCount + i];
}
AnimBool GetReflectionInfluenceShapeBool(int i)
{
return m_AnimBools[k_AnimBoolSingleFieldCount + k_ReflectionProbeModeCount + i];
}
public override void Reset(SerializedHDReflectionProbe data, UnityAction repaint)
{
influenceVolume.Reset(data.influenceVolume, repaint);
base.Reset(data, repaint);
}
}
}

89
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeEditor.cs


using UnityEngine.Experimental.Rendering;
using UnityEngine.Experimental.Rendering.HDPipeline;
using Object = UnityEngine.Object;
using System.Linq;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{

[CanEditMultipleObjects]
class PlanarReflectionProbeEditor : Editor
class PlanarReflectionProbeEditor : HDProbeEditor
static Dictionary<PlanarReflectionProbe, PlanarReflectionProbeUI> s_StateMap = new Dictionary<PlanarReflectionProbe, PlanarReflectionProbeUI>();
const float k_PreviewHeight = 128;
public static bool TryGetUIStateFor(PlanarReflectionProbe p, out PlanarReflectionProbeUI r)
{
return s_StateMap.TryGetValue(p, out r);
}
[DidReloadScripts]
static void DidReloadScripts()
{

}
}
SerializedPlanarReflectionProbe m_SerializedAsset;
PlanarReflectionProbeUI m_UIState = new PlanarReflectionProbeUI();
PlanarReflectionProbeUI[] m_UIHandleState;
PlanarReflectionProbe[] m_TypedTargets;
List<Texture> m_PreviewedTextures = new List<Texture>();
void OnEnable()
internal override HDProbe GetTarget(Object editorTarget)
m_SerializedAsset = new SerializedPlanarReflectionProbe(serializedObject);
m_UIState.Reset(m_SerializedAsset, Repaint);
m_TypedTargets = new PlanarReflectionProbe[targets.Length];
m_UIHandleState = new PlanarReflectionProbeUI[m_TypedTargets.Length];
for (var i = 0; i < m_TypedTargets.Length; i++)
{
m_TypedTargets[i] = (PlanarReflectionProbe)targets[i];
m_UIHandleState[i] = new PlanarReflectionProbeUI();
m_UIHandleState[i].Reset(m_SerializedAsset, null);
s_StateMap[m_TypedTargets[i]] = m_UIHandleState[i];
}
PlanarReflectionProbe probe = (PlanarReflectionProbe)target;
probe.influenceVolume.Init(probe);
return editorTarget as HDProbe;
void OnDisable()
protected override void Draw(HDProbeUI s, SerializedHDProbe serialized, Editor owner)
for (var i = 0; i < m_TypedTargets.Length; i++)
s_StateMap.Remove(m_TypedTargets[i]);
PlanarReflectionProbeUI.Inspector.Draw(s, serialized, owner);
public override void OnInspectorGUI()
protected override void OnEnable()
var s = m_UIState;
var d = m_SerializedAsset;
var o = this;
m_SerializedHDProbe = new SerializedPlanarReflectionProbe(serializedObject);
base.OnEnable();
s.Update();
d.Update();
PlanarReflectionProbeUI.Inspector.Draw(s, d, o);
d.Apply();
PlanarReflectionProbe probe = (PlanarReflectionProbe)target;
probe.influenceVolume.Init(probe);
void OnSceneGUI()
protected override void OnSceneGUI()
for (var i = 0; i < m_TypedTargets.Length; i++)
{
m_UIHandleState[i].Update();
m_UIHandleState[i].influenceVolume.showInfluenceHandles = m_UIState.influenceVolume.isSectionExpandedShape.target;
m_UIHandleState[i].showCaptureHandles = m_UIState.isSectionExpandedCaptureSettings.target;
PlanarReflectionProbeUI.DrawHandles(m_UIHandleState[i], m_TypedTargets[i], this);
}
base.OnSceneGUI();
const float k_PreviewHeight = 128;
List<Texture> m_PreviewedTextures = new List<Texture>();
for (var i = 0; i < m_TypedTargets.Length; i++)
foreach(PlanarReflectionProbe p in m_TypedTargets)
var p = m_TypedTargets[i];
if (p.texture == null)
continue;

if (Event.current.type == EventType.Repaint)
{
var c = new Rect(cameraRect);
for (var i = 0; i < m_TypedTargets.Length; i++)
foreach(PlanarReflectionProbe p in m_TypedTargets)
var p = m_TypedTargets[i];
if (p.texture == null)
continue;

public override bool HasPreviewGUI()
{
for (var i = 0; i < m_TypedTargets.Length; i++)
foreach(PlanarReflectionProbe p in m_TypedTargets)
if (m_TypedTargets[i].texture != null)
if (p.texture != null)
return true;
}
return false;

public override void OnPreviewGUI(Rect r, GUIStyle background)
{
m_PreviewedTextures.Clear();
for (var i = 0; i < m_TypedTargets.Length; i++)
m_PreviewedTextures.Add(m_TypedTargets[i].texture);
foreach (PlanarReflectionProbe p in m_TypedTargets)
{
m_PreviewedTextures.Add(p.texture);
}
for (var i = 0; i < m_TypedTargets.Length; i++)
for (var i = 0; i < m_PreviewedTextures.Count; i++)
{
var row = i / rowSize;
var col = i % rowSize;

2
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeEditor.cs.meta


fileFormatVersion: 2
guid: 7f189b572cf7bf04d9f1976dcc75c942
guid: 01721b4a922692f4d80ef10751baa70c
MonoImporter:
externalObjects: {}
serializedVersion: 2

212
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.Handles.cs


using System;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering;
#if false
static readonly Color k_GizmoCamera = new Color(233f / 255f, 233f / 255f, 233f / 255f, 128f / 255f);
#endif
public static void DrawHandles(PlanarReflectionProbeUI s, PlanarReflectionProbe d, Editor o)
internal static void DrawHandles(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
var mat = Matrix4x4.TRS(d.transform.position, d.transform.rotation, Vector3.one);
PlanarReflectionProbe probe = d.target;
HDProbeUI.DrawHandles(s, d, o);
switch (EditMode.editMode)
if (probe.useMirrorPlane)
case EditBaseShape:
InfluenceVolumeUI.DrawHandles_EditBase(s.influenceVolume, d.influenceVolume, o, mat, d);
break;
case EditInfluenceShape:
InfluenceVolumeUI.DrawHandles_EditInfluence(s.influenceVolume, d.influenceVolume, o, mat, d);
break;
case EditInfluenceNormalShape:
InfluenceVolumeUI.DrawHandles_EditInfluenceNormal(s.influenceVolume, d.influenceVolume, o, mat, d);
break;
case EditMirrorPosition:
{
EditorGUI.BeginChangeCheck();
var m = Handles.matrix;
Handles.matrix = mat;
var p = Handles.PositionHandle(d.captureMirrorPlaneLocalPosition, d.transform.rotation);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(d, "Translate Mirror Plane");
d.captureMirrorPlaneLocalPosition = p;
EditorUtility.SetDirty(d);
}
Handles.matrix = m;
break;
}
case EditMirrorRotation:
{
EditorGUI.BeginChangeCheck();
var m = Handles.matrix;
Handles.matrix = mat;
var q = Quaternion.LookRotation(d.captureMirrorPlaneLocalNormal, Vector3.up);
q = Handles.RotationHandle(q, d.captureMirrorPlaneLocalPosition);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(d, "Rotate Mirror Plane");
d.captureMirrorPlaneLocalNormal = q * Vector3.forward;
EditorUtility.SetDirty(d);
}
Handles.matrix = m;
break;
}
case EditCenter:
var m = Handles.matrix;
var mat = Matrix4x4.TRS(probe.transform.position, probe.transform.rotation, Vector3.one*1.5f);
using (new Handles.DrawingScope(k_GizmoMirrorPlaneCamera, mat))
EditorGUI.BeginChangeCheck();
var m = Handles.matrix;
Handles.matrix = mat;
var p = Handles.PositionHandle(d.captureLocalPosition, d.transform.rotation);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(d, "Translate Capture Position");
d.captureLocalPosition = p;
EditorUtility.SetDirty(d);
}
Handles.matrix = m;
break;
Handles.ArrowHandleCap(
0,
probe.captureMirrorPlaneLocalPosition,
Quaternion.LookRotation(probe.captureMirrorPlaneLocalNormal),
HandleUtility.GetHandleSize(probe.captureMirrorPlaneLocalPosition),
Event.current.type
);
if (d.useMirrorPlane)
{
var m = Handles.matrix;
Handles.matrix = mat;
Handles.color = k_GizmoMirrorPlaneCamera;
Handles.ArrowHandleCap(
0,
d.captureMirrorPlaneLocalPosition,
Quaternion.LookRotation(d.captureMirrorPlaneLocalNormal),
HandleUtility.GetHandleSize(d.captureMirrorPlaneLocalPosition),
Event.current.type
);
Handles.matrix = m;
}
if (d.proxyVolume != null)
ReflectionProxyVolumeComponentUI.DrawHandles_EditNone(s.reflectionProxyVolume, d.proxyVolume);
public static void DrawGizmos(PlanarReflectionProbe d, GizmoType gizmoType)
internal static void DrawGizmos(PlanarReflectionProbe d, GizmoType gizmoType)
PlanarReflectionProbeUI s;
if (!PlanarReflectionProbeEditor.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(s.reflectionProxyVolume, d.proxyVolume);
HDProbeUI.DrawGizmos(d, gizmoType);
var showFrustrum = s.showCaptureHandles
|| EditMode.editMode == EditCenter;
var showCaptureMirror = d.useMirrorPlane
|| EditMode.editMode == EditMirrorPosition
|| EditMode.editMode == EditMirrorRotation;
HDProbeUI s;
if (!HDProbeEditor.TryGetUIStateFor(d, out s))
return;
if (showFrustrum)
DrawGizmos_CaptureFrustrum(s, d);
if (s.showCaptureHandles || EditMode.editMode == EditCenter)
DrawGizmos_CaptureFrustrum(d);
if (showCaptureMirror)
DrawGizmos_CaptureMirror(s, d);
if (d.useMirrorPlane)
DrawGizmos_CaptureMirror(d);
static void DrawGizmos_CaptureMirror(PlanarReflectionProbeUI s, PlanarReflectionProbe d)
static void DrawGizmos_CaptureMirror(PlanarReflectionProbe d)
{
var c = Gizmos.color;
var m = Gizmos.matrix;

Gizmos.color = c;
}
static void DrawGizmos_CaptureFrustrum(PlanarReflectionProbeUI s, PlanarReflectionProbe d)
static void DrawGizmos_CaptureFrustrum(PlanarReflectionProbe d)
{
var viewerCamera = Camera.current;
var c = Gizmos.color;

out aspect, out fov, out clearFlags, out backgroundColor,
out worldToCameraRHS, out projection,
out capturePosition, out captureRotation, viewerCamera);
#if false
// TODO: fix frustrum drawing
var viewProj = projection * worldToCameraRHS;
var invViewProj = viewProj.inverse;
var near = new[]
{
new Vector3(-1, -1, -1),
new Vector3(-1, 1, -1),
new Vector3(1, 1, -1),
new Vector3(1, -1, -1),
};
var far = new[]
{
new Vector3(-1, -1, 1),
new Vector3(-1, 1, 1),
new Vector3(1, 1, 1),
new Vector3(1, -1, 1),
};
for (var i = 0; i < near.Length; ++i)
{
var p = invViewProj * new Vector4(near[i].x, near[i].y, near[i].z, 1);
var w = Mathf.Abs(p.w);
near[i].Set(p.x / w, p.y / w, p.z / w);
}
for (var i = 0; i < far.Length; ++i)
{
var p = invViewProj * new Vector4(far[i].x, far[i].y, far[i].z, 1);
var w = Mathf.Abs(p.w);
far[i].Set(p.x / w, p.y / w, p.z / w);
}
Gizmos.color = k_GizmoCamera;
for (var i = 0; i < 4; ++i)
{
Gizmos.DrawLine(near[i], near[(i + 1) % 4]);
Gizmos.DrawLine(far[i], far[(i + 1) % 4]);
Gizmos.DrawLine(near[i], far[i]);
}
Gizmos.matrix = m;
#endif
Gizmos.DrawSphere(capturePosition, HandleUtility.GetHandleSize(capturePosition) * 0.2f);
Gizmos.color = c;

2
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.Handles.cs.meta


fileFormatVersion: 2
guid: 8ee668677cd59784d8fb06a531b49a77
guid: a5aea6d1bf1e73b4ab7307bcab55151d
MonoImporter:
externalObjects: {}
serializedVersion: 2

121
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.cs


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();
}
}

2
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.cs.meta


fileFormatVersion: 2
guid: f23cf1efede7335468bfa23bd1838cd2
guid: d6d4b9e119caf434784239e203f89e05
MonoImporter:
externalObjects: {}
serializedVersion: 2

109
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDReflectionProbe.cs


namespace UnityEditor.Experimental.Rendering.HDPipeline
{
internal class SerializedHDReflectionProbe
internal class SerializedHDReflectionProbe : SerializedHDProbe
internal ReflectionProbe target;
internal HDAdditionalReflectionData targetData;
internal SerializedObject so;
internal SerializedObject addso;
internal SerializedObject serializedLegacyObject;
internal SerializedProperty mode;
internal SerializedProperty refreshMode;
internal SerializedProperty intensityMultiplier;
internal SerializedProperty legacyBlendDistance;
internal SerializedProperty boxSize;
internal SerializedProperty boxOffset;
internal SerializedProperty resolution;
internal SerializedProperty shadowDistance;
internal SerializedProperty cullingMask;
internal SerializedProperty useOcclusionCulling;
internal SerializedProperty nearClip;
internal SerializedProperty farClip;
internal SerializedProperty boxProjection;
internal SerializedProperty weight;
internal SerializedProperty multiplier;
internal SerializedProperty proxyVolumeComponent;
SerializedProperty legacyBlendDistance;
SerializedProperty legacySize;
SerializedProperty legacyOffset;
SerializedProperty legacyMode;
internal SerializedInfluenceVolume influenceVolume;
internal new HDAdditionalReflectionData target { get { return serializedObject.targetObject as HDAdditionalReflectionData; } }
internal ReflectionProbe targetLegacy { get { return serializedLegacyObject.targetObject as ReflectionProbe; } }
public SerializedHDReflectionProbe(SerializedObject so, SerializedObject addso)
public SerializedHDReflectionProbe(SerializedObject legacyProbe, SerializedObject additionalData) : base(additionalData)
this.so = so;
this.addso = addso;
serializedLegacyObject = legacyProbe;
proxyVolumeComponent = addso.Find((HDAdditionalReflectionData d) => d.proxyVolume);
influenceVolume = new SerializedInfluenceVolume(addso.Find((HDAdditionalReflectionData d) => d.influenceVolume));
target = (ReflectionProbe)so.targetObject;
targetData = target.GetComponent<HDAdditionalReflectionData>();
mode = so.FindProperty("m_Mode");
customBakedTexture = so.FindProperty("m_CustomBakedTexture");
renderDynamicObjects = so.FindProperty("m_RenderDynamicObjects");
refreshMode = so.FindProperty("m_RefreshMode");
timeSlicingMode = so.FindProperty("m_TimeSlicingMode");
intensityMultiplier = so.FindProperty("m_IntensityMultiplier");
boxSize = so.FindProperty("m_BoxSize");
boxOffset = so.FindProperty("m_BoxOffset");
resolution = so.FindProperty("m_Resolution");
shadowDistance = so.FindProperty("m_ShadowDistance");
cullingMask = so.FindProperty("m_CullingMask");
useOcclusionCulling = so.FindProperty("m_UseOcclusionCulling");
nearClip = so.FindProperty("m_NearClip");
farClip = so.FindProperty("m_FarClip");
boxProjection = so.FindProperty("m_BoxProjection");
legacyBlendDistance = so.FindProperty("m_BlendDistance");
weight = addso.Find((HDAdditionalReflectionData d) => d.weight);
multiplier = addso.Find((HDAdditionalReflectionData d) => d.multiplier);
customBakedTexture = legacyProbe.FindProperty("m_CustomBakedTexture");
renderDynamicObjects = legacyProbe.FindProperty("m_RenderDynamicObjects");
timeSlicingMode = legacyProbe.FindProperty("m_TimeSlicingMode");
legacySize = legacyProbe.FindProperty("m_BoxSize");
legacyOffset = legacyProbe.FindProperty("m_BoxOffset");
resolution = legacyProbe.FindProperty("m_Resolution");
shadowDistance = legacyProbe.FindProperty("m_ShadowDistance");
cullingMask = legacyProbe.FindProperty("m_CullingMask");
useOcclusionCulling = legacyProbe.FindProperty("m_UseOcclusionCulling");
nearClip = legacyProbe.FindProperty("m_NearClip");
farClip = legacyProbe.FindProperty("m_FarClip");
legacyBlendDistance = legacyProbe.FindProperty("m_BlendDistance");
legacyMode = legacyProbe.FindProperty("m_Mode");
public void Update()
internal override void Update()
so.Update();
addso.Update();
//InfluenceVolume does not have Update. Add it here if it have in the futur.
serializedLegacyObject.Update();
base.Update();
//check if the transform have been rotated
if (legacyOffset.vector3Value != ((Component)serializedLegacyObject.targetObject).transform.rotation * influenceVolume.offset.vector3Value)
{
//call the offset setter as it will update legacy reflection probe
((HDAdditionalReflectionData)serializedObject.targetObject).influenceVolume.offset = influenceVolume.offset.vector3Value;
}
public void Apply()
internal override void Apply()
so.ApplyModifiedProperties();
addso.ApplyModifiedProperties();
//sync size with legacy reflection probe
switch(target.influenceVolume.shape)
{
case InfluenceShape.Box:
legacySize.vector3Value = influenceVolume.boxSize.vector3Value;
break;
case InfluenceShape.Sphere:
legacySize.vector3Value = Vector3.one * influenceVolume.sphereRadius.floatValue;
break;
}
// Sync mode with legacy reflection probe
legacyMode.intValue = mode.intValue;
serializedLegacyObject.ApplyModifiedProperties();
base.Apply();
//serializedObject.ApplyModifiedProperties(); //done in base methode
}
}
}

81
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedPlanarReflectionProbe.cs


namespace UnityEditor.Experimental.Rendering.HDPipeline
{
internal class SerializedPlanarReflectionProbe
internal class SerializedPlanarReflectionProbe : SerializedHDProbe
internal SerializedObject serializedObject;
internal SerializedProperty proxyVolumeReference;
internal SerializedReflectionProxyVolumeComponent reflectionProxyVolume;
internal SerializedInfluenceVolume influenceVolume;
internal SerializedProperty captureNearPlane;
internal SerializedProperty captureFarPlane;
internal SerializedProperty weight;
internal SerializedProperty multiplier;
internal SerializedProperty mode;
internal SerializedProperty refreshMode;
internal SerializedFrameSettings frameSettings;
internal PlanarReflectionProbe target { get { return serializedObject.targetObject as PlanarReflectionProbe; } }
internal new PlanarReflectionProbe target { get { return serializedObject.targetObject as PlanarReflectionProbe; } }
internal bool isMirrored
{

}
}
internal SerializedPlanarReflectionProbe(SerializedObject serializedObject)
internal SerializedPlanarReflectionProbe(SerializedObject serializedObject) : base(serializedObject)
this.serializedObject = serializedObject;
proxyVolumeReference = serializedObject.Find((PlanarReflectionProbe p) => p.proxyVolume);
influenceVolume = new SerializedInfluenceVolume(serializedObject.Find((PlanarReflectionProbe p) => p.influenceVolume));
captureNearPlane = serializedObject.Find((PlanarReflectionProbe p) => p.captureNearPlane);
captureFarPlane = serializedObject.Find((PlanarReflectionProbe p) => p.captureFarPlane);
nearClip = serializedObject.Find((PlanarReflectionProbe p) => p.captureNearPlane);
farClip = serializedObject.Find((PlanarReflectionProbe p) => p.captureFarPlane);
weight = serializedObject.Find((PlanarReflectionProbe p) => p.weight);
multiplier = serializedObject.Find((PlanarReflectionProbe p) => p.multiplier);
mode = serializedObject.Find((PlanarReflectionProbe p) => p.mode);
refreshMode = serializedObject.Find((PlanarReflectionProbe p) => p.refreshMode);
frameSettings = new SerializedFrameSettings(serializedObject.Find((PlanarReflectionProbe p) => p.frameSettings));
InstantiateProxyVolume(serializedObject);
influenceVolume.editorSimplifiedModeBlendNormalDistance.floatValue = 0;
void InstantiateProxyVolume(SerializedObject serializedObject)
{
var objs = new List<Object>();
for (var i = 0; i < serializedObject.targetObjects.Length; i++)
{
var p = ((PlanarReflectionProbe)serializedObject.targetObjects[i]).proxyVolume;
if (p != null)
objs.Add(p);
}
reflectionProxyVolume = objs.Count > 0
? new SerializedReflectionProxyVolumeComponent(new SerializedObject(objs.ToArray()))
: null;
}
public void Update()
internal override void Update()
serializedObject.Update();
base.Update();
//temporarily force value until other mode are supported
var updateProxyVolume = reflectionProxyVolume != null
&& serializedObject.targetObjects.Length != reflectionProxyVolume.serializedObject.targetObjects.Length;
if (!updateProxyVolume && reflectionProxyVolume != null)
{
var proxyVolumeTargets = reflectionProxyVolume.serializedObject.targetObjects;
for (var i = 0; i < serializedObject.targetObjects.Length; i++)
{
if (proxyVolumeTargets[i] != ((PlanarReflectionProbe)serializedObject.targetObjects[i]).proxyVolume)
{
updateProxyVolume = true;
break;
}
}
}
if (updateProxyVolume)
InstantiateProxyVolume(serializedObject);
public void Apply()
{
serializedObject.ApplyModifiedProperties();
if (reflectionProxyVolume != null)
reflectionProxyVolume.Apply();
}
}
}

163
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Drawers.cs


partial class InfluenceVolumeUI
{
//[TODO: planar / non planar will be redone in next PR]
public static readonly CED.IDrawer SectionFoldoutShapePlanar;
public static readonly CED.IDrawer SectionFoldoutShape;
public static readonly CED.IDrawer SectionShapeBoxPlanar = CED.Action((s, p, o) => Drawer_SectionShapeBox(s,p,o,false,false));
public static readonly CED.IDrawer SectionShapeBox = CED.Action((s, p, o) => Drawer_SectionShapeBox(s, p, o, true, true));
public static readonly CED.IDrawer SectionShapeSpherePlanar = CED.Action((s, p, o) => Drawer_SectionShapeSphere(s, p, o, false, false));
public static readonly CED.IDrawer SectionShapeSphere = CED.Action((s, p, o) => Drawer_SectionShapeSphere(s, p, o, true, true));
internal static readonly CED.IDrawer SectionFoldoutShapePlanar;
internal static readonly CED.IDrawer SectionFoldoutShape;
static readonly CED.IDrawer SectionShapeBoxPlanar = CED.Action((s, p, o) => Drawer_SectionShapeBox( s, p, o, false, false, false));
static readonly CED.IDrawer SectionShapeBox = CED.Action((s, p, o) => Drawer_SectionShapeBox(s, p, o, true, true, true));
static readonly CED.IDrawer SectionShapeSpherePlanar = CED.Action((s, p, o) => Drawer_SectionShapeSphere(s, p, o, false, false));
static readonly CED.IDrawer SectionShapeSphere = CED.Action((s, p, o) => Drawer_SectionShapeSphere(s, p, o, true, true));
"Influence Volume",
influenceVolumeHeader,
(s, d, o) => s.isSectionExpandedShape,
FoldoutOption.Indent,
CED.Action(Drawer_InfluenceAdvancedSwitch),

);
SectionFoldoutShape = CED.Group(
CED.FoldoutGroup(
"Influence Volume",
influenceVolumeHeader,
(s, d, o) => s.isSectionExpandedShape,
FoldoutOption.Indent,
CED.Action(Drawer_InfluenceAdvancedSwitch),

static void Drawer_FieldShapeType(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o)
{
EditorGUILayout.PropertyField(d.shape, _.GetContent("Shape Type"));
EditorGUILayout.PropertyField(d.shape, shapeContent);
}
static void Drawer_InfluenceAdvancedSwitch(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor owner)

GUILayout.FlexibleSpace();
if (d.shape.intValue == (int)InfluenceShape.Sphere)
{
GUI.enabled = false;
}
advanced = !GUILayout.Toggle(!advanced, CoreEditorUtils.GetContent("Normal|Normal parameters mode (only change for box shape)."), EditorStyles.miniButtonLeft, GUILayout.Width(60f), GUILayout.ExpandWidth(false));
advanced = GUILayout.Toggle(advanced, CoreEditorUtils.GetContent("Advanced|Advanced parameters mode (only change for box shape)."), EditorStyles.miniButtonRight, GUILayout.Width(60f), GUILayout.ExpandWidth(false));
advanced = !GUILayout.Toggle(!advanced, normalModeContent, EditorStyles.miniButtonLeft, GUILayout.Width(60f), GUILayout.ExpandWidth(false));
advanced = GUILayout.Toggle(advanced, advancedModeContent, EditorStyles.miniButtonRight, GUILayout.Width(60f), GUILayout.ExpandWidth(false));
s.boxInfluenceHandle.allHandleControledByOne = s.boxInfluenceNormalHandle.allHandleControledByOne = !advanced;
if (d.editorAdvancedModeEnabled.boolValue ^ advanced)
{

d.boxBlendDistanceNegative.vector3Value = d.editorAdvancedModeBlendDistanceNegative.vector3Value;
d.boxBlendNormalDistancePositive.vector3Value = d.editorAdvancedModeBlendNormalDistancePositive.vector3Value;
d.boxBlendNormalDistanceNegative.vector3Value = d.editorAdvancedModeBlendNormalDistanceNegative.vector3Value;
d.boxSideFadePositive.vector3Value = d.editorAdvancedModeFaceFadePositive.vector3Value;
d.boxSideFadeNegative.vector3Value = d.editorAdvancedModeFaceFadeNegative.vector3Value;
d.boxSideFadeNegative.vector3Value = d.boxSideFadePositive.vector3Value = Vector3.one;
if (d.shape.intValue == (int)InfluenceShape.Sphere)
{
GUI.enabled = true;
}
static void Drawer_SectionShapeBox(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, bool drawOffset, bool drawNormal)
static void Drawer_SectionShapeBox(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, bool drawOffset, bool drawNormal, bool drawFace)
{
bool advanced = d.editorAdvancedModeEnabled.boolValue;
var maxFadeDistance = d.boxSize.vector3Value * 0.5f;

EditorGUILayout.PropertyField(d.boxSize, _.GetContent("Box Size"));
PlanarReflectionProbeUI.Drawer_ToolBarButton(0, o, GUILayout.Width(28f), GUILayout.MinHeight(22f));
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(d.boxSize, boxSizeContent);
if (EditorGUI.EndChangeCheck())
{
Vector3 blendPositive = d.boxBlendDistancePositive.vector3Value;
Vector3 blendNegative = d.boxBlendDistanceNegative.vector3Value;
Vector3 blendNormalPositive = d.boxBlendNormalDistancePositive.vector3Value;
Vector3 blendNormalNegative = d.boxBlendNormalDistanceNegative.vector3Value;
Vector3 size = d.boxSize.vector3Value;
for(int i = 0; i<3; ++i)
{
size[i] = Mathf.Max(0f, size[i]);
}
d.boxSize.vector3Value = size;
Vector3 halfSize = size * .5f;
for (int i = 0; i < 3; ++i)
{
blendPositive[i] = Mathf.Clamp(blendPositive[i], 0f, halfSize[i]);
blendNegative[i] = Mathf.Clamp(blendNegative[i], 0f, halfSize[i]);
blendNormalPositive[i] = Mathf.Clamp(blendNormalPositive[i], 0f, halfSize[i]);
blendNormalNegative[i] = Mathf.Clamp(blendNormalNegative[i], 0f, halfSize[i]);
}
d.boxBlendDistancePositive.vector3Value = blendPositive;
d.boxBlendDistanceNegative.vector3Value = blendNegative;
d.boxBlendNormalDistancePositive.vector3Value = blendNormalPositive;
d.boxBlendNormalDistanceNegative.vector3Value = blendNormalNegative;
if (d.editorAdvancedModeEnabled.boolValue)
{
d.editorAdvancedModeBlendDistancePositive.vector3Value = d.boxBlendDistancePositive.vector3Value;
d.editorAdvancedModeBlendDistanceNegative.vector3Value = d.boxBlendDistanceNegative.vector3Value;
d.editorAdvancedModeBlendNormalDistancePositive.vector3Value = d.boxBlendNormalDistancePositive.vector3Value;
d.editorAdvancedModeBlendNormalDistanceNegative.vector3Value = d.boxBlendNormalDistanceNegative.vector3Value;
}
else
{
d.editorSimplifiedModeBlendDistance.floatValue = Mathf.Max(blendPositive.x, blendPositive.y, blendPositive.z, blendNegative.x, blendNegative.y, blendNegative.z);
d.boxBlendDistancePositive.vector3Value = d.boxBlendDistanceNegative.vector3Value = Vector3.one * d.editorSimplifiedModeBlendDistance.floatValue;
d.editorSimplifiedModeBlendNormalDistance.floatValue = Mathf.Max(blendNormalPositive.x, blendNormalPositive.y, blendNormalPositive.z, blendNormalNegative.x, blendNormalNegative.y, blendNormalNegative.z);
d.boxBlendNormalDistancePositive.vector3Value = d.boxBlendNormalDistanceNegative.vector3Value = Vector3.one * d.editorSimplifiedModeBlendNormalDistance.floatValue;
}
}
HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.InfluenceShape, o, GUILayout.Width(28f), GUILayout.MinHeight(22f));
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(d.offset, _.GetContent("Offset"));
HDReflectionProbeUI.Drawer_ToolBarButton(3, o, GUILayout.Width(28f), GUILayout.MinHeight(22f));
EditorGUILayout.EndHorizontal();
Drawer_Offset(s, d, o);
GUILayout.Space(EditorGUIUtility.standardVerticalSpacing);
Drawer_AdvancedBlendDistance(
d,
false,
maxFadeDistance,
CoreEditorUtils.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes.")
);
PlanarReflectionProbeUI.Drawer_ToolBarButton(1, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight((advanced ? 3 : 1) * (EditorGUIUtility.singleLineHeight + 3)));
Drawer_AdvancedBlendDistance(d, false, maxFadeDistance, blendDistanceContent);
HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.Blend, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight((advanced ? 2 : 1) * (EditorGUIUtility.singleLineHeight + 3)));
GUILayout.Space(EditorGUIUtility.standardVerticalSpacing * 2f);
Drawer_AdvancedBlendDistance(
d,
true,
maxFadeDistance,
CoreEditorUtils.GetContent("Blend Normal Distance|Area around the probe where the normals influence the probe. Only used in deferred probes.")
);
PlanarReflectionProbeUI.Drawer_ToolBarButton(2, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight((advanced ? 3 : 1) * (EditorGUIUtility.singleLineHeight + 3)));
Drawer_AdvancedBlendDistance(d, true, maxFadeDistance, blendNormalDistanceContent);
HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.NormalBlend, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight((advanced ? 2 : 1) * (EditorGUIUtility.singleLineHeight + 3)));
GUILayout.Space(EditorGUIUtility.standardVerticalSpacing * 2f);
if (advanced)
if (advanced && drawFace)
CoreEditorUtils.DrawVector6(
CoreEditorUtils.GetContent("Face fade|Fade faces of the cubemap."),
d.boxSideFadePositive, d.boxSideFadeNegative, Vector3.zero, Vector3.one, HDReflectionProbeEditor.k_handlesColor);
EditorGUILayout.BeginHorizontal();
EditorGUI.BeginChangeCheck();
CoreEditorUtils.DrawVector6(faceFadeContent, d.editorAdvancedModeFaceFadePositive, d.editorAdvancedModeFaceFadeNegative, Vector3.zero, Vector3.one, HDReflectionProbeEditor.k_handlesColor);
if (EditorGUI.EndChangeCheck())
{
d.boxSideFadePositive.vector3Value = d.editorAdvancedModeFaceFadePositive.vector3Value;
d.boxSideFadeNegative.vector3Value = d.editorAdvancedModeFaceFadeNegative.vector3Value;
}
GUILayout.Space(28f + 9f); //add right margin for alignment
EditorGUILayout.EndHorizontal();
GUILayout.Space(EditorGUIUtility.standardVerticalSpacing * 2f);
}
}

distance = EditorGUILayout.FloatField(content, distance);
if (EditorGUI.EndChangeCheck())
{
distance = Mathf.Clamp(distance, 0f, Mathf.Max(maxBlendDistance.x, maxBlendDistance.y, maxBlendDistance.z));
Vector3 decal = Vector3.one * distance;
bdp.x = Mathf.Clamp(decal.x, 0f, maxBlendDistance.x);
bdp.y = Mathf.Clamp(decal.y, 0f, maxBlendDistance.y);

{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(d.sphereRadius, _.GetContent("Radius"));
PlanarReflectionProbeUI.Drawer_ToolBarButton(0, o, GUILayout.Width(28f), GUILayout.MinHeight(22f));
EditorGUILayout.PropertyField(d.sphereRadius, radiusContent);
HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.InfluenceShape, o, GUILayout.Width(28f), GUILayout.MinHeight(22f));
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(d.offset, _.GetContent("Offset"));
HDReflectionProbeUI.Drawer_ToolBarButton(3, o, GUILayout.Width(28f), GUILayout.MinHeight(22f));
EditorGUILayout.EndHorizontal();
Drawer_Offset(s, d, o);
}
EditorGUILayout.Space();

EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(d.sphereBlendDistance, _.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes."));
EditorGUILayout.PropertyField(d.sphereBlendDistance, blendDistanceContent);
PlanarReflectionProbeUI.Drawer_ToolBarButton(1, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight + 3));
HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.Blend, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight + 3));
EditorGUILayout.EndHorizontal();
if (drawNormal)

EditorGUILayout.PropertyField(d.sphereBlendNormalDistance, _.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes."));
EditorGUILayout.PropertyField(d.sphereBlendNormalDistance, blendNormalDistanceContent);
PlanarReflectionProbeUI.Drawer_ToolBarButton(2, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight + 3));
HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.NormalBlend, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight + 3));
}
static void Drawer_Offset(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o)
{
EditorGUILayout.BeginHorizontal();
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(d.offset, offsetContent);
if(EditorGUI.EndChangeCheck())
{
//call the offset setter as it will update legacy reflection probe
HDProbeEditor editor = (HDProbeEditor)o;
InfluenceVolume influenceVolume = editor.GetTarget(editor.target).influenceVolume;
influenceVolume.offset = d.offset.vector3Value;
}
HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.CapturePosition, o, GUILayout.Width(28f), GUILayout.MinHeight(22f));
EditorGUILayout.EndHorizontal();
}
}
}

311
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Handles.cs


{
partial class InfluenceVolumeUI
{
public static void DrawHandles_EditBase(InfluenceVolumeUI s, InfluenceVolume d, Editor o, Matrix4x4 matrix, Object sourceAsset)
public static void DrawHandles_EditBase(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, Matrix4x4 matrix, Object sourceAsset)
var mat = Handles.matrix;
var c = Handles.color;
Handles.matrix = matrix;
Handles.color = k_GizmoThemeColorBase;
switch (d.shape)
using (new Handles.DrawingScope(k_GizmoThemeColorBase, matrix))
case InfluenceShape.Box:
{
var center = d.offset;
var size = d.boxSize;
DrawBoxHandle(
s, d, o, sourceAsset,
s1 => s1.boxBaseHandle,
ref center,
ref size);
d.offset = center;
d.boxSize = size;
switch ((InfluenceShape)d.shape.intValue)
{
case InfluenceShape.Box:
DrawBoxHandle(s, d, o, sourceAsset, s.boxBaseHandle);
}
case InfluenceShape.Sphere:
{
var center = d.offset;
var radius = d.sphereRadius;
DrawSphereHandle(
s, d, o, sourceAsset,
s1 => s1.sphereBaseHandle,
ref center,
ref radius);
d.offset = center;
d.sphereRadius = radius;
case InfluenceShape.Sphere:
DrawSphereHandle(s, d, o, sourceAsset, s.sphereBaseHandle);
}
}
Handles.matrix = mat;
Handles.color = c;
public static void DrawHandles_EditInfluence(InfluenceVolumeUI s, InfluenceVolume d, Editor o, Matrix4x4 matrix, Object sourceAsset)
public static void DrawHandles_EditInfluence(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, Matrix4x4 matrix, Object sourceAsset)
var mat = Handles.matrix;
var c = Handles.color;
Handles.matrix = matrix;
Handles.color = k_GizmoThemeColorInfluence;
switch (d.shape)
using (new Handles.DrawingScope(k_GizmoThemeColorInfluence, matrix))
case InfluenceShape.Box:
{
var positive = d.boxBlendDistancePositive;
var negative = d.boxBlendDistanceNegative;
DrawBoxFadeHandle(
s, d, o, sourceAsset,
s1 => s1.boxInfluenceHandle,
d.offset, d.boxSize,
ref positive,
ref negative);
s.data.boxBlendDistancePositive.vector3Value = positive;
s.data.boxBlendDistanceNegative.vector3Value = negative;
//save advanced/simplified saved data
if (s.data.editorAdvancedModeEnabled.boolValue)
switch ((InfluenceShape)d.shape.intValue)
{
case InfluenceShape.Box:
EditorGUI.BeginChangeCheck();
DrawBoxFadeHandle(s, d, o, sourceAsset, s.boxInfluenceHandle, d.boxBlendDistancePositive, d.boxBlendDistanceNegative);
if (EditorGUI.EndChangeCheck())
s.data.editorAdvancedModeBlendDistancePositive.vector3Value = positive;
s.data.editorAdvancedModeBlendDistanceNegative.vector3Value = negative;
}
else
{
s.data.editorSimplifiedModeBlendDistance.floatValue = positive.x;
//save advanced/simplified saved data
if (d.editorAdvancedModeEnabled.boolValue)
{
d.editorAdvancedModeBlendDistancePositive.vector3Value = d.boxBlendDistancePositive.vector3Value;
d.editorAdvancedModeBlendDistanceNegative.vector3Value = d.boxBlendDistanceNegative.vector3Value;
}
else
{
d.editorSimplifiedModeBlendDistance.floatValue = d.boxBlendDistancePositive.vector3Value.x;
}
d.Apply();
s.data.Apply();
}
case InfluenceShape.Sphere:
{
var fade = d.sphereBlendDistance;
DrawSphereFadeHandle(
s, d, o, sourceAsset,
s1 => s1.sphereInfluenceHandle,
d.offset, d.sphereRadius,
ref fade);
d.sphereBlendDistance = fade;
case InfluenceShape.Sphere:
DrawSphereFadeHandle(s, d, o, sourceAsset, s.sphereInfluenceHandle, d.sphereBlendDistance);
}
}
Handles.matrix = mat;
Handles.color = c;
public static void DrawHandles_EditInfluenceNormal(InfluenceVolumeUI s, InfluenceVolume d, Editor o, Matrix4x4 matrix, Object sourceAsset)
public static void DrawHandles_EditInfluenceNormal(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, Matrix4x4 matrix, Object sourceAsset)
var mat = Handles.matrix;
var c = Handles.color;
Handles.matrix = matrix;
Handles.color = k_GizmoThemeColorInfluenceNormal;
switch (d.shape)
using (new Handles.DrawingScope(k_GizmoThemeColorInfluenceNormal, matrix))
case InfluenceShape.Box:
{
Vector3 positive = d.boxBlendNormalDistancePositive;
Vector3 negative = d.boxBlendNormalDistanceNegative;
DrawBoxFadeHandle(
s, d, o, sourceAsset,
s1 => s1.boxInfluenceNormalHandle,
d.offset, d.boxSize,
ref positive,
ref negative);
s.data.boxBlendNormalDistancePositive.vector3Value = positive;
s.data.boxBlendNormalDistanceNegative.vector3Value = negative;
//save advanced/simplified saved data
if (s.data.editorAdvancedModeEnabled.boolValue)
switch ((InfluenceShape)d.shape.intValue)
{
case InfluenceShape.Box:
EditorGUI.BeginChangeCheck();
DrawBoxFadeHandle(s, d, o, sourceAsset, s.boxInfluenceNormalHandle, d.boxBlendNormalDistancePositive, d.boxBlendNormalDistanceNegative);
if (EditorGUI.EndChangeCheck())
s.data.editorAdvancedModeBlendNormalDistancePositive.vector3Value = positive;
s.data.editorAdvancedModeBlendNormalDistanceNegative.vector3Value = negative;
//save advanced/simplified saved data
if (d.editorAdvancedModeEnabled.boolValue)
{
d.editorAdvancedModeBlendNormalDistancePositive.vector3Value = d.boxBlendNormalDistancePositive.vector3Value;
d.editorAdvancedModeBlendNormalDistanceNegative.vector3Value = d.boxBlendNormalDistanceNegative.vector3Value;
}
else
{
d.editorSimplifiedModeBlendNormalDistance.floatValue = d.boxBlendNormalDistancePositive.vector3Value.x;
}
d.Apply();
else
{
s.data.editorSimplifiedModeBlendNormalDistance.floatValue = positive.x;
}
s.data.Apply();
}
case InfluenceShape.Sphere:
{
var fade = d.sphereBlendNormalDistance;
DrawSphereFadeHandle(
s, d, o, sourceAsset,
s1 => s1.sphereInfluenceNormalHandle,
d.offset, d.sphereRadius,
ref fade);
d.sphereBlendNormalDistance = fade;
case InfluenceShape.Sphere:
DrawSphereFadeHandle(s, d, o, sourceAsset, s.sphereInfluenceNormalHandle, d.sphereBlendNormalDistance);
}
}
Handles.matrix = mat;
Handles.color = c;
static void DrawBoxHandle(
InfluenceVolumeUI s, InfluenceVolume d, Editor o, Object sourceAsset,
Func<InfluenceVolumeUI, Gizmo6FacesBox> boundsGetter,
ref Vector3 center, ref Vector3 size)
static void DrawBoxHandle(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, Object sourceAsset, Gizmo6FacesBox box)
var b = boundsGetter(s);
b.center = center;
b.size = size;
box.center = d.offset.vector3Value;
box.size = d.boxSize.vector3Value;
b.DrawHandle();
box.DrawHandle();
center = b.center;
size = b.size;
d.offset.vector3Value = box.center;
var size = box.size;
Vector3 blendPositive = d.boxBlendDistancePositive.vector3Value;
Vector3 blendNegative = d.boxBlendDistanceNegative.vector3Value;
Vector3 blendNormalPositive = d.boxBlendNormalDistancePositive.vector3Value;
Vector3 blendNormalNegative = d.boxBlendNormalDistanceNegative.vector3Value;
for (int i = 0; i < 3; ++i)
{
size[i] = Mathf.Max(0f, size[i]);
}
d.boxSize.vector3Value = size;
Vector3 halfSize = size * .5f;
for (int i = 0; i < 3; ++i)
{
blendPositive[i] = Mathf.Clamp(blendPositive[i], 0f, halfSize[i]);
blendNegative[i] = Mathf.Clamp(blendNegative[i], 0f, halfSize[i]);
blendNormalPositive[i] = Mathf.Clamp(blendNormalPositive[i], 0f, halfSize[i]);
blendNormalNegative[i] = Mathf.Clamp(blendNormalNegative[i], 0f, halfSize[i]);
}
d.boxBlendDistancePositive.vector3Value = blendPositive;
d.boxBlendDistanceNegative.vector3Value = blendNegative;
d.boxBlendNormalDistancePositive.vector3Value = blendNormalPositive;
d.boxBlendNormalDistanceNegative.vector3Value = blendNormalNegative;
EditorUtility.SetDirty(sourceAsset);
if (d.editorAdvancedModeEnabled.boolValue)
{
d.editorAdvancedModeBlendDistancePositive.vector3Value = d.boxBlendDistancePositive.vector3Value;
d.editorAdvancedModeBlendDistanceNegative.vector3Value = d.boxBlendDistanceNegative.vector3Value;
d.editorAdvancedModeBlendNormalDistancePositive.vector3Value = d.boxBlendNormalDistancePositive.vector3Value;
d.editorAdvancedModeBlendNormalDistanceNegative.vector3Value = d.boxBlendNormalDistanceNegative.vector3Value;
}
else
{
d.editorSimplifiedModeBlendDistance.floatValue = Mathf.Min(
d.boxBlendDistancePositive.vector3Value.x,
d.boxBlendDistancePositive.vector3Value.y,
d.boxBlendDistancePositive.vector3Value.z,
d.boxBlendDistanceNegative.vector3Value.x,
d.boxBlendDistanceNegative.vector3Value.y,
d.boxBlendDistanceNegative.vector3Value.z);
d.boxBlendDistancePositive.vector3Value = d.boxBlendDistanceNegative.vector3Value = Vector3.one * d.editorSimplifiedModeBlendDistance.floatValue;
d.editorSimplifiedModeBlendNormalDistance.floatValue = Mathf.Min(
d.boxBlendNormalDistancePositive.vector3Value.x,
d.boxBlendNormalDistancePositive.vector3Value.y,
d.boxBlendNormalDistancePositive.vector3Value.z,
d.boxBlendNormalDistanceNegative.vector3Value.x,
d.boxBlendNormalDistanceNegative.vector3Value.y,
d.boxBlendNormalDistanceNegative.vector3Value.z);
d.boxBlendNormalDistancePositive.vector3Value = d.boxBlendNormalDistanceNegative.vector3Value = Vector3.one * d.editorSimplifiedModeBlendNormalDistance.floatValue;
}
d.Apply();
static void DrawBoxFadeHandle(
InfluenceVolumeUI s, InfluenceVolume d, Editor o, Object sourceAsset,
Func<InfluenceVolumeUI, Gizmo6FacesBox> boundsGetter,
Vector3 baseOffset, Vector3 baseSize,
ref Vector3 positive, ref Vector3 negative)
static void DrawBoxFadeHandle(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, Object sourceAsset, Gizmo6FacesBox box, SerializedProperty positive, SerializedProperty negative)
var b = boundsGetter(s);
b.center = baseOffset - (positive - negative) * 0.5f;
b.size = baseSize - positive - negative;
b.allHandleControledByOne = !s.data.editorAdvancedModeEnabled.boolValue;
box.center = d.offset.vector3Value - (positive.vector3Value - negative.vector3Value) * 0.5f;
box.size = d.boxSize.vector3Value - positive.vector3Value - negative.vector3Value;
box.allHandleControledByOne = !d.editorAdvancedModeEnabled.boolValue;
b.DrawHandle();
box.DrawHandle();
var center = baseOffset;
var influenceSize = baseSize;
var influenceCenter = d.offset.vector3Value;
var halfInfluenceSize = d.boxSize.vector3Value * .5f;
var diff = 2 * (b.center - center);
var sum = influenceSize - b.size;
var positiveNew = (sum - diff) * 0.5f;
var negativeNew = (sum + diff) * 0.5f;
var blendDistancePositive = Vector3.Max(Vector3.zero, Vector3.Min(positiveNew, influenceSize));
var blendDistanceNegative = Vector3.Max(Vector3.zero, Vector3.Min(negativeNew, influenceSize));
var centerDiff = box.center - influenceCenter;
var halfSizeDiff = halfInfluenceSize - box.size * .5f;
var positiveNew = halfSizeDiff - centerDiff;
var negativeNew = halfSizeDiff + centerDiff;
var blendDistancePositive = Vector3.Max(Vector3.zero, Vector3.Min(positiveNew, halfInfluenceSize));
var blendDistanceNegative = Vector3.Max(Vector3.zero, Vector3.Min(negativeNew, halfInfluenceSize));
positive = blendDistancePositive;
negative = blendDistanceNegative;
positive.vector3Value = blendDistancePositive;
negative.vector3Value = blendDistanceNegative;
EditorUtility.SetDirty(sourceAsset);
d.Apply();
static void DrawSphereHandle(
InfluenceVolumeUI s, InfluenceVolume d, Editor o, Object sourceAsset,
Func<InfluenceVolumeUI, SphereBoundsHandle> boundsGetter,
ref Vector3 center, ref float radius)
static void DrawSphereHandle(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, Object sourceAsset, SphereBoundsHandle sphere)
var b = boundsGetter(s);
b.center = center;
b.radius = radius;
sphere.center = d.offset.vector3Value;
sphere.radius = d.sphereRadius.floatValue;
b.DrawHandle();
sphere.DrawHandle();
radius = b.radius;
EditorUtility.SetDirty(sourceAsset);
float radius = sphere.radius;
d.sphereRadius.floatValue = radius;
d.sphereBlendDistance.floatValue = Mathf.Clamp(s.data.sphereBlendDistance.floatValue, 0, radius);
d.sphereBlendNormalDistance.floatValue = Mathf.Clamp(s.data.sphereBlendNormalDistance.floatValue, 0, radius);
d.Apply();
static void DrawSphereFadeHandle(
InfluenceVolumeUI s, InfluenceVolume d, Editor o, Object sourceAsset,
Func<InfluenceVolumeUI, SphereBoundsHandle> boundsGetter,
Vector3 baseOffset, float baseRadius,
ref float radius)
static void DrawSphereFadeHandle(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, Object sourceAsset, SphereBoundsHandle sphere, SerializedProperty radius)
var b = boundsGetter(s);
b.center = baseOffset;
b.radius = Mathf.Clamp(baseRadius - radius, 0, baseRadius);
sphere.center = d.offset.vector3Value;
sphere.radius = radius.floatValue;
b.DrawHandle();
sphere.DrawHandle();
radius = Mathf.Clamp(baseRadius - b.radius, 0, baseRadius);
EditorUtility.SetDirty(sourceAsset);
radius.floatValue = Mathf.Clamp(d.sphereRadius.floatValue - sphere.radius, 0, d.sphereRadius.floatValue);
d.Apply();
}
}
}

20
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.cs


partial class InfluenceVolumeUI : BaseUI<SerializedInfluenceVolume>
{
const int k_AnimBoolFields = 2;
internal static readonly Color k_GizmoThemeColorBase = new Color(255f / 255f, 229f / 255f, 148f / 255f, 80f / 255f);
internal static readonly Color k_GizmoThemeColorBaseFace = new Color(255f / 255f, 229f / 255f, 148f / 255f, 45f / 255f);
internal static readonly Color k_GizmoThemeColorInfluence = new Color(83f / 255f, 255f / 255f, 95f / 255f, 75f / 255f);
internal static readonly Color k_GizmoThemeColorInfluenceFace = new Color(83f / 255f, 255f / 255f, 95f / 255f, 17f / 255f);
internal static readonly Color k_GizmoThemeColorInfluenceNormal = new Color(0f / 255f, 229f / 255f, 255f / 255f, 80f / 255f);
internal static readonly Color k_GizmoThemeColorInfluenceNormalFace = new Color(0f / 255f, 229f / 255f, 255f / 255f, 36f / 255f);
internal static readonly Color k_GizmoThemeColorProjection = new Color(0x00 / 255f, 0xE5 / 255f, 0xFF / 255f, 0x20 / 255f);
internal static readonly Color k_GizmoThemeColorProjectionFace = new Color(0x00 / 255f, 0xE5 / 255f, 0xFF / 255f, 0x20 / 255f);
internal static readonly Color k_GizmoThemeColorDisabled = new Color(0x99 / 255f, 0x89 / 255f, 0x59 / 255f, 0x10 / 255f);
internal static readonly Color k_GizmoThemeColorDisabledFace = new Color(0x99 / 255f, 0x89 / 255f, 0x59 / 255f, 0x10 / 255f);
static readonly int k_ShapeCount = Enum.GetValues(typeof(InfluenceShape)).Length;
public Gizmo6FacesBox boxBaseHandle;

boxInfluenceNormalHandle.faceColorsSelected = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorInfluenceNormalBlendFace };
}
public override void Update()
public void SetIsSectionExpanded_Shape(InfluenceShape shape)
base.Update();
SetIsSectionExpanded_Shape((InfluenceShape)data.shape.intValue);
SetIsSectionExpanded_Shape((int)shape);
void SetIsSectionExpanded_Shape(InfluenceShape shape)
public void SetIsSectionExpanded_Shape(int shape)
m_AnimBools[i].target = (int)shape == i;
m_AnimBools[i].target = shape == i;
}
public AnimBool IsSectionExpanded_Shape(InfluenceShape shapeType)

135
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/ProxyVolumeUI.cs


namespace UnityEditor.Experimental.Rendering.HDPipeline
{
using _ = CoreEditorUtils;
//Skin
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);
//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);
internal static GUIContent shapeContent = CoreEditorUtils.GetContent("Shape|The shape of the Proxy.\nInfinite is compatible with any kind of InfluenceShape.");
internal static GUIContent boxSizeContent = CoreEditorUtils.GetContent("Box Size|The size of the box.");
internal static GUIContent sphereRadiusContent = CoreEditorUtils.GetContent("Sphere Radius|The radius of the sphere.");
//logic
public static readonly CED.IDrawer SectionShapeBox = CED.Action(Drawer_SectionShapeBox);
public static readonly CED.IDrawer SectionShapeSphere = CED.Action(Drawer_SectionShapeSphere);

);
}
public BoxBoundsHandle boxProjectionHandle = new BoxBoundsHandle();
public SphereBoundsHandle sphereProjectionHandle = new SphereBoundsHandle();
public ProxyVolumeUI()
: base(k_ShapeCount)
{

return m_AnimBools[(int)shapeType];
}
//gizmo
public static void DrawGizmos(Transform transform, ProxyVolume proxyVolume)
{
switch (proxyVolume.shape)
{
case ProxyShape.Box:
Gizmos_Box(transform, proxyVolume);
break;
case ProxyShape.Sphere:
Gizmos_Sphere(transform, proxyVolume);
break;
}
}
static void Gizmos_Sphere(Transform t, ProxyVolume d)
{
var mat = Gizmos.matrix;
Color col = Gizmos.color;
Gizmos.matrix = Matrix4x4.TRS(t.position, t.rotation, Vector3.one);
Gizmos.color = k_GizmoThemeColorProjection;
Gizmos.DrawWireSphere(Vector3.zero, d.sphereRadius);
Gizmos.color = col;
Gizmos.matrix = mat;
}
static void Gizmos_Box(Transform t, ProxyVolume d)
{
var mat = Gizmos.matrix;
Color col = Gizmos.color;
Gizmos.matrix = Matrix4x4.TRS(t.position, t.rotation, Vector3.one);
Gizmos.color = k_GizmoThemeColorProjection;
Gizmos.DrawWireCube(Vector3.zero, d.boxSize);
Gizmos.color = col;
Gizmos.matrix = mat;
}
//handles
public BoxBoundsHandle boxProjectionHandle = new BoxBoundsHandle();
public SphereBoundsHandle sphereProjectionHandle = new SphereBoundsHandle();
EditorGUILayout.PropertyField(d.shape, _.GetContent("Shape Type"));
EditorGUILayout.PropertyField(d.shape, shapeContent);
EditorGUILayout.PropertyField(d.boxSize, _.GetContent("Box Size"));
EditorGUILayout.PropertyField(d.boxSize, boxSizeContent);
EditorGUILayout.PropertyField(d.sphereRadius, _.GetContent("Sphere Radius"));
EditorGUILayout.PropertyField(d.sphereRadius, sphereRadiusContent);
}
public static void DrawHandles_EditBase(Transform transform, ProxyVolume proxyVolume, ProxyVolumeUI ui, Object sourceAsset)

}
}
public static void DrawHandles_EditNone(Transform transform, ProxyVolume proxyVolume, ProxyVolumeUI ui, Object sourceAsset)
{
}
Matrix4x4 mat = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
var mat = Handles.matrix;
Handles.matrix = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
Handles.color = k_GizmoThemeColorProjection;
s.sphereProjectionHandle.DrawHandle();
using (new Handles.DrawingScope(k_GizmoThemeColorProjection, mat))
{
s.sphereProjectionHandle.DrawHandle();
}
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(sourceAsset, "Modified Projection Volume");

//the gizmo is not an object of the scene. Flag it as dirty
Handles.matrix = mat;
}
static void Handles_EditBase_Box(Transform transform, ProxyVolume proxyVolume, ProxyVolumeUI s, Object sourceAsset)

var mat = Handles.matrix;
Handles.matrix = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
Matrix4x4 mat = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
Handles.color = k_GizmoThemeColorProjection;
s.boxProjectionHandle.DrawHandle();
using (new Handles.DrawingScope(k_GizmoThemeColorProjection, mat))
{
s.boxProjectionHandle.DrawHandle();
}
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(sourceAsset, "Modified Projection Volume AABB");

//the gizmo is not an object of the scene. Flag it as dirty
Handles.matrix = mat;
}
public static void DrawGizmos_EditNone(Transform transform, ProxyVolume proxyVolume, ProxyVolumeUI ui, Object sourceAsset)
{
switch (proxyVolume.shape)
{
case ProxyShape.Box:
Gizmos_EditNone_Box(transform, proxyVolume, ui, sourceAsset);
break;
case ProxyShape.Sphere:
Gizmos_EditNone_Sphere(transform, proxyVolume, ui, sourceAsset);
break;
}
}
static void Gizmos_EditNone_Sphere(Transform t, ProxyVolume d, ProxyVolumeUI s, Object o)
{
var mat = Gizmos.matrix;
Gizmos.matrix = Matrix4x4.TRS(t.position, t.rotation, Vector3.one);
Gizmos.color = k_GizmoThemeColorProjection;
Gizmos.DrawWireSphere(Vector3.zero, d.sphereRadius);
Gizmos.matrix = mat;
}
static void Gizmos_EditNone_Box(Transform t, ProxyVolume d, ProxyVolumeUI s, Object o)
{
var mat = Gizmos.matrix;
Gizmos.matrix = Matrix4x4.TRS(t.position, t.rotation, Vector3.one);
Gizmos.color = k_GizmoThemeColorProjection;
Gizmos.DrawWireCube(Vector3.zero, d.boxSize);
Gizmos.matrix = mat;
}
}
}

9
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/ReflectionProxyVolumeComponentUI.cs


ProxyVolumeUI.DrawHandles_EditBase(target.transform, target.proxyVolume, ui.proxyVolume, target);
}
public static void DrawHandles_EditNone(ReflectionProxyVolumeComponentUI ui, ReflectionProxyVolumeComponent target)
public static void DrawGizmos_EditNone(ReflectionProxyVolumeComponent target)
ProxyVolumeUI.DrawHandles_EditNone(target.transform, target.proxyVolume, ui.proxyVolume, target);
}
public static void DrawGizmos_EditNone(ReflectionProxyVolumeComponentUI ui, ReflectionProxyVolumeComponent target)
{
ProxyVolumeUI.DrawGizmos_EditNone(target.transform, target.proxyVolume, ui.proxyVolume, target);
ProxyVolumeUI.DrawGizmos(target.transform, target.proxyVolume);
}
}
}

29
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/SerializedInfluenceVolume.cs


internal SerializedProperty boxSize;
internal SerializedProperty boxBlendDistancePositive;
internal SerializedProperty boxBlendDistanceNegative;
//internal SerializedProperty boxBlendSize;
//internal SerializedProperty boxBlendNormalSize;
internal SerializedProperty boxSideFadePositive;
internal SerializedProperty boxSideFadeNegative;
internal SerializedProperty sphereRadius;

internal SerializedProperty editorAdvancedModeBlendNormalDistanceNegative;
internal SerializedProperty editorSimplifiedModeBlendNormalDistance;
internal SerializedProperty editorAdvancedModeEnabled;
internal SerializedProperty editorAdvancedModeFaceFadePositive;
internal SerializedProperty editorAdvancedModeFaceFadeNegative;
public SerializedInfluenceVolume(SerializedProperty root)
{

boxSize = root.Find((InfluenceVolume i) => i.boxSize);
boxBlendDistancePositive = root.Find((InfluenceVolume i) => i.boxBlendDistancePositive);
boxBlendDistanceNegative = root.Find((InfluenceVolume i) => i.boxBlendDistanceNegative);
//boxBlendSize = root.Find((InfluenceVolume i) => i.boxBlendSize);
//boxBlendNormalSize = root.Find((InfluenceVolume i) => i.boxBlendNormalSize);
boxSideFadePositive = root.Find((InfluenceVolume i) => i.boxSideFadePositive);
boxSideFadeNegative = root.Find((InfluenceVolume i) => i.boxSideFadeNegative);
sphereRadius = root.Find((InfluenceVolume i) => i.sphereRadius);

editorAdvancedModeBlendNormalDistanceNegative = root.FindPropertyRelative("m_EditorAdvancedModeBlendNormalDistanceNegative");
editorSimplifiedModeBlendNormalDistance = root.FindPropertyRelative("m_EditorSimplifiedModeBlendNormalDistance");
editorAdvancedModeEnabled = root.FindPropertyRelative("m_EditorAdvancedModeEnabled");
editorAdvancedModeFaceFadePositive = root.FindPropertyRelative("m_EditorAdvancedModeFaceFadePositive");
editorAdvancedModeFaceFadeNegative = root.FindPropertyRelative("m_EditorAdvancedModeFaceFadeNegative");
if(editorAdvancedModeBlendDistancePositive.vector3Value == Vector3.zero
if (editorAdvancedModeBlendDistancePositive.vector3Value == Vector3.zero
&& editorAdvancedModeBlendDistanceNegative.vector3Value == Vector3.zero
&& editorSimplifiedModeBlendDistance.floatValue == 0f
&& editorAdvancedModeBlendNormalDistancePositive.vector3Value == Vector3.zero

|| boxBlendDistanceNegative.vector3Value != Vector3.zero))
|| boxBlendDistanceNegative.vector3Value != Vector3.zero
|| boxBlendNormalDistancePositive.vector3Value != Vector3.zero
|| boxBlendNormalDistanceNegative.vector3Value != Vector3.zero))
{
Vector3 positive = boxBlendDistancePositive.vector3Value;
Vector3 negative = boxBlendDistanceNegative.vector3Value;

|| negative.x != negative.y
|| negative.x != negative.z
|| positive.x != negative.x;
Apply();
}
if(editorAdvancedModeFaceFadePositive.vector3Value == Vector3.one
&& editorAdvancedModeFaceFadeNegative.vector3Value == Vector3.one
&& (boxSideFadePositive.vector3Value != Vector3.one
|| boxSideFadeNegative.vector3Value != Vector3.one))
{
editorAdvancedModeFaceFadePositive.vector3Value = boxSideFadePositive.vector3Value;
editorAdvancedModeFaceFadeNegative.vector3Value = boxSideFadeNegative.vector3Value;
if(!editorAdvancedModeEnabled.boolValue)
{
boxSideFadePositive.vector3Value = Vector3.one;
boxSideFadeNegative.vector3Value = Vector3.one;
}
Apply();
}
}

1
com.unity.render-pipelines.high-definition/HDRP/Lighting/LightDefinition.cs


public struct EnvLightData
{
// Packing order depends on chronological access to avoid cache misses
public uint lightLayers;
// Proxy properties
public Vector3 capturePositionRWS;

1
com.unity.render-pipelines.high-definition/HDRP/Lighting/LightDefinition.cs.hlsl


// PackingRules = Exact
struct EnvLightData
{
uint lightLayers;
float3 capturePositionRWS;
int influenceShapeType;
float3 proxyExtents;

1
com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoop.cs


// Build light data
var envLightData = new EnvLightData();
envLightData.lightLayers = probe.GetLightLayers();
envLightData.influenceShapeType = probe.influenceShapeType;
envLightData.weight = probe.weight;
envLightData.multiplier = probe.multiplier * m_indirectLightingController.indirectSpecularIntensity;

14
com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoop.hlsl


}
// Define macro for a better understanding of the loop
#define EVALUATE_BSDF_ENV(envLightData, TYPE, type) \
IndirectLighting lighting = EvaluateBSDF_Env(context, V, posInput, preLightData, envLightData, bsdfData, envLightData.influenceShapeType, MERGE_NAME(GPUIMAGEBASEDLIGHTINGTYPE_, TYPE), MERGE_NAME(type, HierarchyWeight)); \
AccumulateIndirectLighting(lighting, aggregateLighting);
#define EVALUATE_BSDF_ENV_SKY(envLightData, TYPE, type) \
IndirectLighting lighting = EvaluateBSDF_Env(context, V, posInput, preLightData, envLightData, bsdfData, envLightData.influenceShapeType, MERGE_NAME(GPUIMAGEBASEDLIGHTINGTYPE_, TYPE), MERGE_NAME(type, HierarchyWeight)); \
AccumulateIndirectLighting(lighting, aggregateLighting);
// Environment cubemap test lightlayers, sky don't test it
#define EVALUATE_BSDF_ENV(envLightData, TYPE, type) if (IsMatchingLightLayer(envLightData.lightLayers, builtinData.renderingLayers)) { EVALUATE_BSDF_ENV_SKY(envLightData, TYPE, type) }
// First loop iteration
if (featureFlags & (LIGHTFEATUREFLAGS_ENV | LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_SSREFRACTION | LIGHTFEATUREFLAGS_SSREFLECTION))

// Only apply the sky if we haven't yet accumulated enough IBL lighting.
if (reflectionHierarchyWeight < 1.0)
{
EVALUATE_BSDF_ENV(envLightSky, REFLECTION, reflection);
EVALUATE_BSDF_ENV_SKY(envLightSky, REFLECTION, reflection);
}
if (featureFlags & LIGHTFEATUREFLAGS_SSREFRACTION)

EVALUATE_BSDF_ENV(envLightSky, REFRACTION, refraction);
EVALUATE_BSDF_ENV_SKY(envLightSky, REFRACTION, refraction);
#undef EVALUATE_BSDF_ENV_SKY
// Also Apply indiret diffuse (GI)
// PostEvaluateBSDF will perform any operation wanted by the material and sum everything into diffuseLighting and specularLighting

1
com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoopDef.hlsl


{
EnvLightData output;
ZERO_INITIALIZE(EnvLightData, output);
output.lightLayers = 0xFFFFFFFF; // Enable sky for all layers
output.influenceShapeType = ENVSHAPETYPE_SKY;
// 31 bit index, 1 bit cache type
output.envIndex = ENVCACHETYPE_CUBEMAP | (envIndex << 1);

61
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDAdditionalReflectionData.cs


Second,
HDProbeChild,
UseInfluenceVolume,
MergeEditors,
// Add new version here and they will automatically be the Current one
Max,
Current = Max - 1

int m_Version;
ReflectionProbe m_LegacyProbe;
ReflectionProbe legacyProbe
/// <summary>Get the sibling component ReflectionProbe</summary>
public ReflectionProbe reflectionProbe
if (m_LegacyProbe == null || m_LegacyProbe.Equals(null))
if(m_LegacyProbe == null || m_LegacyProbe.Equals(null))
return m_LegacyProbe;
else
{
return m_LegacyProbe;
}
return m_LegacyProbe;
}
}

bool needMigrateToHDProbeChild = false;
bool needMigrateToUseInfluenceVolume = false;
bool needMigrateToMergeEditors = false;
public void CopyTo(HDAdditionalReflectionData data)
{

{
needMigrateToUseInfluenceVolume = true;
}
else if (m_Version < (int)Version.MergeEditors)
{
needMigrateToMergeEditors = true;
}
else
{
// Add here data migration code that do not use other component

MigrateToHDProbeChild();
if (needMigrateToUseInfluenceVolume)
MigrateToUseInfluenceVolume();
if (needMigrateToMergeEditors)
MigrateToMergeEditors();
ReflectionSystem.RegisterProbe(this);
}
void OnDisable()
{
ReflectionSystem.UnregisterProbe(this);
}
void OnValidate()
{
ReflectionSystem.UnregisterProbe(this);
if (isActiveAndEnabled)
ReflectionSystem.RegisterProbe(this);
mode = legacyProbe.mode;
refreshMode = legacyProbe.refreshMode;
mode = reflectionProbe.mode;
refreshMode = reflectionProbe.refreshMode;
m_Version = (int)Version.HDProbeChild;
needMigrateToHDProbeChild = false;
OnAfterDeserialize(); //continue migrating if needed

{
influenceVolume.boxSize = legacyProbe.size;
influenceVolume.boxSize = reflectionProbe.size;
#pragma warning disable CS0618 // Type or member is obsolete
influenceVolume.sphereRadius = influenceSphereRadius;
influenceVolume.shape = influenceShape; //must be done after each size transfert

//User will lose parameters corresponding to non used mode between simplified and advanced
}
void MigrateToMergeEditors()
{
infiniteProjection = !reflectionProbe.boxProjection;
reflectionProbe.boxProjection = false;
m_Version = (int)Version.MergeEditors;
needMigrateToMergeEditors = false;
OnAfterDeserialize(); //continue migrating if needed
}
legacyProbe.mode = value; //ensure compatibility till we capture without the legacy component
reflectionProbe.mode = value; //ensure compatibility till we capture without the legacy component
if(value == ReflectionProbeMode.Realtime)
{
refreshMode = ReflectionProbeRefreshMode.EveryFrame;
}
}
}

{
base.refreshMode = value;
legacyProbe.refreshMode = value; //ensure compatibility till we capture without the legacy component
reflectionProbe.refreshMode = value; //ensure compatibility till we capture without the legacy component
legacyProbe.size = size;
legacyProbe.center = transform.rotation*offset;
reflectionProbe.size = size;
reflectionProbe.center = transform.rotation*offset;
}
}
}

36
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDProbe.cs


{
[SerializeField, FormerlySerializedAs("proxyVolumeComponent"), FormerlySerializedAs("m_ProxyVolumeReference")]
ReflectionProxyVolumeComponent m_ProxyVolume = null;
[SerializeField]
bool m_InfiniteProjection = true; //usable when no proxy set
[SerializeField]
FrameSettings m_FrameSettings = null;
[SerializeField, FormerlySerializedAsAttribute("dimmer"), FormerlySerializedAsAttribute("m_Dimmer"), FormerlySerializedAsAttribute("multiplier")]
float m_Multiplier = 1.0f;

ReflectionProbeMode m_Mode = ReflectionProbeMode.Baked;
[SerializeField]
ReflectionProbeRefreshMode m_RefreshMode = ReflectionProbeRefreshMode.OnAwake;
RenderTexture m_RealtimeTexture = null;
/// <summary>Light layer to use by this probe.</summary>
public LightLayerEnum lightLayers = LightLayerEnum.LightLayerDefault;
// This function return a mask of light layers as uint and handle the case of Everything as being 0xFF and not -1
public uint GetLightLayers()
{
int value = (int)(lightLayers);
return value < 0 ? (uint)LightLayerEnum.Everything : (uint)value;
}
/// <summary>ProxyVolume currently used by this probe.</summary>
public ReflectionProxyVolumeComponent proxyVolume { get { return m_ProxyVolume; } }

/// <summary>Frame settings in use with this probe.</summary>
public FrameSettings frameSettings { get { return m_FrameSettings; } }
/// <summary>Get the realtime acquired Render Texture</summary>
public RenderTexture realtimeTexture { get { return m_RealtimeTexture; } internal set { m_RealtimeTexture = value; } }
/// <summary>The capture mode.</summary>
public virtual ReflectionProbeMode mode

{
get { return m_RefreshMode; }
set { m_RefreshMode = value; }
}
public bool infiniteProjection
{
get
{
return (proxyVolume != null && proxyVolume.proxyVolume.shape == ProxyShape.Infinite)
|| (proxyVolume == null && m_InfiniteProjection);
}
set
{
m_InfiniteProjection = value;
}
}
internal void Awake()

19
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/PlanarReflectionProbe.cs


using UnityEngine.Serialization;
using UnityEngine.Rendering;
using UnityEngine.Assertions;
namespace UnityEngine.Experimental.Rendering.HDPipeline
{

[SerializeField]
Texture m_BakedTexture;
[SerializeField]
FrameSettings m_FrameSettings = null;
[SerializeField]
float m_CaptureNearPlane = 1;
[SerializeField]
float m_CaptureFarPlane = 1000;

[SerializeField]
[Range(0, 180)]
float m_FieldOfViewOverride = 90;
RenderTexture m_RealtimeTexture;
public bool overrideFieldOfView { get { return m_OverrideFieldOfView; } }
public float fieldOfViewOverride { get { return m_FieldOfViewOverride; } }

}
public Texture customTexture { get { return m_CustomTexture; } set { m_CustomTexture = value; } }
public Texture bakedTexture { get { return m_BakedTexture; } set { m_BakedTexture = value; }}
public RenderTexture realtimeTexture { get { return m_RealtimeTexture; } internal set { m_RealtimeTexture = value; } }
public FrameSettings frameSettings { get { return m_FrameSettings; } }
public float captureNearPlane { get { return m_CaptureNearPlane; } }
public float captureFarPlane { get { return m_CaptureFarPlane; } }
public CapturePositionMode capturePositionMode { get { return m_CapturePositionMode; } }

: influenceVolume.boxSize;
}
}
public bool infiniteProjection
{
get
{
return proxyVolume != null
&& proxyVolume.proxyVolume.shape == ProxyShape.Infinite;
}
}
public bool useMirrorPlane
{

public void OnAfterDeserialize()
{
Assert.IsNotNull(influenceVolume, "influenceVolume must have an instance at this point. See HDProbe.Awake()");
if (m_Version != currentVersion)
{
// Add here data migration code

}
m_Version = currentVersion;
}
influenceVolume.boxBlendNormalDistanceNegative = Vector3.zero;
influenceVolume.boxBlendNormalDistancePositive = Vector3.zero;
}
}
}

34
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ProbeWrapper.cs


public abstract Matrix4x4 proxyToWorld { get; }
public abstract Vector3 proxyExtents { get; }
public abstract bool infiniteProjection { get; }
public abstract uint GetLightLayers();
}
class VisibleReflectionProbeWrapper : ProbeWrapper

if (add.influenceVolume == null)
{
add.Awake(); // We need to init the 'default' data if it isn't
}
}
Vector3 distance = Vector3.one * probe.blendDistance;
add.influenceVolume.boxBlendDistancePositive = distance;
add.influenceVolume.boxBlendDistanceNegative = distance;

}
}
public override Texture texture { get { return probe.texture; } }
public override Texture texture
{
get
{
if(additional.mode == ReflectionProbeMode.Realtime)
{
return additional.realtimeTexture;
}
else
{
return probe.texture;
}
}
}
public override ReflectionProbeMode mode { get { return probe.probe.mode; } }
public override EnvShapeType influenceShapeType { get { return ConvertShape(additional.influenceVolume.shape); } }
public override float weight { get { return additional.weight; } }

: influenceExtents;
}
}
public override bool infiniteProjection
{
get
{
return additional.proxyVolume != null
? additional.proxyVolume.proxyVolume.shape == ProxyShape.Infinite
: probe.boxProjection == 0;
}
}
public override bool infiniteProjection { get { return additional.infiniteProjection; } }
public override Matrix4x4 proxyToWorld
{

: influenceToWorld;
}
}
public override uint GetLightLayers() { return additional.GetLightLayers(); }
}
class PlanarReflectionProbeWrapper : ProbeWrapper

public override ReflectionProbeMode mode { get { return planarReflectionProbe.mode; } }
public override Matrix4x4 proxyToWorld { get { return planarReflectionProbe.proxyToWorld; } }
public override uint GetLightLayers() { return planarReflectionProbe.GetLightLayers(); }
}
}

10
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ReflectionSystem.cs


s_Instance.RegisterProbe(planarProbe);
}
public static void RegisterProbe(HDAdditionalReflectionData probe)
{
s_Instance.RegisterProbe(probe);
}
}
public static void UnregisterProbe(HDAdditionalReflectionData probe)
{
s_Instance.UnregisterProbe(probe);
}
public static void RequestRealtimeRender(PlanarReflectionProbe probe)

167
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ReflectionSystemInternal.cs


{
static Camera s_RenderCamera = null;
static HDAdditionalCameraData s_RenderCameraData;
static int frame = Time.frameCount;
HashSet<HDAdditionalReflectionData> m_AdditionalDataReflectionProbes;
HashSet<HDAdditionalReflectionData> m_AdditionalDataReflectionProbe_RealtimeUpdate;
HashSet<HDAdditionalReflectionData> m_AdditionalDataReflectionProbe_RequestRealtimeRender;
HDAdditionalReflectionData[] m_AdditionalDataReflectionProbe_RealtimeUpdate_WorkArray;
HashSet<PlanarReflectionProbe> m_PlanarReflectionProbes;
HashSet<PlanarReflectionProbe> m_PlanarReflectionProbe_DirtyBounds;

m_PlanarReflectionProbesArray = new PlanarReflectionProbe[parameters.maxActivePlanarReflectionProbe];
m_PlanarReflectionProbeBoundsArray = new BoundingSphere[parameters.maxActivePlanarReflectionProbe];
m_PlanarReflectionProbe_RealtimeUpdate_WorkArray = new PlanarReflectionProbe[parameters.maxPlanarReflectionProbePerCamera];
m_AdditionalDataReflectionProbe_RealtimeUpdate_WorkArray = new HDAdditionalReflectionData[parameters.maxPlanarReflectionProbePerCamera]; ;
m_AdditionalDataReflectionProbes = new HashSet<HDAdditionalReflectionData>();
m_AdditionalDataReflectionProbe_RealtimeUpdate = new HashSet<HDAdditionalReflectionData>();
m_AdditionalDataReflectionProbe_RequestRealtimeRender = new HashSet<HDAdditionalReflectionData>();
m_PlanarReflectionProbes = new HashSet<PlanarReflectionProbe>();
m_PlanarReflectionProbe_DirtyBounds = new HashSet<PlanarReflectionProbe>();
m_PlanarReflectionProbe_RequestRealtimeRender = new HashSet<PlanarReflectionProbe>();

if (previous != null)
{
m_AdditionalDataReflectionProbes.UnionWith(previous.m_AdditionalDataReflectionProbes);
m_AdditionalDataReflectionProbe_RequestRealtimeRender.UnionWith(previous.m_AdditionalDataReflectionProbe_RequestRealtimeRender);
m_AdditionalDataReflectionProbe_RealtimeUpdate.UnionWith(previous.m_AdditionalDataReflectionProbe_RealtimeUpdate);
m_PlanarReflectionProbes.UnionWith(previous.m_PlanarReflectionProbes);
m_PlanarReflectionProbe_DirtyBounds.UnionWith(m_PlanarReflectionProbes);
m_PlanarReflectionProbe_RequestRealtimeRender.UnionWith(previous.m_PlanarReflectionProbe_RequestRealtimeRender);

}
}
public void RegisterProbe(HDAdditionalReflectionData additional)
{
m_AdditionalDataReflectionProbes.Add(additional);
//SetProbeBoundsDirty(probe);
if (additional.mode == ReflectionProbeMode.Realtime)
{
//switch (additional.refreshMode)
//{
// case ReflectionProbeRefreshMode.OnAwake:
// m_AdditionalDataReflectionProbe_RequestRealtimeRender.Add(additional);
// break;
// case ReflectionProbeRefreshMode.EveryFrame:
m_AdditionalDataReflectionProbe_RealtimeUpdate.Add(additional);
// break;
//}
}
}
public void UnregisterProbe(PlanarReflectionProbe planarProbe)
{
m_PlanarReflectionProbes.Remove(planarProbe);

m_PlanarReflectionProbe_PerCamera_RealtimeUpdate.Remove(planarProbe);
}
public void UnregisterProbe(HDAdditionalReflectionData additional)
{
m_AdditionalDataReflectionProbes.Remove(additional);
m_AdditionalDataReflectionProbe_RequestRealtimeRender.Remove(additional);
m_AdditionalDataReflectionProbe_RealtimeUpdate.Remove(additional);
}
public void PrepareCull(Camera camera, ReflectionProbeCullResults results)
{
UpdateAllPlanarReflectionProbeBounds();

{
var probe = m_PlanarReflectionProbe_RealtimeUpdate_WorkArray[i];
if (!IsRealtimeTextureValid(probe.realtimeTexture))
if (!IsRealtimeTextureValid(probe.realtimeTexture, true))
{
if (probe.realtimeTexture != null)
probe.realtimeTexture.Release();

{
var probe = m_PlanarReflectionProbe_RealtimeUpdate_WorkArray[i];
if (!IsRealtimeTextureValid(probe.realtimeTexture))
if (!IsRealtimeTextureValid(probe.realtimeTexture, true))
{
if (probe.realtimeTexture != null)
probe.realtimeTexture.Release();

Render(probe, probe.realtimeTexture);
}
}
if ((probeTypes & ReflectionProbeType.ReflectionProbe) != 0 && frame != Time.frameCount)
{
//do only one per frame
frame = Time.frameCount;
// Discard disabled probes in requested render probes
m_AdditionalDataReflectionProbe_RequestRealtimeRender.IntersectWith(m_AdditionalDataReflectionProbes);
// Include all realtime probe modes
m_AdditionalDataReflectionProbe_RequestRealtimeRender.UnionWith(m_AdditionalDataReflectionProbe_RealtimeUpdate);
var length = Mathf.Min(m_AdditionalDataReflectionProbe_RequestRealtimeRender.Count, m_AdditionalDataReflectionProbe_RealtimeUpdate_WorkArray.Length);
m_AdditionalDataReflectionProbe_RequestRealtimeRender.CopyTo(m_AdditionalDataReflectionProbe_RealtimeUpdate_WorkArray);
m_AdditionalDataReflectionProbe_RequestRealtimeRender.Clear();
// 1. Allocate if necessary target texture
for (var i = 0; i < length; i++)
{
var additional = m_AdditionalDataReflectionProbe_RealtimeUpdate_WorkArray[i];
if (!IsRealtimeTextureValid(additional.realtimeTexture, false))
{
if (additional.realtimeTexture != null)
additional.realtimeTexture.Release();
additional.realtimeTexture = NewRenderTarget(additional);
}
}
// 2. Render
for (var i = 0; i < length; i++)
{
var additional = m_AdditionalDataReflectionProbe_RealtimeUpdate_WorkArray[i];
Render(additional, additional.realtimeTexture);
}
}
}
public RenderTexture NewRenderTarget(PlanarReflectionProbe probe)

return rt;
}
public RenderTexture NewRenderTarget(HDAdditionalReflectionData probe)
{
var rt = new RenderTexture(m_Parameters.reflectionProbeSize, m_Parameters.reflectionProbeSize, 0, RenderTextureFormat.ARGBHalf);
// No hide and don't save for this one
rt.useMipMap = true;
rt.autoGenerateMips = false;
rt.name = CoreUtils.GetRenderTargetAutoName(m_Parameters.reflectionProbeSize, m_Parameters.reflectionProbeSize, 1, RenderTextureFormat.ARGBHalf, "ProbeRT");
rt.dimension = TextureDimension.Cube;
rt.Create();
return rt;
}
//public float GetCaptureCameraFOVFor(PlanarReflectionProbe probe, Camera viewerCamera)
//{
// switch (probe.influenceVolume.shapeType)

// }
//}
bool IsRealtimeTextureValid(RenderTexture renderTexture)
bool IsRealtimeTextureValid(RenderTexture renderTexture, bool isPlanar)
return renderTexture != null
&& renderTexture.width == m_Parameters.planarReflectionProbeSize
&& renderTexture.height == m_Parameters.planarReflectionProbeSize
&& renderTexture.format == RenderTextureFormat.ARGBHalf
&& renderTexture.useMipMap;
if(isPlanar)
return renderTexture != null
&& renderTexture.width == m_Parameters.planarReflectionProbeSize
&& renderTexture.height == m_Parameters.planarReflectionProbeSize
&& renderTexture.format == RenderTextureFormat.ARGBHalf
&& renderTexture.useMipMap;
else
return renderTexture != null
&& renderTexture.width == m_Parameters.reflectionProbeSize
&& renderTexture.height == m_Parameters.reflectionProbeSize
&& renderTexture.format == RenderTextureFormat.ARGBHalf
&& renderTexture.useMipMap;
}
public void RequestRealtimeRender(PlanarReflectionProbe probe)

renderCamera.Render();
GL.invertCulling = false;
renderCamera.targetTexture = null;
target.IncrementUpdateCount();
}
public void Render(HDAdditionalReflectionData additional, RenderTexture target, Camera viewerCamera = null)
{
var renderCamera = GetRenderCamera();
// Copy current frameSettings of this probe to the HDAdditionalData of the render camera
//probe.frameSettings.CopyTo(s_RenderCameraData.GetFrameSettings());
SetupCameraForRender(renderCamera, additional, viewerCamera);
renderCamera.RenderToCubemap(target);
target.IncrementUpdateCount();
}

ctr.rotation = captureRotation;
}
static void SetupCameraForRender(Camera camera, HDAdditionalReflectionData additional, Camera viewerCamera = null)
{
float nearClipPlane, farClipPlane, aspect, fov;
Color backgroundColor;
CameraClearFlags clearFlags;
Vector3 capturePosition;
Quaternion captureRotation;
Matrix4x4 worldToCamera, projection;
CalculateCaptureCameraProperties(additional,
out nearClipPlane, out farClipPlane,
out aspect, out fov, out clearFlags, out backgroundColor,
out worldToCamera, out projection,
out capturePosition, out captureRotation, viewerCamera);
camera.farClipPlane = farClipPlane;
camera.nearClipPlane = nearClipPlane;
camera.fieldOfView = fov;
camera.aspect = aspect;
camera.clearFlags = clearFlags;
camera.backgroundColor = camera.backgroundColor;
camera.projectionMatrix = projection;
camera.worldToCameraMatrix = worldToCamera;
camera.cullingMask = additional.reflectionProbe.cullingMask;
var ctr = camera.transform;
ctr.position = capturePosition;
ctr.rotation = captureRotation;
}
public static void CalculateCaptureCameraViewProj(PlanarReflectionProbe probe, out Matrix4x4 worldToCamera, out Matrix4x4 projection, out Vector3 capturePosition, out Quaternion captureRotation, Camera viewerCamera = null)
{
float nearClipPlane, farClipPlane, aspect, fov;

CalculateMirroredCaptureCameraProperties(probe, viewerCamera, out nearClipPlane, out farClipPlane, out aspect, out fov, out clearFlags, out backgroundColor, out worldToCamera, out projection, out capturePosition, out captureRotation);
else
CalculateStaticCaptureCameraProperties(probe, out nearClipPlane, out farClipPlane, out aspect, out fov, out clearFlags, out backgroundColor, out worldToCamera, out projection, out capturePosition, out captureRotation);
}
public static void CalculateCaptureCameraProperties(HDAdditionalReflectionData additional, out float nearClipPlane, out float farClipPlane, out float aspect, out float fov, out CameraClearFlags clearFlags, out Color backgroundColor, out Matrix4x4 worldToCamera, out Matrix4x4 projection, out Vector3 capturePosition, out Quaternion captureRotation, Camera viewerCamera = null)
{
nearClipPlane = additional.reflectionProbe.nearClipPlane;
farClipPlane = additional.reflectionProbe.farClipPlane;
aspect = 1f;
fov = 90f;
clearFlags = CameraClearFlags.Nothing;
backgroundColor = Color.white;
capturePosition = additional.transform.position; //at the moment capture position is at probe position
captureRotation = Quaternion.identity;
worldToCamera = GeometryUtils.CalculateWorldToCameraMatrixRHS(capturePosition, captureRotation);
projection = Matrix4x4.Perspective(fov, aspect, nearClipPlane, farClipPlane);
}
static bool IsProbeCaptureMirrored(PlanarReflectionProbe probe, Camera viewerCamera)

14
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ReflectionSystemParameters.cs


{
maxPlanarReflectionProbePerCamera = 128,
maxActivePlanarReflectionProbe = 512,
planarReflectionProbeSize = 128
planarReflectionProbeSize = 128,
maxActiveReflectionProbe = 512,
reflectionProbeSize = 128
};
/// <summary>

/// Size of the planar probe textures.
/// </summary>
public int planarReflectionProbeSize;
/// <summary>
/// Maximum number of active non planar reflection in the world.
/// </summary>
public int maxActiveReflectionProbe;
/// <summary>
/// Size of the non planar probe textures.
/// </summary>
public int reflectionProbeSize;
}
}

16
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/Volumes/InfluenceVolume.cs


float m_EditorSimplifiedModeBlendNormalDistance;
[SerializeField, FormerlySerializedAs("editorAdvancedModeEnabled")]
bool m_EditorAdvancedModeEnabled;
[SerializeField]
Vector3 m_EditorAdvancedModeFaceFadePositive = Vector3.one;
[SerializeField]
Vector3 m_EditorAdvancedModeFaceFadeNegative = Vector3.one;
// Sphere
[SerializeField, FormerlySerializedAs("m_SphereBaseRadius")]

data.m_EditorAdvancedModeBlendNormalDistanceNegative = m_EditorAdvancedModeBlendNormalDistanceNegative;
data.m_EditorSimplifiedModeBlendNormalDistance = m_EditorSimplifiedModeBlendNormalDistance;
data.m_EditorAdvancedModeEnabled = m_EditorAdvancedModeEnabled;
data.m_EditorAdvancedModeFaceFadePositive = m_EditorAdvancedModeFaceFadePositive;
data.m_EditorAdvancedModeFaceFadeNegative = m_EditorAdvancedModeFaceFadeNegative;
}
/// <summary>Shape of this InfluenceVolume.</summary>

}
/// <summary>Offset of this influence volume to the component handling him.</summary>
public Vector3 offset { get { return m_Offset; } set { m_Offset = value; } }
public Vector3 offset
{
get { return m_Offset; }
set
{
m_Offset = value;
m_Probe.UpdatedInfluenceVolumeShape(boxSize, m_Offset);
}
}
/// <summary>Size of the InfluenceVolume in Box Mode.</summary>
public Vector3 boxSize

8
com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs


}
// TODO: Render only visible probes
var isReflection = cameras.Any(c => c.cameraType == CameraType.Reflection);
if (!isReflection)
ReflectionSystem.RenderAllRealtimeProbes(ReflectionProbeType.PlanarReflection);
var probeTypeToRender = ReflectionProbeType.ReflectionProbe;
var isPlanarReflection = cameras.Any(c => c.cameraType == CameraType.Reflection);
if (isPlanarReflection)
probeTypeToRender |= ReflectionProbeType.PlanarReflection;
ReflectionSystem.RenderAllRealtimeProbes(probeTypeToRender);
// We first update the state of asset frame settings as they can be use by various camera
// but we keep the dirty state to correctly reset other camera that use RenderingPath.Default.

4
com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipelineAsset.cs


{
maxPlanarReflectionProbePerCamera = renderPipelineSettings.lightLoopSettings.planarReflectionProbeCacheSize,
maxActivePlanarReflectionProbe = 512,
planarReflectionProbeSize = (int)renderPipelineSettings.lightLoopSettings.planarReflectionTextureSize
planarReflectionProbeSize = (int)renderPipelineSettings.lightLoopSettings.planarReflectionTextureSize,
maxActiveReflectionProbe = 512,
reflectionProbeSize = (int)renderPipelineSettings.lightLoopSettings.reflectionCubemapSize
};
}
}

12
com.unity.render-pipelines.lightweight/CHANGELOG.md


and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [3.3.0-preview]
### Added
- Add callbacks to LWRP that can be attached to a camera (IBeforeCameraRender, IAfterDepthPrePass, IAfterOpaquePass, IAfterOpaquePostProcess, IAfterSkyboxPass, IAfterTransparentPass, IAfterRender)
###Changed
- Clean up LWRP creation of render textures. If we are not going straight to screen ensure that we create both depth and color targets.
- UNITY_DECLARE_FRAMEBUFFER_INPUT and UNITY_READ_FRAMEBUFFER_INPUT macros were added. They are necessary for reading transient attachments.
- UNITY_MATRIX_I_VP is now defined.
- Renamed LightweightForwardRenderer to ScriptableRenderer.
- Moved all light constants to _LightBuffer CBUFFER. Now _PerCamera CBUFFER contains all other per camera constants.
### Fixed
- Lightweight Unlit shader UI doesn't throw an error about missing receive shadow property anymore.
## [3.2.0-preview]
### Changed

97
com.unity.render-pipelines.lightweight/LWRP/DefaultRendererSetup.cs


private DirectionalShadowsPass m_DirectionalShadowPass;
private LocalShadowsPass m_LocalShadowPass;
private SetupForwardRenderingPass m_SetupForwardRenderingPass;
private ScreenSpaceShadowResolvePass m_ScreenSpaceShadowResovePass;
private ScreenSpaceShadowResolvePass m_ScreenSpaceShadowResolvePass;
private CreateLightweightRenderTexturesPass m_CreateLightweightRenderTexturesPass;
private BeginXRRenderingPass m_BeginXrRenderingPass;
private SetupLightweightConstanstPass m_SetupLightweightConstants;

private TransparentPostProcessPass m_TransparentPostProcessPass;
private FinalBlitPass m_FinalBlitPass;
private EndXRRenderingPass m_EndXrRenderingPass;
#if UNITY_EDITOR
#if UNITY_EDITOR
#endif
#endif
private RenderTargetHandle Color;
private RenderTargetHandle ColorAttachment;
private RenderTargetHandle DepthAttachment;
private RenderTargetHandle DepthTexture;
private RenderTargetHandle OpaqueColor;

m_DirectionalShadowPass = new DirectionalShadowsPass();
m_LocalShadowPass = new LocalShadowsPass();
m_SetupForwardRenderingPass = new SetupForwardRenderingPass();
m_ScreenSpaceShadowResovePass = new ScreenSpaceShadowResolvePass();
m_ScreenSpaceShadowResolvePass = new ScreenSpaceShadowResolvePass();
m_CreateLightweightRenderTexturesPass = new CreateLightweightRenderTexturesPass();
m_BeginXrRenderingPass = new BeginXRRenderingPass();
m_SetupLightweightConstants = new SetupLightweightConstanstPass();

m_TransparentPostProcessPass = new TransparentPostProcessPass();
m_FinalBlitPass = new FinalBlitPass();
m_EndXrRenderingPass = new EndXRRenderingPass();
#if UNITY_EDITOR
#if UNITY_EDITOR
#endif
#endif
Color.Init("_CameraColorTexture");
ColorAttachment.Init("_CameraColorTexture");
DepthAttachment.Init("_CameraDepthAttachment");
DepthTexture.Init("_CameraDepthTexture");
OpaqueColor.Init("_CameraOpaqueTexture");

m_Initialized = true;
}
public void Setup(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public void Setup(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults, ref RenderingData renderingData)
{
Init();

Camera camera = renderingData.cameraData.camera;
RenderTextureDescriptor baseDescriptor = LightweightForwardRenderer.CreateRTDesc(ref renderingData.cameraData);
RenderTextureDescriptor baseDescriptor = ScriptableRenderer.CreateRTDesc(ref renderingData.cameraData);
bool requiresDepthPrepass = renderingData.shadowData.requiresScreenSpaceShadowResolve ||
renderingData.cameraData.isSceneViewCamera ||
(requiresCameraDepth &&
!LightweightForwardRenderer.CanCopyDepth(ref renderingData.cameraData));
bool requiresDepthPrepass = renderingData.shadowData.requiresScreenSpaceShadowResolve
|| renderingData.cameraData.isSceneViewCamera
|| (requiresCameraDepth && !ScriptableRenderer.CanCopyDepth(ref renderingData.cameraData));
// For now VR requires a depth prepass until we figure out how to properly resolve texture2DMS in stereo
requiresDepthPrepass |= renderingData.cameraData.isStereoEnabled;

if (renderingData.shadowData.renderLocalShadows)
{
m_LocalShadowPass.Setup(LocalShadowmap, renderer.maxVisibleLocalLights);
renderer.EnqueuePass(m_LocalShadowPass);
}

{
m_DepthOnlyPass.Setup(baseDescriptor, DepthTexture, SampleCount.One);
renderer.EnqueuePass(m_DepthOnlyPass);
foreach (var pass in camera.GetComponents<IAfterDepthPrePass>())
renderer.EnqueuePass(pass.GetPassToEnqueue(m_DepthOnlyPass.descriptor, DepthTexture));
m_ScreenSpaceShadowResovePass.Setup(baseDescriptor, ScreenSpaceShadowmap);
renderer.EnqueuePass(m_ScreenSpaceShadowResovePass);
m_ScreenSpaceShadowResolvePass.Setup(baseDescriptor, ScreenSpaceShadowmap);
renderer.EnqueuePass(m_ScreenSpaceShadowResolvePass);
bool requiresDepthAttachment = requiresCameraDepth && !requiresDepthPrepass;
bool requiresColorAttachment =
LightweightForwardRenderer.RequiresIntermediateColorTexture(
bool requiresRenderToTexture =
ScriptableRenderer.RequiresIntermediateColorTexture(
baseDescriptor,
requiresDepthAttachment);
RenderTargetHandle colorHandle = (requiresColorAttachment) ? Color : RenderTargetHandle.CameraTarget;
RenderTargetHandle depthHandle = (requiresDepthAttachment) ? DepthAttachment : RenderTargetHandle.CameraTarget;
baseDescriptor);
RenderTargetHandle colorHandle = RenderTargetHandle.CameraTarget;
RenderTargetHandle depthHandle = RenderTargetHandle.CameraTarget;
var sampleCount = (SampleCount) renderingData.cameraData.msaaSamples;
m_CreateLightweightRenderTexturesPass.Setup(baseDescriptor, colorHandle, depthHandle, sampleCount);
renderer.EnqueuePass(m_CreateLightweightRenderTexturesPass);
if (requiresRenderToTexture)
{
colorHandle = ColorAttachment;
depthHandle = DepthAttachment;
var sampleCount = (SampleCount)renderingData.cameraData.msaaSamples;
m_CreateLightweightRenderTexturesPass.Setup(baseDescriptor, colorHandle, depthHandle, sampleCount);
renderer.EnqueuePass(m_CreateLightweightRenderTexturesPass);
}
Camera camera = renderingData.cameraData.camera;
RendererConfiguration rendererConfiguration = LightweightForwardRenderer.GetRendererConfiguration(renderingData.lightData.totalAdditionalLightsCount);
RendererConfiguration rendererConfiguration = ScriptableRenderer.GetRendererConfiguration(renderingData.lightData.totalAdditionalLightsCount);
m_RenderOpaqueForwardPass.Setup(baseDescriptor, colorHandle, depthHandle, LightweightForwardRenderer.GetCameraClearFlag(camera), camera.backgroundColor, rendererConfiguration,dynamicBatching);
m_RenderOpaqueForwardPass.Setup(baseDescriptor, colorHandle, depthHandle, ScriptableRenderer.GetCameraClearFlag(camera), camera.backgroundColor, rendererConfiguration, dynamicBatching);
foreach (var pass in camera.GetComponents<IAfterOpaquePass>())
renderer.EnqueuePass(pass.GetPassToEnqueue(baseDescriptor, colorHandle, depthHandle));
if (renderingData.cameraData.postProcessEnabled &&
renderingData.cameraData.postProcessLayer.HasOpaqueOnlyEffects(renderer.postProcessRenderContext))

foreach (var pass in camera.GetComponents<IAfterOpaquePostProcess>())
renderer.EnqueuePass(pass.GetPassToEnqueue(baseDescriptor, colorHandle, depthHandle));
{
m_DrawSkyboxPass.Setup(colorHandle, depthHandle);
}
if (depthHandle != RenderTargetHandle.CameraTarget)
foreach (var pass in camera.GetComponents<IAfterSkyboxPass>())
renderer.EnqueuePass(pass.GetPassToEnqueue(baseDescriptor, colorHandle, depthHandle));
if (requiresCameraDepth && !requiresDepthPrepass)
{
m_CopyDepthPass.Setup(depthHandle, DepthTexture);
renderer.EnqueuePass(m_CopyDepthPass);

m_RenderTransparentForwardPass.Setup(baseDescriptor, colorHandle, depthHandle, ClearFlag.None, camera.backgroundColor, rendererConfiguration, dynamicBatching);
renderer.EnqueuePass(m_RenderTransparentForwardPass);
foreach (var pass in camera.GetComponents<IAfterTransparentPass>())
renderer.EnqueuePass(pass.GetPassToEnqueue(baseDescriptor, colorHandle, depthHandle));
m_TransparentPostProcessPass.Setup(renderer.postProcessRenderContext, baseDescriptor, colorHandle);
m_TransparentPostProcessPass.Setup(renderer.postProcessRenderContext, baseDescriptor, colorHandle, BuiltinRenderTextureType.CameraTarget);
renderer.EnqueuePass(m_TransparentPostProcessPass);
}
else if (!renderingData.cameraData.isOffscreenRender && colorHandle != RenderTargetHandle.CameraTarget)

}
foreach (var pass in camera.GetComponents<IAfterRender>())
renderer.EnqueuePass(pass.GetPassToEnqueue());
#if UNITY_EDITOR
if (renderingData.cameraData.isSceneViewCamera)
{

2
com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGUI/LightweightShaderGUI.cs


cullingProp = FindProperty("_Cull", properties);
alphaClipProp = FindProperty("_AlphaClip", properties);
alphaCutoffProp = FindProperty("_Cutoff", properties);
receiveShadowsProp = FindProperty("_ReceiveShadows", properties);
receiveShadowsProp = FindProperty("_ReceiveShadows", properties, false);
}
public virtual void ShaderPropertiesGUI(Material material)

2
com.unity.render-pipelines.lightweight/LWRP/IRendererSetup.cs


{
public interface IRendererSetup
{
void Setup(LightweightForwardRenderer renderer, ref ScriptableRenderContext context, ref CullResults cullResults, ref RenderingData renderingData);
void Setup(ScriptableRenderer renderer, ref ScriptableRenderContext context, ref CullResults cullResults, ref RenderingData renderingData);
}
}

1
com.unity.render-pipelines.lightweight/LWRP/LightweightAdditionalCameraData.cs


{
[DisallowMultipleComponent]
[RequireComponent(typeof(Camera))]
[ImageEffectAllowedInSceneView]
public class LightweightAdditionalCameraData : MonoBehaviour
{
[Tooltip("If enabled shadows will render for this camera.")]

277
com.unity.render-pipelines.lightweight/LWRP/LightweightPipeline.cs


{
public partial class LightweightPipeline : RenderPipeline
{
private static class PerFrameBuffer
static class PerFrameBuffer
}
static class PerCameraBuffer
{
// TODO: This needs to account for stereo rendering
public static int _InvCameraViewProj;
public static int _ScaledScreenParams;
private IRendererSetup m_DefaultRendererSetup;
private IRendererSetup defaultRendererSetup
private static IRendererSetup m_DefaultRendererSetup;
private static IRendererSetup defaultRendererSetup
{
get
{

CameraComparer m_CameraComparer = new CameraComparer();
LightweightForwardRenderer m_Renderer;
ScriptableRenderer m_Renderer;
List<int> m_LocalLightIndices = new List<int>();
bool m_IsCameraRendering;
private PipelineSettings m_PipelineSettings;
public struct PipelineSettings
{
public int msaaSampleCount { get; private set; }
public bool supportsHDR { get; private set; }
public XRGraphicsConfig savedXRGraphicsConfig { get; private set; }
public float renderScale { get; private set; }
public bool supportsCameraDepthTexture { get; private set; }
public Downsampling opaqueDownsampling { get; private set; }
public bool supportsCameraOpaqueTexture { get; private set; }
public bool supportsDynamicBatching { get; private set; }
public int maxPixelLights { get; private set; }
public bool supportsDirectionalShadows { get; private set; }
public bool supportsSoftParticles { get; private set; }
public bool supportsLocalShadows { get; private set; }
public float shadowDistance { get; private set; }
public int cascadeCount { get; private set; }
public int directionalShadowAtlasResolution { get; private set; }
public float cascade2Split { get; private set; }
public Vector3 cascade4Split { get; private set; }
public bool supportsVertexLight { get; private set; }
public int localShadowAtlasResolution { get; private set; }
public bool supportsSoftShadows { get; private set; }
public static PipelineSettings Create(LightweightPipelineAsset asset)
{
var cache = new PipelineSettings();
cache.msaaSampleCount = asset.msaaSampleCount;
cache.supportsHDR = asset.supportsHDR;
cache.savedXRGraphicsConfig = asset.savedXRGraphicsConfig;
cache.renderScale = asset.renderScale;
cache.supportsCameraDepthTexture = asset.supportsCameraDepthTexture;
cache.opaqueDownsampling = asset.opaqueDownsampling;
cache.supportsCameraOpaqueTexture = asset.supportsCameraOpaqueTexture;
cache.supportsDynamicBatching = asset.supportsDynamicBatching;
cache.maxPixelLights = asset.maxPixelLights;
cache.supportsDirectionalShadows = asset.supportsDirectionalShadows;
cache.supportsSoftParticles = asset.supportsSoftParticles;
cache.supportsLocalShadows = asset.supportsLocalShadows;
cache.shadowDistance = asset.shadowDistance;
cache.cascadeCount = asset.cascadeCount;
cache.directionalShadowAtlasResolution = asset.directionalShadowAtlasResolution;
cache.cascade2Split = asset.cascade2Split;
cache.cascade4Split = asset.cascade4Split;
cache.supportsVertexLight = asset.supportsVertexLight;
cache.localShadowAtlasResolution = asset.localShadowAtlasResolution;
cache.supportsSoftShadows = asset.supportsSoftShadows;
return cache;
}
}
pipelineAsset = asset;
m_PipelineSettings = PipelineSettings.Create(asset);
SetSupportedRenderingFeatures();
SetPipelineCapabilities(asset);

SetupLightweightConstanstPass.PerCameraBuffer._ScaledScreenParams = Shader.PropertyToID("_ScaledScreenParams");
m_Renderer = new LightweightForwardRenderer(asset);
PerCameraBuffer._InvCameraViewProj = Shader.PropertyToID("_InvCameraViewProj");
PerCameraBuffer._ScaledScreenParams = Shader.PropertyToID("_ScaledScreenParams");
m_Renderer = new ScriptableRenderer(asset);
if (QualitySettings.antiAliasing != pipelineAsset.msaaSampleCount)
QualitySettings.antiAliasing = pipelineAsset.msaaSampleCount;
if (QualitySettings.antiAliasing != m_PipelineSettings.msaaSampleCount)
QualitySettings.antiAliasing = m_PipelineSettings.msaaSampleCount;
m_IsCameraRendering = false;
}
public override void Dispose()

m_Renderer.Dispose();
}
public interface IBeforeCameraRender
{
void ExecuteBeforeCameraRender(ScriptableRenderContext context, Camera camera, PipelineSettings pipelineSettings, ScriptableRenderer renderer);
}
if (m_IsCameraRendering)
{
Debug.LogWarning("Nested camera rendering is forbidden. If you are calling camera.Render inside OnWillRenderObject callback, use BeginCameraRender callback instead.");
return;
}
pipelineAsset.savedXRGraphicsConfig.renderScale = pipelineAsset.renderScale;
pipelineAsset.savedXRGraphicsConfig.viewportScale = 1.0f; // Placeholder until viewportScale is all hooked up
m_PipelineSettings.savedXRGraphicsConfig.renderScale = m_PipelineSettings.renderScale;
m_PipelineSettings.savedXRGraphicsConfig.viewportScale = 1.0f; // Placeholder until viewportScale is all hooked up
pipelineAsset.savedXRGraphicsConfig.SetConfig();
m_PipelineSettings.savedXRGraphicsConfig.SetConfig();
base.Render(context, cameras);
BeginFrameRendering(cameras);

foreach (Camera camera in cameras)
{
BeginCameraRendering(camera);
string renderCameraTag = "Render " + camera.name;
CommandBuffer cmd = CommandBufferPool.Get(renderCameraTag);
using (new ProfilingSample(cmd, renderCameraTag))
foreach (var beforeCamera in camera.GetComponents<IBeforeCameraRender>())
beforeCamera.ExecuteBeforeCameraRender(context, camera, m_PipelineSettings, m_Renderer);
RenderSingleCamera(context, m_PipelineSettings, camera, ref m_CullResults, camera.GetComponent<IRendererSetup>(), m_Renderer);
}
}
public static void RenderSingleCamera(ScriptableRenderContext context, PipelineSettings settings, Camera camera, ref CullResults cullResults, IRendererSetup setup, ScriptableRenderer renderer)
{
string renderCameraTag = camera.name;
CommandBuffer cmd = CommandBufferPool.Get(renderCameraTag);
using (new ProfilingSample(cmd, renderCameraTag))
{
CameraData cameraData;
InitializeCameraData(settings, camera, out cameraData);
SetupPerCameraShaderConstants(cameraData);
ScriptableCullingParameters cullingParameters;
if (!CullResults.GetCullingParameters(camera, cameraData.isStereoEnabled, out cullingParameters))
CameraData cameraData;
InitializeCameraData(camera, out cameraData);
SetupPerCameraShaderConstants(cameraData);
CommandBufferPool.Release(cmd);
return;
}
ScriptableCullingParameters cullingParameters;
if (!CullResults.GetCullingParameters(camera, cameraData.isStereoEnabled, out cullingParameters))
{
CommandBufferPool.Release(cmd);
continue;
}
cullingParameters.shadowDistance = Mathf.Min(cameraData.maxShadowDistance, camera.farClipPlane);
cullingParameters.shadowDistance = Mathf.Min(cameraData.maxShadowDistance, camera.farClipPlane);
context.ExecuteCommandBuffer(cmd);
cmd.Clear();
context.ExecuteCommandBuffer(cmd);
cmd.Clear();
#if UNITY_EDITOR
#if UNITY_EDITOR
try
#endif
{
m_IsCameraRendering = true;
#if UNITY_EDITOR
// Emit scene view UI
if (cameraData.isSceneViewCamera)
ScriptableRenderContext.EmitWorldGeometryForSceneView(camera);
// Emit scene view UI
if (cameraData.isSceneViewCamera)
ScriptableRenderContext.EmitWorldGeometryForSceneView(camera);
CullResults.Cull(ref cullingParameters, context, ref m_CullResults);
List<VisibleLight> visibleLights = m_CullResults.visibleLights;
CullResults.Cull(ref cullingParameters, context, ref cullResults);
List<VisibleLight> visibleLights = cullResults.visibleLights;
RenderingData renderingData;
InitializeRenderingData(settings, ref cameraData, visibleLights,
renderer.maxSupportedLocalLightsPerPass, renderer.maxSupportedVertexLights,
out renderingData);
RenderingData renderingData;
InitializeRenderingData(ref cameraData, visibleLights,
m_Renderer.maxSupportedLocalLightsPerPass, m_Renderer.maxSupportedVertexLights,
out renderingData);
var setupToUse = setup;
if (setupToUse == null)
setupToUse = defaultRendererSetup;
var setup = cameraData.camera.GetComponent<IRendererSetup>();
if (setup == null)
setup = defaultRendererSetup;
setupToUse.Setup(renderer, ref context, ref cullResults, ref renderingData);
setup.Setup(m_Renderer, ref context, ref m_CullResults, ref renderingData);
renderer.Execute(ref context, ref cullResults, ref renderingData);
m_Renderer.Execute(ref context, ref m_CullResults, ref renderingData);
}
#if UNITY_EDITOR
catch (Exception)
{
CommandBufferPool.Release(cmd);
throw;
}
finally
#endif
{
m_IsCameraRendering = false;
}
}
context.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
context.Submit();

void SetSupportedRenderingFeatures()
static void SetSupportedRenderingFeatures()
{
#if UNITY_EDITOR
SupportedRenderingFeatures.active = new SupportedRenderingFeatures()

#endif
}
void InitializeCameraData(Camera camera, out CameraData cameraData)
static void InitializeCameraData(PipelineSettings settings, Camera camera, out CameraData cameraData)
bool msaaEnabled = camera.allowMSAA && pipelineAsset.msaaSampleCount > 1;
bool msaaEnabled = camera.allowMSAA && settings.msaaSampleCount > 1;
cameraData.msaaSamples = (camera.targetTexture != null) ? camera.targetTexture.antiAliasing : pipelineAsset.msaaSampleCount;
cameraData.msaaSamples = (camera.targetTexture != null) ? camera.targetTexture.antiAliasing : settings.msaaSampleCount;
else
cameraData.msaaSamples = 1;

if (cameraData.isStereoEnabled && XRGraphicsConfig.eyeTextureDesc.dimension == TextureDimension.Tex2DArray)
cameraData.msaaSamples = 1;
cameraData.isHdrEnabled = camera.allowHDR && pipelineAsset.supportsHDR;
cameraData.isHdrEnabled = camera.allowHDR && settings.supportsHDR;
cameraData.postProcessLayer = camera.GetComponent<PostProcessLayer>();
cameraData.postProcessEnabled = cameraData.postProcessLayer != null && cameraData.postProcessLayer.isActiveAndEnabled;

// If XR is enabled, use XR renderScale.
// Discard variations lesser than kRenderScaleThreshold.
// Scale is only enabled for gameview.
float usedRenderScale = XRGraphicsConfig.enabled ? pipelineAsset.savedXRGraphicsConfig.renderScale : pipelineAsset.renderScale;
float usedRenderScale = XRGraphicsConfig.enabled ? settings.savedXRGraphicsConfig.renderScale : settings.renderScale;
cameraData.requiresDepthTexture = pipelineAsset.supportsCameraDepthTexture || cameraData.isSceneViewCamera;
cameraData.requiresSoftParticles = pipelineAsset.supportsSoftParticles;
cameraData.requiresOpaqueTexture = pipelineAsset.supportsCameraOpaqueTexture;
cameraData.opaqueTextureDownsampling = pipelineAsset.opaqueDownsampling;
cameraData.requiresDepthTexture = settings.supportsCameraDepthTexture || cameraData.isSceneViewCamera;
cameraData.requiresSoftParticles = settings.supportsSoftParticles;
cameraData.requiresOpaqueTexture = settings.supportsCameraOpaqueTexture;
cameraData.opaqueTextureDownsampling = settings.opaqueDownsampling;
bool anyShadowsEnabled = pipelineAsset.supportsDirectionalShadows || pipelineAsset.supportsLocalShadows;
cameraData.maxShadowDistance = (anyShadowsEnabled) ? pipelineAsset.shadowDistance : 0.0f;
bool anyShadowsEnabled = settings.supportsDirectionalShadows || settings.supportsLocalShadows;
cameraData.maxShadowDistance = (anyShadowsEnabled) ? settings.shadowDistance : 0.0f;
LightweightAdditionalCameraData additionalCameraData = camera.gameObject.GetComponent<LightweightAdditionalCameraData>();
if (additionalCameraData != null)

cameraData.requiresDepthTexture |= cameraData.postProcessEnabled;
}
void InitializeRenderingData(ref CameraData cameraData, List<VisibleLight> visibleLights, int maxSupportedLocalLightsPerPass, int maxSupportedVertexLights, out RenderingData renderingData)
static void InitializeRenderingData(PipelineSettings settings, ref CameraData cameraData,
List<VisibleLight> visibleLights, int maxSupportedLocalLightsPerPass, int maxSupportedVertexLights,
out RenderingData renderingData)
m_LocalLightIndices.Clear();
List<int> localLightIndices = new List<int>();
bool hasDirectionalShadowCastingLight = false;
bool hasLocalShadowCastingLight = false;

else
{
hasLocalShadowCastingLight |= castShadows;
m_LocalLightIndices.Add(i);
localLightIndices.Add(i);
InitializeLightData(visibleLights, maxSupportedLocalLightsPerPass, maxSupportedVertexLights, out renderingData.lightData);
InitializeShadowData(hasDirectionalShadowCastingLight, hasLocalShadowCastingLight, out renderingData.shadowData);
renderingData.supportsDynamicBatching = pipelineAsset.supportsDynamicBatching;
InitializeLightData(settings, visibleLights, maxSupportedLocalLightsPerPass, maxSupportedVertexLights, localLightIndices, out renderingData.lightData);
InitializeShadowData(settings, hasDirectionalShadowCastingLight, hasLocalShadowCastingLight, out renderingData.shadowData);
renderingData.supportsDynamicBatching = settings.supportsDynamicBatching;
void InitializeShadowData(bool hasDirectionalShadowCastingLight, bool hasLocalShadowCastingLight, out ShadowData shadowData)
static void InitializeShadowData(PipelineSettings settings, bool hasDirectionalShadowCastingLight, bool hasLocalShadowCastingLight, out ShadowData shadowData)
shadowData.renderDirectionalShadows = pipelineAsset.supportsDirectionalShadows && hasDirectionalShadowCastingLight;
shadowData.renderDirectionalShadows = settings.supportsDirectionalShadows && hasDirectionalShadowCastingLight;
shadowData.requiresScreenSpaceShadowResolve = shadowData.renderDirectionalShadows && supportsScreenSpaceShadows && pipelineAsset.cascadeCount > 1;
shadowData.directionalLightCascadeCount = (shadowData.requiresScreenSpaceShadowResolve) ? pipelineAsset.cascadeCount : 1;
shadowData.directionalShadowAtlasWidth = pipelineAsset.directionalShadowAtlasResolution;
shadowData.directionalShadowAtlasHeight = pipelineAsset.directionalShadowAtlasResolution;
shadowData.requiresScreenSpaceShadowResolve = shadowData.renderDirectionalShadows && supportsScreenSpaceShadows && settings.cascadeCount > 1;
shadowData.directionalLightCascadeCount = (shadowData.requiresScreenSpaceShadowResolve) ? settings.cascadeCount : 1;
shadowData.directionalShadowAtlasWidth = settings.directionalShadowAtlasResolution;
shadowData.directionalShadowAtlasHeight = settings.directionalShadowAtlasResolution;
switch (shadowData.directionalLightCascadeCount)
{

case 2:
shadowData.directionalLightCascades = new Vector3(pipelineAsset.cascade2Split, 1.0f, 0.0f);
shadowData.directionalLightCascades = new Vector3(settings.cascade2Split, 1.0f, 0.0f);
shadowData.directionalLightCascades = pipelineAsset.cascade4Split;
shadowData.directionalLightCascades = settings.cascade4Split;
shadowData.renderLocalShadows = pipelineAsset.supportsLocalShadows && hasLocalShadowCastingLight;
shadowData.localShadowAtlasWidth = shadowData.localShadowAtlasHeight = pipelineAsset.localShadowAtlasResolution;
shadowData.supportsSoftShadows = pipelineAsset.supportsSoftShadows;
shadowData.renderLocalShadows = settings.supportsLocalShadows && hasLocalShadowCastingLight;
shadowData.localShadowAtlasWidth = shadowData.localShadowAtlasHeight = settings.localShadowAtlasResolution;
shadowData.supportsSoftShadows = settings.supportsSoftShadows;
shadowData.bufferBitCount = 16;
shadowData.renderedDirectionalShadowQuality = LightShadows.None;

void InitializeLightData(List<VisibleLight> visibleLights, int maxSupportedLocalLightsPerPass, int maxSupportedVertexLights, out LightData lightData)
static void InitializeLightData(PipelineSettings settings, List<VisibleLight> visibleLights,
int maxSupportedLocalLightsPerPass, int maxSupportedVertexLights, List<int> localLightIndices, out LightData lightData)
int visibleLightsCount = Math.Min(visibleLights.Count, pipelineAsset.maxPixelLights);
lightData.mainLightIndex = GetMainLight(visibleLights);
int visibleLightsCount = Math.Min(visibleLights.Count, settings.maxPixelLights);
lightData.mainLightIndex = GetMainLight(settings, visibleLights);
int vertexLightCount = (pipelineAsset.supportsVertexLight) ? Math.Min(visibleLights.Count, maxSupportedLocalLightsPerPass) - additionalPixelLightsCount : 0;
int vertexLightCount = (settings.supportsVertexLight) ? Math.Min(visibleLights.Count, maxSupportedLocalLightsPerPass) - additionalPixelLightsCount : 0;
lightData.visibleLocalLightIndices = m_LocalLightIndices;
lightData.visibleLocalLightIndices = localLightIndices;
int GetMainLight(List<VisibleLight> visibleLights)
static int GetMainLight(PipelineSettings settings, List<VisibleLight> visibleLights)
if (totalVisibleLights == 0 || pipelineAsset.maxPixelLights == 0)
if (totalVisibleLights == 0 || settings.maxPixelLights == 0)
return -1;
for (int i = 0; i < totalVisibleLights; ++i)

return -1;
}
void SetupPerFrameShaderConstants()
static void SetupPerFrameShaderConstants()
{
// When glossy reflections are OFF in the shader we set a constant color to use as indirect specular
SphericalHarmonicsL2 ambientSH = RenderSettings.ambientProbe;

Shader.SetGlobalVector(PerFrameBuffer._SubtractiveShadowColor, CoreUtils.ConvertSRGBToActiveColorSpace(RenderSettings.subtractiveShadowColor));
}
void SetupPerCameraShaderConstants(CameraData cameraData)
static void SetupPerCameraShaderConstants(CameraData cameraData)
Camera camera = cameraData.camera;
Shader.SetGlobalVector(SetupLightweightConstanstPass.PerCameraBuffer._ScaledScreenParams, new Vector4(cameraWidth, cameraHeight, 1.0f + 1.0f / cameraWidth, 1.0f + 1.0f / cameraHeight));
Shader.SetGlobalVector(PerCameraBuffer._ScaledScreenParams, new Vector4(cameraWidth, cameraHeight, 1.0f + 1.0f / cameraWidth, 1.0f + 1.0f / cameraHeight));
Matrix4x4 projMatrix = GL.GetGPUProjectionMatrix(camera.projectionMatrix, false);
Matrix4x4 viewMatrix = camera.worldToCameraMatrix;
Matrix4x4 viewProjMatrix = projMatrix * viewMatrix;
Matrix4x4 invViewProjMatrix = Matrix4x4.Inverse(viewProjMatrix);
Shader.SetGlobalMatrix(PerCameraBuffer._InvCameraViewProj, invViewProjMatrix);
}
}
}

2
com.unity.render-pipelines.lightweight/LWRP/Passes/BeginXRRenderingPass.cs


{
public class BeginXRRenderingPass : ScriptableRenderPass
{
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

4
com.unity.render-pipelines.lightweight/LWRP/Passes/CopyColorPass.cs


this.destination = destination;
}
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

float opaqueScaler = m_OpaqueScalerValues[(int)downsampling];
RenderTextureDescriptor opaqueDesc = LightweightForwardRenderer.CreateRTDesc(ref renderingData.cameraData, opaqueScaler);
RenderTextureDescriptor opaqueDesc = ScriptableRenderer.CreateRTDesc(ref renderingData.cameraData, opaqueScaler);
RenderTargetIdentifier colorRT = source.Identifier();
RenderTargetIdentifier opaqueColorRT = destination.Identifier();

8
com.unity.render-pipelines.lightweight/LWRP/Passes/CopyDepthPass.cs


this.destination = destination;
}
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

Material depthCopyMaterial = renderer.GetMaterial(MaterialHandles.DepthCopy);
RenderTextureDescriptor descriptor = LightweightForwardRenderer.CreateRTDesc(ref renderingData.cameraData);
RenderTextureDescriptor descriptor = ScriptableRenderer.CreateRTDesc(ref renderingData.cameraData);
cmd.SetGlobalTexture("_CameraDepthAttachment", source.Identifier());
if (renderingData.cameraData.msaaSamples > 1)
{
cmd.DisableShaderKeyword(LightweightKeywordStrings.DepthNoMsaa);

4
com.unity.render-pipelines.lightweight/LWRP/Passes/CreateLightweightRenderTexturesPass.cs


descriptor = baseDescriptor;
}
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

var colorDescriptor = descriptor;
colorDescriptor.depthBufferBits = k_DepthStencilBufferBits; // TODO: does the color RT always need depth?
colorDescriptor.depthBufferBits = 0;
colorDescriptor.sRGB = true;
colorDescriptor.msaaSamples = (int) samples;
cmd.GetTemporaryRT(colorAttachmentHandle.id, colorDescriptor, FilterMode.Bilinear);

6
com.unity.render-pipelines.lightweight/LWRP/Passes/DepthOnlyPass.cs


int kDepthBufferBits = 32;
private RenderTargetHandle depthAttachmentHandle { get; set; }
private RenderTextureDescriptor descriptor { get; set; }
public FilterRenderersSettings opaqueFilterSettings { get; private set; }
internal RenderTextureDescriptor descriptor { get; set; }
private FilterRenderersSettings opaqueFilterSettings { get; set; }
public void Setup(
RenderTextureDescriptor baseDescriptor,

};
}
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

2
com.unity.render-pipelines.lightweight/LWRP/Passes/DirectionalShadowsPass.cs


this.destination = destination;
}
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

21
com.unity.render-pipelines.lightweight/LWRP/Passes/DrawSkyboxPass.cs


using UnityEngine.Rendering;
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
private RenderTargetHandle colorAttachmentHandle { get; set; }
private RenderTargetHandle depthAttachmentHandle { get; set; }
public void Setup(RenderTargetHandle colorHandle, RenderTargetHandle depthHandle)
{
this.colorAttachmentHandle = colorHandle;
this.depthAttachmentHandle = depthHandle;
}
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
CommandBuffer cmd = CommandBufferPool.Get("Draw Skybox (Set RT's)");
cmd.SetRenderTarget(colorAttachmentHandle.Identifier(), depthAttachmentHandle.Identifier());
context.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
}
}

2
com.unity.render-pipelines.lightweight/LWRP/Passes/EndXRRenderingPass.cs


{
public class EndXRRenderingPass : ScriptableRenderPass
{
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

2
com.unity.render-pipelines.lightweight/LWRP/Passes/FinalBlitPass.cs


this.descriptor = baseDescriptor;
}
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

14
com.unity.render-pipelines.lightweight/LWRP/Passes/LightweightForwardPass.cs


protected void SetRenderTarget(CommandBuffer cmd, RenderBufferLoadAction loadOp, RenderBufferStoreAction storeOp, ClearFlag clearFlag, Color clearColor)
{
if (colorAttachmentHandle != RenderTargetHandle.CameraTarget)
{
if (depthAttachmentHandle != RenderTargetHandle.CameraTarget)
SetRenderTarget(
SetRenderTarget(
cmd,
colorAttachmentHandle.Identifier(),
loadOp,

clearFlag,
clearColor,
descriptor.dimension);
else
SetRenderTarget(cmd, colorAttachmentHandle.Identifier(), loadOp, storeOp, clearFlag, clearColor, descriptor.dimension);
}
else
{
SetRenderTarget(cmd, BuiltinRenderTextureType.CameraTarget, loadOp, storeOp, clearFlag, clearColor, descriptor.dimension);
}
protected void RenderObjectsWithError(LightweightForwardRenderer renderer, ref ScriptableRenderContext context, ref CullResults cullResults, Camera camera, FilterRenderersSettings filterSettings, SortFlags sortFlags)
protected void RenderObjectsWithError(ScriptableRenderer renderer, ref ScriptableRenderContext context, ref CullResults cullResults, Camera camera, FilterRenderersSettings filterSettings, SortFlags sortFlags)
{
Material errorMaterial = renderer.GetMaterial(MaterialHandles.Error);
if (errorMaterial != null)

2
com.unity.render-pipelines.lightweight/LWRP/Passes/LocalShadowsPass.cs


}
}
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

2
com.unity.render-pipelines.lightweight/LWRP/Passes/OpaquePostProcessPass.cs


descriptor = baseDescriptor;
}
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

2
com.unity.render-pipelines.lightweight/LWRP/Passes/RenderOpaqueForwardPass.cs


};
}
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

2
com.unity.render-pipelines.lightweight/LWRP/Passes/RenderTransparentForwardPass.cs


};
}
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

2
com.unity.render-pipelines.lightweight/LWRP/Passes/SceneViewDepthCopy.cs


this.source = source;
}
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

2
com.unity.render-pipelines.lightweight/LWRP/Passes/ScreenSpaceShadowResolvePass.cs


descriptor = baseDescriptor;
}
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

2
com.unity.render-pipelines.lightweight/LWRP/Passes/ScriptableRenderPass.cs


public virtual void FrameCleanup(CommandBuffer cmd)
{}
public abstract void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public abstract void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData);

2
com.unity.render-pipelines.lightweight/LWRP/Passes/SetupForwardRenderingPass.cs


{
public class SetupForwardRenderingPass : ScriptableRenderPass
{
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

50
com.unity.render-pipelines.lightweight/LWRP/Passes/SetupLightweightConstanstPass.cs


{
public class SetupLightweightConstanstPass : ScriptableRenderPass
{
public static class PerCameraBuffer
public static class LightConstantBuffer
{
public static int _MainLightPosition;
public static int _MainLightColor;

public static int _AdditionalLightSpotAttenuation;
public static int _LightIndexBuffer;
public static int _ScaledScreenParams;
}
MixedLightingSetup m_MixedLightingSetup;

public SetupLightweightConstanstPass()
{
PerCameraBuffer._MainLightPosition = Shader.PropertyToID("_MainLightPosition");
PerCameraBuffer._MainLightColor = Shader.PropertyToID("_MainLightColor");
PerCameraBuffer._MainLightCookie = Shader.PropertyToID("_MainLightCookie");
PerCameraBuffer._WorldToLight = Shader.PropertyToID("_WorldToLight");
PerCameraBuffer._AdditionalLightCount = Shader.PropertyToID("_AdditionalLightCount");
PerCameraBuffer._AdditionalLightPosition = Shader.PropertyToID("_AdditionalLightPosition");
PerCameraBuffer._AdditionalLightColor = Shader.PropertyToID("_AdditionalLightColor");
PerCameraBuffer._AdditionalLightDistanceAttenuation = Shader.PropertyToID("_AdditionalLightDistanceAttenuation");
PerCameraBuffer._AdditionalLightSpotDir = Shader.PropertyToID("_AdditionalLightSpotDir");
PerCameraBuffer._AdditionalLightSpotAttenuation = Shader.PropertyToID("_AdditionalLightSpotAttenuation");
PerCameraBuffer._LightIndexBuffer = Shader.PropertyToID("_LightIndexBuffer");
LightConstantBuffer._MainLightPosition = Shader.PropertyToID("_MainLightPosition");
LightConstantBuffer._MainLightColor = Shader.PropertyToID("_MainLightColor");
LightConstantBuffer._MainLightCookie = Shader.PropertyToID("_MainLightCookie");
LightConstantBuffer._WorldToLight = Shader.PropertyToID("_WorldToLight");
LightConstantBuffer._AdditionalLightCount = Shader.PropertyToID("_AdditionalLightCount");
LightConstantBuffer._AdditionalLightPosition = Shader.PropertyToID("_AdditionalLightPosition");
LightConstantBuffer._AdditionalLightColor = Shader.PropertyToID("_AdditionalLightColor");
LightConstantBuffer._AdditionalLightDistanceAttenuation = Shader.PropertyToID("_AdditionalLightDistanceAttenuation");
LightConstantBuffer._AdditionalLightSpotDir = Shader.PropertyToID("_AdditionalLightSpotDir");
LightConstantBuffer._AdditionalLightSpotAttenuation = Shader.PropertyToID("_AdditionalLightSpotAttenuation");
LightConstantBuffer._LightIndexBuffer = Shader.PropertyToID("_LightIndexBuffer");
m_LightPositions = new Vector4[0];
m_LightColors = new Vector4[0];

{
Matrix4x4 lightCookieMatrix;
LightweightPipeline.GetLightCookieMatrix(mainLight, out lightCookieMatrix);
cmd.SetGlobalTexture(PerCameraBuffer._MainLightCookie, mainLightRef.cookie);
cmd.SetGlobalMatrix(PerCameraBuffer._WorldToLight, lightCookieMatrix);
cmd.SetGlobalTexture(LightConstantBuffer._MainLightCookie, mainLightRef.cookie);
cmd.SetGlobalMatrix(LightConstantBuffer._WorldToLight, lightCookieMatrix);
cmd.SetGlobalVector(PerCameraBuffer._MainLightPosition, new Vector4(lightPos.x, lightPos.y, lightPos.z, lightDistanceAttenuation.w));
cmd.SetGlobalVector(PerCameraBuffer._MainLightColor, lightColor);
cmd.SetGlobalVector(LightConstantBuffer._MainLightPosition, new Vector4(lightPos.x, lightPos.y, lightPos.z, lightDistanceAttenuation.w));
cmd.SetGlobalVector(LightConstantBuffer._MainLightColor, lightColor);
}
void SetupAdditionalLightConstants(CommandBuffer cmd, ref LightData lightData)

}
}
cmd.SetGlobalVector(PerCameraBuffer._AdditionalLightCount, new Vector4(lightData.pixelAdditionalLightsCount,
cmd.SetGlobalVector(LightConstantBuffer._AdditionalLightCount, new Vector4(lightData.pixelAdditionalLightsCount,
lightData.totalAdditionalLightsCount, 0.0f, 0.0f));
// if not using a compute buffer, engine will set indices in 2 vec4 constants

}
else
{
cmd.SetGlobalVector(PerCameraBuffer._AdditionalLightCount, Vector4.zero);
cmd.SetGlobalVector(LightConstantBuffer._AdditionalLightCount, Vector4.zero);
cmd.SetGlobalVectorArray(PerCameraBuffer._AdditionalLightPosition, m_LightPositions);
cmd.SetGlobalVectorArray(PerCameraBuffer._AdditionalLightColor, m_LightColors);
cmd.SetGlobalVectorArray(PerCameraBuffer._AdditionalLightDistanceAttenuation, m_LightDistanceAttenuations);
cmd.SetGlobalVectorArray(PerCameraBuffer._AdditionalLightSpotDir, m_LightSpotDirections);
cmd.SetGlobalVectorArray(PerCameraBuffer._AdditionalLightSpotAttenuation, m_LightSpotAttenuations);
cmd.SetGlobalVectorArray(LightConstantBuffer._AdditionalLightPosition, m_LightPositions);
cmd.SetGlobalVectorArray(LightConstantBuffer._AdditionalLightColor, m_LightColors);
cmd.SetGlobalVectorArray(LightConstantBuffer._AdditionalLightDistanceAttenuation, m_LightDistanceAttenuations);
cmd.SetGlobalVectorArray(LightConstantBuffer._AdditionalLightSpotDir, m_LightSpotDirections);
cmd.SetGlobalVectorArray(LightConstantBuffer._AdditionalLightSpotAttenuation, m_LightSpotAttenuations);
}
void SetShaderKeywords(CommandBuffer cmd, ref CameraData cameraData, ref LightData lightData, ref ShadowData shadowData)

CoreUtils.SetKeyword(cmd, "SOFTPARTICLES_ON", cameraData.requiresSoftParticles);
}
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

10
com.unity.render-pipelines.lightweight/LWRP/Passes/TransparentPostProcessPass.cs


private RenderTargetHandle colorAttachmentHandle { get; set; }
private RenderTextureDescriptor descriptor { get; set; }
private PostProcessRenderContext postContext { get; set; }
private RenderTargetIdentifier destination { get; set; }
RenderTargetHandle colorAttachmentHandle)
RenderTargetHandle colorAttachmentHandle,
RenderTargetIdentifier destination)
this.destination = destination;
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
LightweightPipeline.RenderPostProcess(cmd, postContext, ref renderingData.cameraData, descriptor.colorFormat, colorAttachmentHandle.Identifier(), BuiltinRenderTextureType.CameraTarget, false);
LightweightPipeline.RenderPostProcess(cmd, postContext, ref renderingData.cameraData, descriptor.colorFormat, colorAttachmentHandle.Identifier(), destination, false);
context.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
}

15
com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/Core.hlsl


#define UNITY_Z_0_FAR_FROM_CLIPSPACE(coord) (coord)
#endif
// TODO: Really need a better define for iOS Metal than the framebuffer fetch one, that's also enabled on android and webgl (???)
#if defined(SHADER_API_VULKAN) || (defined(SHADER_API_METAL) && defined(UNITY_FRAMEBUFFER_FETCH_AVAILABLE))
// Renderpass inputs: Vulkan/Metal subpass input
#define UNITY_DECLARE_FRAMEBUFFER_INPUT_FLOAT(idx) cbuffer hlslcc_SubpassInput_f_##idx { float4 hlslcc_fbinput_##idx; }
#define UNITY_DECLARE_FRAMEBUFFER_INPUT_HALF(idx) cbuffer hlslcc_SubpassInput_h_##idx { half4 hlslcc_fbinput_##idx; }
#define UNITY_READ_FRAMEBUFFER_INPUT(idx, v2fname) hlslcc_fbinput_##idx
#else
// Renderpass inputs: General fallback path
#define UNITY_DECLARE_FRAMEBUFFER_INPUT_FLOAT(idx) TEXTURE2D_FLOAT(_UnityFBInput##idx); float4 _UnityFBInput##idx##_TexelSize
#define UNITY_DECLARE_FRAMEBUFFER_INPUT_HALF(idx) TEXTURE2D_HALF(_UnityFBInput##idx); float4 _UnityFBInput##idx##_TexelSize
#define UNITY_READ_FRAMEBUFFER_INPUT(idx, v2fvertexname) _UnityFBInput##idx.Load(uint3(v2fvertexname.xy, 0))
#endif
float4 GetScaledScreenParams()
{
return _ScaledScreenParams;

9
com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/Input.hlsl


CBUFFER_END
CBUFFER_START(_PerCamera)
float4x4 _InvCameraViewProj;
float4 _ScaledScreenParams;
CBUFFER_END
CBUFFER_START(_LightBuffer)
float4 _MainLightPosition;
half4 _MainLightColor;
float4x4 _WorldToLight;

half4 _AdditionalLightDistanceAttenuation[MAX_VISIBLE_LIGHTS];
half4 _AdditionalLightSpotDir[MAX_VISIBLE_LIGHTS];
half4 _AdditionalLightSpotAttenuation[MAX_VISIBLE_LIGHTS];
float4 _ScaledScreenParams;
CBUFFER_END
#if USE_STRUCTURED_BUFFER_FOR_LIGHT_DATA

#define UNITY_MATRIX_P OptimizeProjectionMatrix(glstate_matrix_projection)
#define UNITY_MATRIX_I_P ERROR_UNITY_MATRIX_I_P_IS_NOT_DEFINED
#define UNITY_MATRIX_VP unity_MatrixVP
#define UNITY_MATRIX_I_VP ERROR_UNITY_MATRIX_I_VP_IS_NOT_DEFINED
#define UNITY_MATRIX_I_VP _InvCameraViewProj
#define UNITY_MATRIX_MV mul(UNITY_MATRIX_V, UNITY_MATRIX_M)
#define UNITY_MATRIX_T_MV transpose(UNITY_MATRIX_MV)
#define UNITY_MATRIX_IT_MV transpose(mul(UNITY_MATRIX_I_M, UNITY_MATRIX_I_V))

2
com.unity.render-pipelines.lightweight/LWRP/ScriptableRenderer.cs.meta


fileFormatVersion: 2
guid: 83797c942458af1439f0f02f681ee8c9
guid: f0f3c3678ea96e34f97aa3e4a1503a22
MonoImporter:
externalObjects: {}
serializedVersion: 2

15
com.unity.render-pipelines.lightweight/LWRP/ScriptableRenderer.cs


namespace UnityEngine.Experimental.Rendering.LightweightPipeline
{
public class LightweightForwardRenderer
public class ScriptableRenderer
{
// Lights are culled per-object. In platforms that don't use StructuredBuffer
// the engine will set 4 light indices in the following constant unity_4LightIndices0

readonly Material[] m_Materials;
public LightweightForwardRenderer(LightweightPipelineAsset pipelineAsset)
public ScriptableRenderer(LightweightPipelineAsset pipelineAsset)
this.pipelineAsset = pipelineAsset;
m_Materials = new[]
{
CoreUtils.CreateEngineMaterial("Hidden/InternalErrorShader"),

postProcessRenderContext = new PostProcessRenderContext();
}
public LightweightPipelineAsset pipelineAsset { get; private set; }
public void Dispose()
{

desc.colorFormat = cameraData.isHdrEnabled ? RenderTextureFormat.DefaultHDR :
RenderTextureFormat.Default;
desc.enableRandomWrite = false;
desc.sRGB = true;
public void Execute(ref ScriptableRenderContext context, ref CullResults cullResults, ref RenderingData renderingData)
{

m_ActiveRenderPassQueue.Add(pass);
}
public static bool RequiresIntermediateColorTexture(ref CameraData cameraData, RenderTextureDescriptor baseDescriptor, bool requiresCameraDepth)
public static bool RequiresIntermediateColorTexture(ref CameraData cameraData, RenderTextureDescriptor baseDescriptor)
{
if (cameraData.isOffscreenRender)
return false;

return requiresCameraDepth || cameraData.isSceneViewCamera || isScaledRender || cameraData.isHdrEnabled ||
return cameraData.isSceneViewCamera || isScaledRender || cameraData.isHdrEnabled ||
cameraData.postProcessEnabled || cameraData.requiresOpaqueTexture || isTargetTexture2DArray || !cameraData.isDefaultViewport;
}

26
com.unity.testing.srp.lightweight/Tests/Scenes/028_PostProcessing_Custom/Scripts/InvertOpaque.cs


[Serializable]
[PostProcess(typeof(InvertOpaqueRenderer), PostProcessEvent.BeforeTransparent, "Custom/LWtest/Invert Opaque")]
public sealed class InvertOpaque : PostProcessEffectSettings {
public BoolParameter enable = new BoolParameter();
}
public sealed class InvertOpaque : PostProcessEffectSettings
{}
public sealed class InvertOpaqueRenderer : PostProcessEffectRenderer<InvertOpaque> {
public sealed class InvertOpaqueRenderer : PostProcessEffectRenderer<InvertOpaque>
{
internal static readonly int opaqueTemp = Shader.PropertyToID("_MainTex");
context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, 0);
bool srcEqualsDest = context.destination == context.source;
if(srcEqualsDest)
context.GetScreenSpaceTemporaryRT(context.command, opaqueTemp);
context.command.BlitFullscreenTriangle(context.source, srcEqualsDest ? opaqueTemp : context.destination, sheet, 0);
if (srcEqualsDest)
{
context.command.BlitFullscreenTriangle(opaqueTemp, context.destination);
context.command.ReleaseTemporaryRT(opaqueTemp);
}
}
}

8
com.unity.testing.srp.lightweight/Tests/Scenes/045_CustomLWPipe/CustomLWPipe.cs


m_Initialized = true;
}
public void Setup(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public void Setup(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults, ref RenderingData renderingData)
{
Init();

renderer.SetupPerObjectLightIndices(ref cullResults, ref renderingData.lightData);
RenderTextureDescriptor baseDescriptor = LightweightForwardRenderer.CreateRTDesc(ref renderingData.cameraData);
RenderTextureDescriptor baseDescriptor = ScriptableRenderer.CreateRTDesc(ref renderingData.cameraData);
RenderTextureDescriptor shadowDescriptor = baseDescriptor;
shadowDescriptor.dimension = TextureDimension.Tex2D;

Camera camera = renderingData.cameraData.camera;
bool dynamicBatching = renderingData.supportsDynamicBatching;
RendererConfiguration rendererConfiguration = LightweightForwardRenderer.GetRendererConfiguration(renderingData.lightData.totalAdditionalLightsCount);
RendererConfiguration rendererConfiguration = ScriptableRenderer.GetRendererConfiguration(renderingData.lightData.totalAdditionalLightsCount);
m_RenderOpaqueForwardPass.Setup(baseDescriptor, colorHandle, depthHandle, LightweightForwardRenderer.GetCameraClearFlag(camera), camera.backgroundColor, rendererConfiguration, dynamicBatching);
m_RenderOpaqueForwardPass.Setup(baseDescriptor, colorHandle, depthHandle, ScriptableRenderer.GetCameraClearFlag(camera), camera.backgroundColor, rendererConfiguration, dynamicBatching);
renderer.EnqueuePass(m_RenderOpaqueForwardPass);
}
}

447
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1213_Lit_Anisotropy.unity


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.13314511, g: 0.18438525, b: 0.2460813, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 11
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_TemporalCoherenceThreshold: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
m_LightmapEditorSettings:
serializedVersion: 10
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 500
m_PVRBounces: 2
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVRFilteringMode: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ShowResolutionOverlay: 1
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1001 &150555373
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 4209882255362944, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
propertyPath: m_LocalPosition.x
value: -6.237743
objectReference: {fileID: 0}
- target: {fileID: 4209882255362944, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
propertyPath: m_LocalPosition.y
value: 10.1327915
objectReference: {fileID: 0}
- target: {fileID: 4209882255362944, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
propertyPath: m_LocalPosition.z
value: -11.384525
objectReference: {fileID: 0}
- target: {fileID: 4209882255362944, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
propertyPath: m_LocalRotation.x
value: -0.26558536
objectReference: {fileID: 0}
- target: {fileID: 4209882255362944, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
propertyPath: m_LocalRotation.y
value: -0.0023166116
objectReference: {fileID: 0}
- target: {fileID: 4209882255362944, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
propertyPath: m_LocalRotation.z
value: 0.0006380343
objectReference: {fileID: 0}
- target: {fileID: 4209882255362944, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
propertyPath: m_LocalRotation.w
value: -0.9640844
objectReference: {fileID: 0}
- target: {fileID: 4209882255362944, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4209882255362944, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 90.00001
objectReference: {fileID: 0}
- target: {fileID: 4209882255362944, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4209882255362944, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1132393308280272, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
propertyPath: m_Name
value: HDRP_Test_Camera
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3}
--- !u!1 &760537692
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 760537696}
- component: {fileID: 760537695}
- component: {fileID: 760537694}
- component: {fileID: 760537693}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &760537693
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 760537692}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c6c2871f720b2af4e9210febdac74517, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Version: 1
shadowResolution: 512
shadowDimmer: 1
shadowFadeDistance: 10000
contactShadows: 0
viewBiasMin: 0.2
viewBiasMax: 100
viewBiasScale: 1
normalBiasMin: 0.5
normalBiasMax: 0.5
normalBiasScale: 1
sampleBiasScale: 0
edgeLeakFixup: 1
edgeToleranceNormal: 1
edgeTolerance: 1
shadowCascadeCount: 4
shadowCascadeRatios:
- 0.05
- 0.2
- 0.3
shadowCascadeBorders:
- 0.2
- 0.2
- 0.2
- 0.2
shadowAlgorithm: 0
shadowVariant: 0
shadowPrecision: 0
shadowData:
format: 0
data:
shadowDatas: []
--- !u!114 &760537694
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 760537692}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7a68c43fe1f2a47cfa234b5eeaa98012, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 2
m_Version: 2
directionalIntensity: 3.1415927
punctualIntensity: 600
areaIntensity: 200
enableSpotReflector: 0
m_InnerSpotPercent: 0
lightDimmer: 1
volumetricDimmer: 1
lightUnit: 2
fadeDistance: 10000
affectDiffuse: 1
affectSpecular: 1
nonLightmappedOnly: 0
lightTypeExtent: 0
spotLightShape: 0
shapeWidth: 0.5
shapeHeight: 0.5
aspectRatio: 1
shapeRadius: 0
maxSmoothness: 1
applyRangeAttenuation: 1
useOldInspector: 0
featuresFoldout: 1
showAdditionalSettings: 0
displayLightIntensity: 3.1415927
displayAreaLightEmissiveMesh: 0
lightLayers: 1
--- !u!108 &760537695
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 760537692}
m_Enabled: 1
serializedVersion: 8
m_Type: 1
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Intensity: 3.1415927
m_Range: 10
m_SpotAngle: 30
m_CookieSize: 10
m_Shadows:
m_Type: 0
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_Lightmapping: 4
m_LightShadowCasterMode: 2
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &760537696
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 760537692}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 1.3850813, y: 10.78, z: -0.414073}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &2109457463
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2109457466}
- component: {fileID: 2109457465}
- component: {fileID: 2109457464}
m_Layer: 0
m_Name: Scene Settings
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &2109457464
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2109457463}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 441482e8936e35048a1dffac814e3ef8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Profile: {fileID: 11400000, guid: 877ee5097ab34a94b92316009a8295a0, type: 2}
m_BakingSkyUniqueID: 2
--- !u!114 &2109457465
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2109457463}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 172515602e62fb746b5d573b38a5fe58, type: 3}
m_Name:
m_EditorClassIdentifier:
isGlobal: 1
priority: 0
blendDistance: 0
weight: 1
sharedProfile: {fileID: 11400000, guid: 877ee5097ab34a94b92316009a8295a0, type: 2}
--- !u!4 &2109457466
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2109457463}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1275563729146576701
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 6880039408237096682, guid: 128b2cbeebc1c094e81e9bb209c5967b, type: 3}
propertyPath: m_LocalPosition.x
value: -6.381103
objectReference: {fileID: 0}
- target: {fileID: 6880039408237096682, guid: 128b2cbeebc1c094e81e9bb209c5967b, type: 3}
propertyPath: m_LocalPosition.y
value: 5.229407
objectReference: {fileID: 0}
- target: {fileID: 6880039408237096682, guid: 128b2cbeebc1c094e81e9bb209c5967b, type: 3}
propertyPath: m_LocalPosition.z
value: -0.72239685
objectReference: {fileID: 0}
- target: {fileID: 6880039408237096682, guid: 128b2cbeebc1c094e81e9bb209c5967b, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6880039408237096682, guid: 128b2cbeebc1c094e81e9bb209c5967b, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6880039408237096682, guid: 128b2cbeebc1c094e81e9bb209c5967b, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6880039408237096682, guid: 128b2cbeebc1c094e81e9bb209c5967b, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6880039408237096682, guid: 128b2cbeebc1c094e81e9bb209c5967b, type: 3}
propertyPath: m_RootOrder
value: 3
objectReference: {fileID: 0}
- target: {fileID: 6880039408237096682, guid: 128b2cbeebc1c094e81e9bb209c5967b, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6880039408237096682, guid: 128b2cbeebc1c094e81e9bb209c5967b, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6880039408237096682, guid: 128b2cbeebc1c094e81e9bb209c5967b, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 331744688631616955, guid: 128b2cbeebc1c094e81e9bb209c5967b, type: 3}
propertyPath: m_Name
value: SphereGroups
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 128b2cbeebc1c094e81e9bb209c5967b, type: 3}

7
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1213_Lit_Anisotropy.unity.meta


fileFormatVersion: 2
guid: e0ebb398c814c2645af130d8b2e6b9aa
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/1x_Materials/1213_Lit_anisotropy.meta


fileFormatVersion: 2
guid: 8bc3ee3419898e94f9395f4d95281855
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

1001
TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/1213_Lit_Anisotropy.png
文件差异内容过多而无法显示
查看文件

88
TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/1213_Lit_Anisotropy.png.meta


fileFormatVersion: 2
guid: bd8831e1f55353a41b290e481bffc7a8
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 7
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 1
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

23
com.unity.render-pipelines.core/CoreRP/Editor/SettingsDisableScope.cs


using System;
using UnityEngine;
namespace UnityEditor.Experimental.Rendering
{
public class SettingsDisableScope : IDisposable
{
bool enable;
public SettingsDisableScope(bool enable)
{
this.enable = enable;
if (!enable)
GUI.enabled = false;
}
public void Dispose()
{
if (!enable)
GUI.enabled = true;
}
}
}

11
com.unity.render-pipelines.core/CoreRP/Editor/SettingsDisableScope.cs.meta


fileFormatVersion: 2
guid: b066eb8bfc3d4cd4a8181437643343d2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

80
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeEditor.cs


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);
}
}
}

11
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeEditor.cs.meta


fileFormatVersion: 2
guid: 7f189b572cf7bf04d9f1976dcc75c942
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

45
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.ContextualMenu.cs


using System.IO;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
partial class HDProbeUI
{
[MenuItem("GameObject/3D Object/Mirror", priority = CoreUtils.gameObjectMenuPriority)]
static void CreateMirrorGameObject(MenuCommand menuCommand)
{
GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
GameObjectUtility.SetParentAndAlign(plane, menuCommand.context as GameObject);
Undo.RegisterCreatedObjectUndo(plane, "Create " + plane.name);
Selection.activeObject = plane;
var planarProbe = plane.AddComponent<PlanarReflectionProbe>();
planarProbe.influenceVolume.boxSize = new Vector3(10, 0.01f, 10);
var hdrp = GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset;
var material = hdrp != null ? hdrp.GetDefaultMirrorMaterial() : null;
if (material)
{
plane.GetComponent<MeshRenderer>().sharedMaterial = material;
}
}
[MenuItem("GameObject/Light/Planar Reflection Probe", priority = CoreUtils.gameObjectMenuPriority)]
static void CreatePlanarReflectionGameObject(MenuCommand menuCommand)
{
var parent = menuCommand.context as GameObject;
var go = CoreEditorUtils.CreateGameObject(parent, "Planar Reflection");
var planarProbe = go.AddComponent<PlanarReflectionProbe>();
planarProbe.influenceVolume.boxSize = new Vector3(1, 0.01f, 1);
// Ensure it gets re-parented if this was a context click (otherwise does nothing)
GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
// Register the creation in the undo system
Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
Selection.activeObject = go;
}
}
}

11
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.ContextualMenu.cs.meta


fileFormatVersion: 2
guid: f9ddf94c77394c14986865eb30c51d79
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

304
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Drawers.cs


using System;
using System.Collections.Generic;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
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)
{
var hdPipeline = RenderPipelineManager.currentPipeline as HDRenderPipeline;
using (new SettingsDisableScope(hdPipeline.asset.renderPipelineSettings.supportLightLayers))
{
d.lightLayers.intValue = Convert.ToInt32(EditorGUILayout.EnumFlagsField(lightLayersContent, (LightLayerEnum)d.lightLayers.intValue));
}
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();
}
}
}
}

11
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Drawers.cs.meta


fileFormatVersion: 2
guid: ce4764ad508471d498f39a66388bb18d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

101
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Handles.cs


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);
}
}
}

11
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Handles.cs.meta


fileFormatVersion: 2
guid: 8ee668677cd59784d8fb06a531b49a77
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

80
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Skin.cs


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 lightLayersContent = CoreEditorUtils.GetContent("Light Layers|Specifies the current light layers that the light affect. Corresponding renderer with the same flags will be lit by this light.");
//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.") }
});
}
}
}
}

11
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Skin.cs.meta


fileFormatVersion: 2
guid: 43443fcbe23ff044eb73250a6d34cedd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

90
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.cs


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();
}
}
}

11
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.cs.meta


fileFormatVersion: 2
guid: f23cf1efede7335468bfa23bd1838cd2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

61
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDProbe.cs


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 lightLayers;
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));
lightLayers = serializedObject.Find((HDProbe p) => p.lightLayers);
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();
}
}
}

11
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDProbe.cs.meta


fileFormatVersion: 2
guid: fe06aab2f0da27148b61819e1ce565a1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

36
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Skin.cs


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";
}
}

部分文件因为文件数量过多而无法显示

正在加载...
取消
保存