Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Commit 5319de6

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/dof'
2 parents d600585 + c73f1d4 commit 5319de6

53 files changed

Lines changed: 1135 additions & 1291 deletions

Some content is hidden

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

PostProcessing/Editor/Models/AntialiasingModelEditor.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ public class AntialiasingModelEditor : PostProcessingModelEditor
1414
SerializedProperty m_FxaaPreset;
1515

1616
SerializedProperty m_TaaJitterSpread;
17-
SerializedProperty m_TaaSampleCount;
1817
SerializedProperty m_TaaSharpen;
1918
SerializedProperty m_TaaStationaryBlending;
2019
SerializedProperty m_TaaMotionBlending;
21-
SerializedProperty m_TaaQueue;
2220

2321
static string[] s_MethodNames =
2422
{
@@ -33,11 +31,9 @@ public override void OnEnable()
3331
m_FxaaPreset = FindSetting((Settings x) => x.fxaaSettings.preset);
3432

3533
m_TaaJitterSpread = FindSetting((Settings x) => x.taaSettings.jitterSpread);
36-
m_TaaSampleCount = FindSetting((Settings x) => x.taaSettings.sampleCount);
3734
m_TaaSharpen = FindSetting((Settings x) => x.taaSettings.sharpen);
3835
m_TaaStationaryBlending = FindSetting((Settings x) => x.taaSettings.stationaryBlending);
3936
m_TaaMotionBlending = FindSetting((Settings x) => x.taaSettings.motionBlending);
40-
m_TaaQueue = FindSetting((Settings x) => x.taaSettings.renderQueue);
4137
}
4238

4339
public override void OnInspectorGUI()
@@ -56,7 +52,6 @@ public override void OnInspectorGUI()
5652
EditorGUILayout.LabelField("Jitter", EditorStyles.boldLabel);
5753
EditorGUI.indentLevel++;
5854
EditorGUILayout.PropertyField(m_TaaJitterSpread, EditorGUIHelper.GetContent("Spread"));
59-
EditorGUILayout.PropertyField(m_TaaSampleCount);
6055
EditorGUI.indentLevel--;
6156

6257
EditorGUILayout.Space();
@@ -70,7 +65,6 @@ public override void OnInspectorGUI()
7065
EditorGUILayout.Space();
7166

7267
EditorGUILayout.PropertyField(m_TaaSharpen);
73-
EditorGUILayout.PropertyField(m_TaaQueue);
7468
}
7569
}
7670
}

PostProcessing/Editor/Models/ColorGradingModelEditor.cs

Lines changed: 159 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace UnityEditor.PostProcessing
88
{
99
using Settings = ColorGradingModel.Settings;
1010
using Tonemapper = ColorGradingModel.Tonemapper;
11+
using ColorWheelMode = ColorGradingModel.ColorWheelMode;
1112

1213
[PostProcessingModelEditor(typeof(ColorGradingModel))]
1314
public class ColorGradingModelEditor : PostProcessingModelEditor
@@ -48,6 +49,7 @@ struct ChannelMixerSettings
4849

4950
struct ColorWheelsSettings
5051
{
52+
public SerializedProperty mode;
5153
public SerializedProperty log;
5254
public SerializedProperty linear;
5355
}
@@ -89,6 +91,15 @@ struct CurvesSettings
8991
CurveEditor m_CurveEditor;
9092
Dictionary<SerializedProperty, Color> m_CurveDict;
9193

94+
// Neutral tonemapping curve helper
95+
const int k_CurveResolution = 24;
96+
const float k_NeutralRangeX = 2f;
97+
const float k_NeutralRangeY = 1f;
98+
Vector3[] m_RectVertices = new Vector3[4];
99+
Vector3[] m_LineVertices = new Vector3[2];
100+
Vector3[] m_CurveVertices = new Vector3[k_CurveResolution];
101+
Rect m_NeutralCurveRect;
102+
92103
public override void OnEnable()
93104
{
94105
// Tonemapping settings
@@ -129,6 +140,7 @@ public override void OnEnable()
129140
// Color wheels
130141
m_ColorWheels = new ColorWheelsSettings
131142
{
143+
mode = FindSetting((Settings x) => x.colorWheels.mode),
132144
log = FindSetting((Settings x) => x.colorWheels.log),
133145
linear = FindSetting((Settings x) => x.colorWheels.linear)
134146
};
@@ -214,6 +226,8 @@ void DoTonemappingGUI()
214226

215227
if (tid == (int)Tonemapper.Neutral)
216228
{
229+
DrawNeutralTonemappingCurve();
230+
217231
EditorGUILayout.PropertyField(m_Tonemapping.neutralBlackIn, EditorGUIHelper.GetContent("Black In"));
218232
EditorGUILayout.PropertyField(m_Tonemapping.neutralWhiteIn, EditorGUIHelper.GetContent("White In"));
219233
EditorGUILayout.PropertyField(m_Tonemapping.neutralBlackOut, EditorGUIHelper.GetContent("Black Out"));
@@ -225,6 +239,129 @@ void DoTonemappingGUI()
225239
m_Tonemapping.tonemapper.intValue = tid;
226240
}
227241

242+
void DrawNeutralTonemappingCurve()
243+
{
244+
using (new GUILayout.HorizontalScope())
245+
{
246+
GUILayout.Space(EditorGUI.indentLevel * 15f);
247+
m_NeutralCurveRect = GUILayoutUtility.GetRect(128, 80);
248+
}
249+
250+
// Background
251+
m_RectVertices[0] = PointInRect( 0f, 0f);
252+
m_RectVertices[1] = PointInRect(k_NeutralRangeX, 0f);
253+
m_RectVertices[2] = PointInRect(k_NeutralRangeX, k_NeutralRangeY);
254+
m_RectVertices[3] = PointInRect( 0f, k_NeutralRangeY);
255+
256+
Handles.DrawSolidRectangleWithOutline(
257+
m_RectVertices,
258+
Color.white * 0.1f,
259+
Color.white * 0.4f
260+
);
261+
262+
// Horizontal lines
263+
for (var i = 1; i < k_NeutralRangeY; i++)
264+
DrawLine(0, i, k_NeutralRangeX, i, 0.4f);
265+
266+
// Vertical lines
267+
for (var i = 1; i < k_NeutralRangeX; i++)
268+
DrawLine(i, 0, i, k_NeutralRangeY, 0.4f);
269+
270+
// Label
271+
Handles.Label(
272+
PointInRect(0, k_NeutralRangeY) + Vector3.right,
273+
"Neutral Tonemapper", EditorStyles.miniLabel
274+
);
275+
276+
// Precompute some values
277+
var tonemap = ((ColorGradingModel)target).settings.tonemapping;
278+
279+
const float scaleFactor = 20f;
280+
const float scaleFactorHalf = scaleFactor * 0.5f;
281+
282+
float inBlack = tonemap.neutralBlackIn * scaleFactor + 1f;
283+
float outBlack = tonemap.neutralBlackOut * scaleFactorHalf + 1f;
284+
float inWhite = tonemap.neutralWhiteIn / scaleFactor;
285+
float outWhite = 1f - tonemap.neutralWhiteOut / scaleFactor;
286+
float blackRatio = inBlack / outBlack;
287+
float whiteRatio = inWhite / outWhite;
288+
289+
const float a = 0.2f;
290+
float b = Mathf.Max(0f, Mathf.LerpUnclamped(0.57f, 0.37f, blackRatio));
291+
float c = Mathf.LerpUnclamped(0.01f, 0.24f, whiteRatio);
292+
float d = Mathf.Max(0f, Mathf.LerpUnclamped(0.02f, 0.20f, blackRatio));
293+
const float e = 0.02f;
294+
const float f = 0.30f;
295+
float whiteLevel = tonemap.neutralWhiteLevel;
296+
float whiteClip = tonemap.neutralWhiteClip / scaleFactorHalf;
297+
298+
// Tonemapping curve
299+
var vcount = 0;
300+
while (vcount < k_CurveResolution)
301+
{
302+
float x = k_NeutralRangeX * vcount / (k_CurveResolution - 1);
303+
float y = NeutralTonemap(x, a, b, c, d, e, f, whiteLevel, whiteClip);
304+
305+
if (y < k_NeutralRangeY)
306+
{
307+
m_CurveVertices[vcount++] = PointInRect(x, y);
308+
}
309+
else
310+
{
311+
if (vcount > 1)
312+
{
313+
// Extend the last segment to the top edge of the rect.
314+
var v1 = m_CurveVertices[vcount - 2];
315+
var v2 = m_CurveVertices[vcount - 1];
316+
var clip = (m_NeutralCurveRect.y - v1.y) / (v2.y - v1.y);
317+
m_CurveVertices[vcount - 1] = v1 + (v2 - v1) * clip;
318+
}
319+
break;
320+
}
321+
}
322+
323+
if (vcount > 1)
324+
{
325+
Handles.color = Color.white * 0.9f;
326+
Handles.DrawAAPolyLine(2.0f, vcount, m_CurveVertices);
327+
}
328+
}
329+
330+
void DrawLine(float x1, float y1, float x2, float y2, float grayscale)
331+
{
332+
m_LineVertices[0] = PointInRect(x1, y1);
333+
m_LineVertices[1] = PointInRect(x2, y2);
334+
Handles.color = Color.white * grayscale;
335+
Handles.DrawAAPolyLine(2f, m_LineVertices);
336+
}
337+
338+
Vector3 PointInRect(float x, float y)
339+
{
340+
x = Mathf.Lerp(m_NeutralCurveRect.x, m_NeutralCurveRect.xMax, x / k_NeutralRangeX);
341+
y = Mathf.Lerp(m_NeutralCurveRect.yMax, m_NeutralCurveRect.y, y / k_NeutralRangeY);
342+
return new Vector3(x, y, 0);
343+
}
344+
345+
float NeutralCurve(float x, float a, float b, float c, float d, float e, float f)
346+
{
347+
return ((x * (a * x + c * b) + d * e) / (x * (a * x + b) + d * f)) - e / f;
348+
}
349+
350+
float NeutralTonemap(float x, float a, float b, float c, float d, float e, float f, float whiteLevel, float whiteClip)
351+
{
352+
x = Mathf.Max(0f, x);
353+
354+
// Tonemap
355+
float whiteScale = 1f / NeutralCurve(whiteLevel, a, b, c, d, e, f);
356+
x = NeutralCurve(x * whiteScale, a, b, c, d, e, f);
357+
x *= whiteScale;
358+
359+
// Post-curve white point adjustment
360+
x /= whiteClip;
361+
362+
return x;
363+
}
364+
228365
void DoBasicGUI()
229366
{
230367
EditorGUILayout.PropertyField(m_Basic.exposure, EditorGUIHelper.GetContent("Post Exposure (EV)"));
@@ -266,15 +403,28 @@ void DoChannelMixerGUI()
266403

267404
void DoColorWheelsGUI()
268405
{
269-
EditorGUILayout.Space();
270-
EditorGUILayout.PropertyField(m_ColorWheels.linear);
271-
var rect = GUILayoutUtility.GetLastRect();
272-
WheelSetTitle(rect, "Linear Controls");
273-
274-
EditorGUILayout.Space();
275-
EditorGUILayout.PropertyField(m_ColorWheels.log);
276-
rect = GUILayoutUtility.GetLastRect();
277-
WheelSetTitle(rect, "Log Controls");
406+
int wheelMode = m_ColorWheels.mode.intValue;
407+
408+
using (new EditorGUILayout.HorizontalScope())
409+
{
410+
GUILayout.Space(15);
411+
if (GUILayout.Toggle(wheelMode == (int)ColorWheelMode.Linear, "Linear", EditorStyles.miniButtonLeft)) wheelMode = (int)ColorWheelMode.Linear;
412+
if (GUILayout.Toggle(wheelMode == (int)ColorWheelMode.Log, "Log", EditorStyles.miniButtonRight)) wheelMode = (int)ColorWheelMode.Log;
413+
}
414+
415+
m_ColorWheels.mode.intValue = wheelMode;
416+
EditorGUILayout.Space();
417+
418+
if (wheelMode == (int)ColorWheelMode.Linear)
419+
{
420+
EditorGUILayout.PropertyField(m_ColorWheels.linear);
421+
WheelSetTitle(GUILayoutUtility.GetLastRect(), "Linear Controls");
422+
}
423+
else if (wheelMode == (int)ColorWheelMode.Log)
424+
{
425+
EditorGUILayout.PropertyField(m_ColorWheels.log);
426+
WheelSetTitle(GUILayoutUtility.GetLastRect(), "Log Controls");
427+
}
278428
}
279429

280430
static void WheelSetTitle(Rect position, string label)

PostProcessing/Editor/Models/DepthOfFieldModelEditor.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,31 @@ namespace UnityEditor.PostProcessing
77
[PostProcessingModelEditor(typeof(DepthOfFieldModel))]
88
public class DepthOfFieldModelEditor : PostProcessingModelEditor
99
{
10+
SerializedProperty m_FocusDistance;
11+
SerializedProperty m_Aperture;
12+
SerializedProperty m_FocalLength;
13+
SerializedProperty m_UseCameraFov;
14+
SerializedProperty m_KernelSize;
15+
1016
public override void OnEnable()
1117
{
18+
m_FocusDistance = FindSetting((Settings x) => x.focusDistance);
19+
m_Aperture = FindSetting((Settings x) => x.aperture);
20+
m_FocalLength = FindSetting((Settings x) => x.focalLength);
21+
m_UseCameraFov = FindSetting((Settings x) => x.useCameraFov);
22+
m_KernelSize = FindSetting((Settings x) => x.kernelSize);
1223
}
1324

1425
public override void OnInspectorGUI()
1526
{
16-
EditorGUILayout.HelpBox("Work in progress.", MessageType.Warning);
27+
EditorGUILayout.PropertyField(m_FocusDistance);
28+
EditorGUILayout.PropertyField(m_Aperture, EditorGUIHelper.GetContent("Aperture (f-stop)"));
29+
30+
EditorGUILayout.PropertyField(m_UseCameraFov, EditorGUIHelper.GetContent("Use Camera FOV"));
31+
if (!m_UseCameraFov.boolValue)
32+
EditorGUILayout.PropertyField(m_FocalLength, EditorGUIHelper.GetContent("Focal Length (mm)"));
33+
34+
EditorGUILayout.PropertyField(m_KernelSize);
1735
}
1836
}
1937
}

PostProcessing/Editor/Models/GrainModelEditor.cs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,13 @@ public class GrainModelEditor : PostProcessingModelEditor
99
{
1010
SerializedProperty m_Colored;
1111
SerializedProperty m_Intensity;
12-
SerializedProperty m_WeightR;
13-
SerializedProperty m_WeightG;
14-
SerializedProperty m_WeightB;
1512
SerializedProperty m_Size;
1613
SerializedProperty m_LuminanceContribution;
1714

1815
public override void OnEnable()
1916
{
2017
m_Colored = FindSetting((Settings x) => x.colored);
2118
m_Intensity = FindSetting((Settings x) => x.intensity);
22-
m_WeightR = FindSetting((Settings x) => x.weightR);
23-
m_WeightG = FindSetting((Settings x) => x.weightG);
24-
m_WeightB = FindSetting((Settings x) => x.weightB);
2519
m_Size = FindSetting((Settings x) => x.size);
2620
m_LuminanceContribution = FindSetting((Settings x) => x.luminanceContribution);
2721
}
@@ -32,18 +26,6 @@ public override void OnInspectorGUI()
3226
EditorGUILayout.PropertyField(m_LuminanceContribution);
3327
EditorGUILayout.PropertyField(m_Size);
3428
EditorGUILayout.PropertyField(m_Colored);
35-
36-
if (m_Colored.boolValue)
37-
{
38-
EditorGUILayout.Space();
39-
EditorGUILayout.LabelField("Channel Weights", EditorStyles.boldLabel);
40-
41-
EditorGUI.indentLevel++;
42-
EditorGUILayout.PropertyField(m_WeightR, EditorGUIHelper.GetContent("Red"));
43-
EditorGUILayout.PropertyField(m_WeightG, EditorGUIHelper.GetContent("Green"));
44-
EditorGUILayout.PropertyField(m_WeightB, EditorGUIHelper.GetContent("Blue"));
45-
EditorGUI.indentLevel--;
46-
}
4729
}
4830
}
4931
}

PostProcessing/Editor/Models/MotionBlurModelEditor.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ public class MotionBlurModelEditor : PostProcessingModelEditor
1010
{
1111
SerializedProperty m_ShutterAngle;
1212
SerializedProperty m_SampleCount;
13-
SerializedProperty m_MaxBlurRadius;
1413
SerializedProperty m_FrameBlending;
1514

1615
GraphDrawer m_GraphDrawer;
@@ -165,7 +164,6 @@ public override void OnEnable()
165164
{
166165
m_ShutterAngle = FindSetting((Settings x) => x.shutterAngle);
167166
m_SampleCount = FindSetting((Settings x) => x.sampleCount);
168-
m_MaxBlurRadius = FindSetting((Settings x) => x.maxBlurRadius);
169167
m_FrameBlending = FindSetting((Settings x) => x.frameBlending);
170168
}
171169

@@ -179,7 +177,6 @@ public override void OnInspectorGUI()
179177
m_GraphDrawer.DrawShutterGraph(m_ShutterAngle.floatValue);
180178
EditorGUILayout.PropertyField(m_ShutterAngle);
181179
EditorGUILayout.PropertyField(m_SampleCount);
182-
EditorGUILayout.PropertyField(m_MaxBlurRadius);
183180
EditorGUI.indentLevel--;
184181
EditorGUILayout.Space();
185182

PostProcessing/Resources/Shaders/Common.cginc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ inline half4 SafeHDR(half4 c) { return min(c, HALF_MAX); }
9090
#if (SHADER_TARGET < 50 && !defined(SHADER_API_PSSL))
9191
float rcp(float value)
9292
{
93-
return 1. / value;
93+
return 1.0 / value;
9494
}
9595
#endif
9696

0 commit comments

Comments
 (0)