Skip to content

Commit 9b36cec

Browse files
Merge branch 'master' into Branch_DebugShadows
# Conflicts: # Assets/ScriptableRenderLoop/HDRenderPipeline/Editor/HDRenderPipelineInspector.cs # Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs # Assets/ScriptableRenderLoop/RenderPasses/ShadowRenderPass.cs
2 parents c134365 + c61958f commit 9b36cec

158 files changed

Lines changed: 6983 additions & 2014 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Assets/BasicRenderLoopTutorial/BasicRenderLoop.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ static void CreateBasicRenderLoop()
2121
var instance = ScriptableObject.CreateInstance<BasicRenderLoop>();
2222
UnityEditor.AssetDatabase.CreateAsset(instance, "Assets/BasicRenderLoopTutorial/BasicRenderLoop.asset");
2323
}
24+
2425
#endif
2526

2627
protected override IRenderPipeline InternalCreatePipeline()
@@ -31,7 +32,6 @@ protected override IRenderPipeline InternalCreatePipeline()
3132

3233
public class BasicRenderLoopInstance : RenderPipeline
3334
{
34-
3535
public override void Render(ScriptableRenderContext renderContext, Camera[] cameras)
3636
{
3737
base.Render(renderContext, cameras);
@@ -70,21 +70,20 @@ public static void Render(ScriptableRenderContext context, IEnumerable<Camera> c
7070
var settings = new DrawRendererSettings(cull, camera, new ShaderPassName("BasicPass"));
7171
settings.sorting.flags = SortFlags.CommonOpaque;
7272
settings.inputFilter.SetQueuesOpaque();
73-
context.DrawRenderers(ref settings);
73+
context.DrawRenderers(settings);
7474

7575
// Draw skybox
7676
context.DrawSkybox(camera);
7777

7878
// Draw transparent objects using BasicPass shader pass
7979
settings.sorting.flags = SortFlags.CommonTransparent;
8080
settings.inputFilter.SetQueuesTransparent();
81-
context.DrawRenderers(ref settings);
81+
context.DrawRenderers(settings);
8282

8383
context.Submit();
8484
}
8585
}
8686

87-
8887
// Setup lighting variables for shader to use
8988

9089
private static void SetupLightShaderVariables(VisibleLight[] lights, ScriptableRenderContext context)
@@ -171,7 +170,6 @@ private static void SetupLightShaderVariables(VisibleLight[] lights, ScriptableR
171170
cmd.Dispose();
172171
}
173172

174-
175173
// Prepare L2 spherical harmonics values for efficient evaluation in a shader
176174

177175
private static void GetShaderConstantsFromNormalizedSH(ref SphericalHarmonicsL2 ambientProbe, Vector4[] outCoefficients)

Assets/Editor/Tests/RenderloopTests/RenderloopTestFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static void Run(TestDelegate renderCallback)
5353
var sceneCamera = Camera.main;
5454
var camObject = sceneCamera.gameObject;
5555

56-
GraphicsSettings.renderPipeline = m_Instance;
56+
GraphicsSettings.renderPipelineAsset = m_Instance;
5757
s_Callback = renderCallback;
5858
Transform t = camObject.transform;
5959

@@ -64,6 +64,6 @@ public static void Run(TestDelegate renderCallback)
6464
SceneView.lastActiveSceneView.LookAtDirect(t.position + t.forward * camDist, t.rotation, size);
6565

6666
sceneCamera.Render();
67-
GraphicsSettings.renderPipeline = null;
67+
GraphicsSettings.renderPipelineAsset = null;
6868
}
6969
}

Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugViewMaterialGBuffer.shader

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Shader "Hidden/HDRenderPipeline/DebugViewMaterialGBuffer"
99

1010
HLSLPROGRAM
1111
#pragma target 4.5
12-
#pragma only_renderers d3d11 ps4 metal // TEMP: unitl we go futher in dev
12+
#pragma only_renderers d3d11 ps4 metal // TEMP: until we go further in dev
1313

1414
#pragma vertex Vert
1515
#pragma fragment Frag

Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugViewTiles.shader

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ Shader "Hidden/HDRenderPipeline/DebugViewTiles"
1010

1111
HLSLPROGRAM
1212
#pragma target 4.5
13-
#pragma only_renderers d3d11 ps4 metal // TEMP: unitl we go futher in dev
13+
#pragma only_renderers d3d11 ps4 metal // TEMP: until we go further in dev
1414

1515
#pragma vertex Vert
1616
#pragma fragment Frag
1717

18-
#define LIGHTLOOP_TILE_PASS 1
19-
#define LIGHTLOOP_TILE_ALL 1
18+
#define LIGHTLOOP_TILE_PASS
19+
#define LIGHTLOOP_TILE_ALL
2020

2121
#pragma multi_compile USE_FPTL_LIGHTLIST USE_CLUSTERED_LIGHTLIST
2222

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &11400000
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 0
6+
m_PrefabParentObject: {fileID: 0}
7+
m_PrefabInternal: {fileID: 0}
8+
m_GameObject: {fileID: 0}
9+
m_Enabled: 1
10+
m_EditorHideFlags: 0
11+
m_Script: {fileID: 11500000, guid: bc357c46587fc9d4cb8f311794d7d2f3, type: 3}
12+
m_Name: DefaultCommonSettings
13+
m_EditorClassIdentifier:
14+
m_Settings:
15+
m_ShadowMaxDistance: 1000
16+
m_ShadowCascadeCount: 4
17+
m_ShadowCascadeSplit0: 0.05
18+
m_ShadowCascadeSplit1: 0.2
19+
m_ShadowCascadeSplit2: 0.3
20+
m_SssProfileStdDev1: {r: 0.3, g: 0.3, b: 0.3, a: 0}
21+
m_SssProfileStdDev2: {r: 1, g: 1, b: 1, a: 0}
22+
m_SssProfileLerpWeight: 0.5
23+
m_SssBilateralScale: 0.1

Assets/ScriptableRenderLoop/HDRenderPipeline/DefaultCommonSettings.asset.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using UnityEngine.Experimental.Rendering.HDPipeline;
2+
using UnityEngine;
3+
4+
namespace UnityEditor.Experimental.Rendering.HDPipeline
5+
{
6+
public class HDRenderPipeWindow : EditorWindow
7+
{
8+
[MenuItem("HDRenderPipeline/Configure Overrides")]
9+
static void ConfigureOverrides()
10+
{
11+
GetWindow<HDRenderPipeWindow>().Show();
12+
}
13+
14+
void OnGUI()
15+
{
16+
CommonSettingsSingleton.overrideSettings = (CommonSettings)EditorGUILayout.ObjectField(new GUIContent("Common Settings"), CommonSettingsSingleton.overrideSettings, typeof(CommonSettings), false);
17+
SkyParametersSingleton.overrideSettings = (SkyParameters)EditorGUILayout.ObjectField(new GUIContent("Sky Settings"), SkyParametersSingleton.overrideSettings, typeof(SkyParameters), false);
18+
19+
if (GUILayout.Button("Create new common settings"))
20+
{
21+
var instance = CreateInstance<CommonSettings>();
22+
AssetDatabase.CreateAsset(instance, "Assets/NewCommonSettings.asset");
23+
}
24+
25+
if (GUILayout.Button("Create new HDRI sky params"))
26+
{
27+
var instance = CreateInstance<HDRISkyParameters>();
28+
AssetDatabase.CreateAsset(instance, "Assets/NewHDRISkyParameters.asset");
29+
}
30+
31+
if (GUILayout.Button("Create new Procedural sky params"))
32+
{
33+
var instance = CreateInstance<ProceduralSkyParameters>();
34+
AssetDatabase.CreateAsset(instance, "Assets/NewProceduralSkyParameters.asset");
35+
}
36+
}
37+
}
38+
}

Assets/ScriptableRenderLoop/HDRenderPipeline/Editor/HDRenderPipeWindow.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/ScriptableRenderLoop/HDRenderPipeline/Editor/HDRenderPipelineInspector.cs

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Reflection;
23
using System.Linq.Expressions;
34
using UnityEditor;
45

@@ -29,14 +30,15 @@ private class Styles
2930
public GUIContent[] debugViewMaterialStrings = null;
3031
public int[] debugViewMaterialValues = null;
3132

33+
public readonly GUIContent skyParams = new GUIContent("Sky Settings");
34+
3235
// Shadow Debug
3336
public readonly GUIContent shadowDebugParameters = new GUIContent("Shadow Debug");
3437
public readonly GUIContent shadowDebugEnable = new GUIContent("Enable Shadows");
3538
public readonly GUIContent shadowDebugVisualizationMode = new GUIContent("Visualize");
3639
public readonly GUIContent shadowDebugVisualizeShadowIndex = new GUIContent("Visualize Shadow Index");
3740

3841
public readonly GUIContent shadowSettings = new GUIContent("Shadow Settings");
39-
4042
public readonly GUIContent shadowsAtlasWidth = new GUIContent("Atlas width");
4143
public readonly GUIContent shadowsAtlasHeight = new GUIContent("Atlas height");
4244

@@ -152,6 +154,14 @@ void FillWithPropertiesEnum(Type type, GUIContent[] debugViewMaterialStrings, in
152154
}
153155
}
154156

157+
static void HackSetDirty(RenderPipelineAsset asset)
158+
{
159+
EditorUtility.SetDirty(asset);
160+
var method = typeof(RenderPipelineAsset).GetMethod("OnValidate", BindingFlags.FlattenHierarchy | BindingFlags.NonPublic | BindingFlags.Instance);
161+
if (method != null)
162+
method.Invoke(asset, new object[0]);
163+
}
164+
155165
private void DebuggingUI(HDRenderPipeline renderContext)
156166
{
157167
EditorGUILayout.LabelField(styles.debugging);
@@ -227,11 +237,28 @@ private void DebugParametersUI(HDRenderPipeline renderContext)
227237

228238
if (EditorGUI.EndChangeCheck())
229239
{
230-
EditorUtility.SetDirty(renderContext); // Repaint
240+
HackSetDirty(renderContext); // Repaint
231241
}
232242
EditorGUI.indentLevel--;
233243
}
234244

245+
private void SkySettingsUI(HDRenderPipeline pipe)
246+
{
247+
EditorGUILayout.Space();
248+
249+
EditorGUILayout.LabelField(styles.skyParams);
250+
EditorGUI.BeginChangeCheck();
251+
EditorGUI.indentLevel++;
252+
pipe.skyParameters = (SkyParameters) EditorGUILayout.ObjectField(new GUIContent("Sky Settings"), pipe.skyParameters, typeof(SkyParameters), false);
253+
pipe.lightLoopProducer = (LightLoopProducer) EditorGUILayout.ObjectField(new GUIContent("Light Loop"), pipe.lightLoopProducer, typeof(LightLoopProducer), false);
254+
EditorGUI.indentLevel--;
255+
256+
if (EditorGUI.EndChangeCheck())
257+
{
258+
HackSetDirty(pipe); // Repaint
259+
}
260+
}
261+
235262
private void ShadowDebugParametersUI(HDRenderPipeline renderContext)
236263
{
237264
m_ShowDebugShadow.boolValue = EditorGUILayout.Foldout(m_ShowDebugShadow.boolValue, styles.shadowDebugParameters);
@@ -245,7 +272,7 @@ private void ShadowDebugParametersUI(HDRenderPipeline renderContext)
245272
{
246273
if ((ShadowDebugMode)m_DebugShadowVisualizationMode.intValue == ShadowDebugMode.VisualizeShadowMap)
247274
{
248-
EditorGUILayout.IntSlider(m_DebugShadowVisualizeShadowIndex, 0, renderContext.GetCurrentShadowCount() - 1, styles.shadowDebugVisualizeShadowIndex);
275+
EditorGUILayout.IntSlider(m_DebugShadowVisualizeShadowIndex, 0, 5/*renderContext.GetCurrentShadowCount() - 1*/, styles.shadowDebugVisualizeShadowIndex);
249276
}
250277
}
251278
EditorGUI.indentLevel--;
@@ -265,7 +292,7 @@ private void ShadowParametersUI(HDRenderPipeline renderContext)
265292

266293
if (EditorGUI.EndChangeCheck())
267294
{
268-
EditorUtility.SetDirty(renderContext); // Repaint
295+
HackSetDirty(renderContext); // Repaint
269296
}
270297
EditorGUI.indentLevel--;
271298
}
@@ -286,17 +313,17 @@ private void TextureParametersUI(HDRenderPipeline renderContext)
286313
if (EditorGUI.EndChangeCheck())
287314
{
288315
renderContext.textureSettings = textureParameters;
289-
EditorUtility.SetDirty(renderContext); // Repaint
316+
HackSetDirty(renderContext); // Repaint
290317
}
291318
EditorGUI.indentLevel--;
292319
}
293320

294-
private void TilePassUI(HDRenderPipeline renderContext)
321+
/* private void TilePassUI(HDRenderPipeline renderContext)
295322
{
296323
EditorGUILayout.Space();
297324
298325
// TODO: we should call a virtual method or something similar to setup the UI, inspector should not know about it
299-
TilePass.LightLoop tilePass = renderContext.lightLoop as TilePass.LightLoop;
326+
var tilePass = renderContext.tileSettings;
300327
if (tilePass != null)
301328
{
302329
EditorGUILayout.LabelField(styles.tileLightLoopSettings);
@@ -308,7 +335,7 @@ private void TilePassUI(HDRenderPipeline renderContext)
308335
309336
if (EditorGUI.EndChangeCheck())
310337
{
311-
EditorUtility.SetDirty(renderContext); // Repaint
338+
HackSetDirty(renderContext); // Repaint
312339
313340
// SetAssetDirty will tell renderloop to rebuild
314341
renderContext.DestroyCreatedInstances();
@@ -323,12 +350,12 @@ private void TilePassUI(HDRenderPipeline renderContext)
323350
324351
if (EditorGUI.EndChangeCheck())
325352
{
326-
EditorUtility.SetDirty(renderContext); // Repaint
353+
HackSetDirty(renderContext); // Repaint
327354
UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
328355
}
329356
EditorGUI.indentLevel--;
330357
}
331-
}
358+
}*/
332359

333360
public void OnEnable()
334361
{
@@ -344,10 +371,11 @@ public override void OnInspectorGUI()
344371

345372
serializedObject.Update();
346373

374+
SkySettingsUI(renderContext);
347375
DebuggingUI(renderContext);
348376
ShadowParametersUI(renderContext);
349377
TextureParametersUI(renderContext);
350-
TilePassUI(renderContext);
378+
//TilePassUI(renderContext);
351379

352380
serializedObject.ApplyModifiedProperties();
353381
}

Assets/ScriptableRenderLoop/HDRenderPipeline/Editor/HDRenderPipelineMenuItems.cs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,17 @@
11
using UnityEngine;
2-
using UnityEngine.Experimental.Rendering.HDPipeline;
32

43
namespace UnityEditor.Experimental.Rendering.HDPipeline
54
{
65
public class HDRenderPipelineMenuItems
76
{
8-
[MenuItem("HDRenderPipeline/Create Scene Settings")]
9-
static void CreateSceneSettings()
10-
{
11-
CommonSettings[] settings = Object.FindObjectsOfType<CommonSettings>();
12-
13-
if (settings.Length == 0)
14-
{
15-
GameObject go = new GameObject { name = "SceneSettings" };
16-
go.AddComponent<CommonSettings>();
17-
go.AddComponent<PostProcessing>();
18-
}
19-
else
20-
{
21-
Debug.LogWarning("SceneSettings has already been created.");
22-
}
23-
}
24-
257
[MenuItem("HDRenderPipeline/Synchronize all Layered materials")]
268
static void SynchronizeAllLayeredMaterial()
279
{
2810
Object[] materials = Resources.FindObjectsOfTypeAll<Material>();
2911
foreach (Object obj in materials)
3012
{
3113
Material mat = obj as Material;
32-
if(mat.shader.name == "HDRenderLoop/LayeredLit")
14+
if (mat.shader.name == "HDRenderLoop/LayeredLit")
3315
{
3416
LayeredLitGUI.SynchronizeAllLayers(mat);
3517
}

0 commit comments

Comments
 (0)