This commit is contained in:
2025-11-14 18:44:06 +08:00
parent 10156da245
commit 22e867d077
7013 changed files with 2572882 additions and 1804 deletions

View File

@@ -0,0 +1,42 @@
using UnityEngine.PostProcessing;
namespace UnityEditor.PostProcessing
{
using Settings = AmbientOcclusionModel.Settings;
[PostProcessingModelEditor(typeof(AmbientOcclusionModel))]
public class AmbientOcclusionModelEditor : PostProcessingModelEditor
{
SerializedProperty m_Intensity;
SerializedProperty m_Radius;
SerializedProperty m_SampleCount;
SerializedProperty m_Downsampling;
SerializedProperty m_ForceForwardCompatibility;
SerializedProperty m_AmbientOnly;
SerializedProperty m_HighPrecision;
public override void OnEnable()
{
m_Intensity = FindSetting((Settings x) => x.intensity);
m_Radius = FindSetting((Settings x) => x.radius);
m_SampleCount = FindSetting((Settings x) => x.sampleCount);
m_Downsampling = FindSetting((Settings x) => x.downsampling);
m_ForceForwardCompatibility = FindSetting((Settings x) => x.forceForwardCompatibility);
m_AmbientOnly = FindSetting((Settings x) => x.ambientOnly);
m_HighPrecision = FindSetting((Settings x) => x.highPrecision);
}
public override void OnInspectorGUI()
{
EditorGUILayout.PropertyField(m_Intensity);
EditorGUILayout.PropertyField(m_Radius);
EditorGUILayout.PropertyField(m_SampleCount);
EditorGUILayout.PropertyField(m_Downsampling);
EditorGUILayout.PropertyField(m_ForceForwardCompatibility);
EditorGUILayout.PropertyField(m_HighPrecision, EditorGUIHelper.GetContent("High Precision (Forward)"));
using (new EditorGUI.DisabledGroupScope(m_ForceForwardCompatibility.boolValue))
EditorGUILayout.PropertyField(m_AmbientOnly, EditorGUIHelper.GetContent("Ambient Only (Deferred + HDR)"));
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 9fcb710e23a5a0546a3b8b0ca28c1720
timeCreated: 1467190133
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,71 @@
using UnityEngine;
using UnityEngine.PostProcessing;
namespace UnityEditor.PostProcessing
{
using Method = AntialiasingModel.Method;
using Settings = AntialiasingModel.Settings;
[PostProcessingModelEditor(typeof(AntialiasingModel))]
public class AntialiasingModelEditor : PostProcessingModelEditor
{
SerializedProperty m_Method;
SerializedProperty m_FxaaPreset;
SerializedProperty m_TaaJitterSpread;
SerializedProperty m_TaaSharpen;
SerializedProperty m_TaaStationaryBlending;
SerializedProperty m_TaaMotionBlending;
static string[] s_MethodNames =
{
"Fast Approximate Anti-aliasing",
"Temporal Anti-aliasing"
};
public override void OnEnable()
{
m_Method = FindSetting((Settings x) => x.method);
m_FxaaPreset = FindSetting((Settings x) => x.fxaaSettings.preset);
m_TaaJitterSpread = FindSetting((Settings x) => x.taaSettings.jitterSpread);
m_TaaSharpen = FindSetting((Settings x) => x.taaSettings.sharpen);
m_TaaStationaryBlending = FindSetting((Settings x) => x.taaSettings.stationaryBlending);
m_TaaMotionBlending = FindSetting((Settings x) => x.taaSettings.motionBlending);
}
public override void OnInspectorGUI()
{
m_Method.intValue = EditorGUILayout.Popup("Method", m_Method.intValue, s_MethodNames);
if (m_Method.intValue == (int)Method.Fxaa)
{
EditorGUILayout.PropertyField(m_FxaaPreset);
}
else if (m_Method.intValue == (int)Method.Taa)
{
if (QualitySettings.antiAliasing > 1)
EditorGUILayout.HelpBox("Temporal Anti-Aliasing doesn't work correctly when MSAA is enabled.", MessageType.Warning);
EditorGUILayout.LabelField("Jitter", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_TaaJitterSpread, EditorGUIHelper.GetContent("Spread"));
EditorGUI.indentLevel--;
EditorGUILayout.Space();
EditorGUILayout.LabelField("Blending", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_TaaStationaryBlending, EditorGUIHelper.GetContent("Stationary"));
EditorGUILayout.PropertyField(m_TaaMotionBlending, EditorGUIHelper.GetContent("Motion"));
EditorGUI.indentLevel--;
EditorGUILayout.Space();
EditorGUILayout.PropertyField(m_TaaSharpen);
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2451939fe695c1a408ba688219837667
timeCreated: 1467190133
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,204 @@
using UnityEngine;
using UnityEngine.PostProcessing;
namespace UnityEditor.PostProcessing
{
using Settings = BloomModel.Settings;
[PostProcessingModelEditor(typeof(BloomModel))]
public class BloomModelEditor : PostProcessingModelEditor
{
struct BloomSettings
{
public SerializedProperty intensity;
public SerializedProperty threshold;
public SerializedProperty softKnee;
public SerializedProperty radius;
public SerializedProperty antiFlicker;
}
struct LensDirtSettings
{
public SerializedProperty texture;
public SerializedProperty intensity;
}
BloomSettings m_Bloom;
LensDirtSettings m_LensDirt;
public override void OnEnable()
{
m_Bloom = new BloomSettings
{
intensity = FindSetting((Settings x) => x.bloom.intensity),
threshold = FindSetting((Settings x) => x.bloom.threshold),
softKnee = FindSetting((Settings x) => x.bloom.softKnee),
radius = FindSetting((Settings x) => x.bloom.radius),
antiFlicker = FindSetting((Settings x) => x.bloom.antiFlicker)
};
m_LensDirt = new LensDirtSettings
{
texture = FindSetting((Settings x) => x.lensDirt.texture),
intensity = FindSetting((Settings x) => x.lensDirt.intensity)
};
}
public override void OnInspectorGUI()
{
EditorGUILayout.Space();
PrepareGraph();
DrawGraph();
EditorGUILayout.Space();
EditorGUILayout.PropertyField(m_Bloom.intensity);
EditorGUILayout.PropertyField(m_Bloom.threshold, EditorGUIHelper.GetContent("Threshold (Gamma)"));
EditorGUILayout.PropertyField(m_Bloom.softKnee);
EditorGUILayout.PropertyField(m_Bloom.radius);
EditorGUILayout.PropertyField(m_Bloom.antiFlicker);
EditorGUILayout.Space();
EditorGUILayout.LabelField("Dirt", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_LensDirt.texture);
EditorGUILayout.PropertyField(m_LensDirt.intensity);
EditorGUI.indentLevel--;
}
#region Graph
float m_GraphThreshold;
float m_GraphKnee;
float m_GraphIntensity;
// Number of vertices in curve
const int k_CurveResolution = 48;
// Vertex buffers
Vector3[] m_RectVertices = new Vector3[4];
Vector3[] m_LineVertices = new Vector3[2];
Vector3[] m_CurveVertices = new Vector3[k_CurveResolution];
Rect m_RectGraph;
float m_RangeX;
float m_RangeY;
float ResponseFunction(float x)
{
var rq = Mathf.Clamp(x - m_GraphThreshold + m_GraphKnee, 0, m_GraphKnee * 2);
rq = rq * rq * 0.25f / m_GraphKnee;
return Mathf.Max(rq, x - m_GraphThreshold) * m_GraphIntensity;
}
// Transform a point into the graph rect
Vector3 PointInRect(float x, float y)
{
x = Mathf.Lerp(m_RectGraph.x, m_RectGraph.xMax, x / m_RangeX);
y = Mathf.Lerp(m_RectGraph.yMax, m_RectGraph.y, y / m_RangeY);
return new Vector3(x, y, 0);
}
// Draw a line in the graph rect
void DrawLine(float x1, float y1, float x2, float y2, float grayscale)
{
m_LineVertices[0] = PointInRect(x1, y1);
m_LineVertices[1] = PointInRect(x2, y2);
Handles.color = Color.white * grayscale;
Handles.DrawAAPolyLine(2.0f, m_LineVertices);
}
// Draw a rect in the graph rect
void DrawRect(float x1, float y1, float x2, float y2, float fill, float line)
{
m_RectVertices[0] = PointInRect(x1, y1);
m_RectVertices[1] = PointInRect(x2, y1);
m_RectVertices[2] = PointInRect(x2, y2);
m_RectVertices[3] = PointInRect(x1, y2);
Handles.DrawSolidRectangleWithOutline(
m_RectVertices,
fill < 0 ? Color.clear : Color.white * fill,
line < 0 ? Color.clear : Color.white * line
);
}
// Update internal state with a given bloom instance
public void PrepareGraph()
{
var bloom = (BloomModel)target;
m_RangeX = 5f;
m_RangeY = 2f;
m_GraphThreshold = bloom.settings.bloom.thresholdLinear;
m_GraphKnee = bloom.settings.bloom.softKnee * m_GraphThreshold + 1e-5f;
// Intensity is capped to prevent sampling errors
m_GraphIntensity = Mathf.Min(bloom.settings.bloom.intensity, 10f);
}
// Draw the graph at the current position
public void DrawGraph()
{
using (new GUILayout.HorizontalScope())
{
GUILayout.Space(EditorGUI.indentLevel * 15f);
m_RectGraph = GUILayoutUtility.GetRect(128, 80);
}
// Background
DrawRect(0, 0, m_RangeX, m_RangeY, 0.1f, 0.4f);
// Soft-knee range
DrawRect(m_GraphThreshold - m_GraphKnee, 0, m_GraphThreshold + m_GraphKnee, m_RangeY, 0.25f, -1);
// Horizontal lines
for (var i = 1; i < m_RangeY; i++)
DrawLine(0, i, m_RangeX, i, 0.4f);
// Vertical lines
for (var i = 1; i < m_RangeX; i++)
DrawLine(i, 0, i, m_RangeY, 0.4f);
// Label
Handles.Label(
PointInRect(0, m_RangeY) + Vector3.right,
"Brightness Response (linear)", EditorStyles.miniLabel
);
// Threshold line
DrawLine(m_GraphThreshold, 0, m_GraphThreshold, m_RangeY, 0.6f);
// Response curve
var vcount = 0;
while (vcount < k_CurveResolution)
{
var x = m_RangeX * vcount / (k_CurveResolution - 1);
var y = ResponseFunction(x);
if (y < m_RangeY)
{
m_CurveVertices[vcount++] = PointInRect(x, y);
}
else
{
if (vcount > 1)
{
// Extend the last segment to the top edge of the rect.
var v1 = m_CurveVertices[vcount - 2];
var v2 = m_CurveVertices[vcount - 1];
var clip = (m_RectGraph.y - v1.y) / (v2.y - v1.y);
m_CurveVertices[vcount - 1] = v1 + (v2 - v1) * clip;
}
break;
}
}
if (vcount > 1)
{
Handles.color = Color.white * 0.9f;
Handles.DrawAAPolyLine(2.0f, vcount, m_CurveVertices);
}
}
#endregion
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a95f3f10e7e437c49ade656f531b30d2
timeCreated: 1467190133
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,106 @@
using UnityEngine.PostProcessing;
namespace UnityEditor.PostProcessing
{
using Mode = BuiltinDebugViewsModel.Mode;
using Settings = BuiltinDebugViewsModel.Settings;
[PostProcessingModelEditor(typeof(BuiltinDebugViewsModel), alwaysEnabled: true)]
public class BuiltinDebugViewsEditor : PostProcessingModelEditor
{
struct DepthSettings
{
public SerializedProperty scale;
}
struct MotionVectorsSettings
{
public SerializedProperty sourceOpacity;
public SerializedProperty motionImageOpacity;
public SerializedProperty motionImageAmplitude;
public SerializedProperty motionVectorsOpacity;
public SerializedProperty motionVectorsResolution;
public SerializedProperty motionVectorsAmplitude;
}
SerializedProperty m_Mode;
DepthSettings m_Depth;
MotionVectorsSettings m_MotionVectors;
public override void OnEnable()
{
m_Mode = FindSetting((Settings x) => x.mode);
m_Depth = new DepthSettings
{
scale = FindSetting((Settings x) => x.depth.scale)
};
m_MotionVectors = new MotionVectorsSettings
{
sourceOpacity = FindSetting((Settings x) => x.motionVectors.sourceOpacity),
motionImageOpacity = FindSetting((Settings x) => x.motionVectors.motionImageOpacity),
motionImageAmplitude = FindSetting((Settings x) => x.motionVectors.motionImageAmplitude),
motionVectorsOpacity = FindSetting((Settings x) => x.motionVectors.motionVectorsOpacity),
motionVectorsResolution = FindSetting((Settings x) => x.motionVectors.motionVectorsResolution),
motionVectorsAmplitude = FindSetting((Settings x) => x.motionVectors.motionVectorsAmplitude),
};
}
public override void OnInspectorGUI()
{
EditorGUILayout.PropertyField(m_Mode);
int mode = m_Mode.intValue;
if (mode == (int)Mode.Depth)
{
EditorGUILayout.PropertyField(m_Depth.scale);
}
else if (mode == (int)Mode.MotionVectors)
{
EditorGUILayout.HelpBox("Switch to play mode to see motion vectors.", MessageType.Info);
EditorGUILayout.LabelField("Source Image", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_MotionVectors.sourceOpacity, EditorGUIHelper.GetContent("Opacity"));
EditorGUI.indentLevel--;
EditorGUILayout.Space();
EditorGUILayout.LabelField("Motion Vectors (overlay)", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
if (m_MotionVectors.motionImageOpacity.floatValue > 0f)
EditorGUILayout.HelpBox("Please keep opacity to 0 if you're subject to motion sickness.", MessageType.Warning);
EditorGUILayout.PropertyField(m_MotionVectors.motionImageOpacity, EditorGUIHelper.GetContent("Opacity"));
EditorGUILayout.PropertyField(m_MotionVectors.motionImageAmplitude, EditorGUIHelper.GetContent("Amplitude"));
EditorGUI.indentLevel--;
EditorGUILayout.Space();
EditorGUILayout.LabelField("Motion Vectors (arrows)", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_MotionVectors.motionVectorsOpacity, EditorGUIHelper.GetContent("Opacity"));
EditorGUILayout.PropertyField(m_MotionVectors.motionVectorsResolution, EditorGUIHelper.GetContent("Resolution"));
EditorGUILayout.PropertyField(m_MotionVectors.motionVectorsAmplitude, EditorGUIHelper.GetContent("Amplitude"));
EditorGUI.indentLevel--;
}
else
{
CheckActiveEffect(mode == (int)Mode.AmbientOcclusion && !profile.ambientOcclusion.enabled, "Ambient Occlusion");
CheckActiveEffect(mode == (int)Mode.FocusPlane && !profile.depthOfField.enabled, "Depth Of Field");
CheckActiveEffect(mode == (int)Mode.EyeAdaptation && !profile.eyeAdaptation.enabled, "Eye Adaptation");
CheckActiveEffect((mode == (int)Mode.LogLut || mode == (int)Mode.PreGradingLog) && !profile.colorGrading.enabled, "Color Grading");
CheckActiveEffect(mode == (int)Mode.UserLut && !profile.userLut.enabled, "User Lut");
}
}
void CheckActiveEffect(bool expr, string name)
{
if (expr)
EditorGUILayout.HelpBox(string.Format("{0} isn't enabled, the debug view won't work.", name), MessageType.Warning);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 760ffebbef2ed644c87940a699eb7fe6
timeCreated: 1468237035
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
using UnityEngine.PostProcessing;
namespace UnityEditor.PostProcessing
{
[PostProcessingModelEditor(typeof(ChromaticAberrationModel))]
public class ChromaticaAberrationModelEditor : DefaultPostFxModelEditor
{
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 8a713f71a0169794a915a081f6242f60
timeCreated: 1467190133
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,672 @@
using UnityEngine;
using UnityEngine.PostProcessing;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
namespace UnityEditor.PostProcessing
{
using Settings = ColorGradingModel.Settings;
using Tonemapper = ColorGradingModel.Tonemapper;
using ColorWheelMode = ColorGradingModel.ColorWheelMode;
[PostProcessingModelEditor(typeof(ColorGradingModel))]
public class ColorGradingModelEditor : PostProcessingModelEditor
{
static GUIContent[] s_Tonemappers =
{
new GUIContent("None"),
new GUIContent("Filmic (ACES)"),
new GUIContent("Neutral")
};
struct TonemappingSettings
{
public SerializedProperty tonemapper;
public SerializedProperty neutralBlackIn;
public SerializedProperty neutralWhiteIn;
public SerializedProperty neutralBlackOut;
public SerializedProperty neutralWhiteOut;
public SerializedProperty neutralWhiteLevel;
public SerializedProperty neutralWhiteClip;
}
struct BasicSettings
{
public SerializedProperty exposure;
public SerializedProperty temperature;
public SerializedProperty tint;
public SerializedProperty hueShift;
public SerializedProperty saturation;
public SerializedProperty contrast;
}
struct ChannelMixerSettings
{
public SerializedProperty[] channels;
public SerializedProperty currentEditingChannel;
}
struct ColorWheelsSettings
{
public SerializedProperty mode;
public SerializedProperty log;
public SerializedProperty linear;
}
static GUIContent[] s_Curves =
{
new GUIContent("YRGB"),
new GUIContent("Hue VS Hue"),
new GUIContent("Hue VS Sat"),
new GUIContent("Sat VS Sat"),
new GUIContent("Lum VS Sat")
};
struct CurvesSettings
{
public SerializedProperty master;
public SerializedProperty red;
public SerializedProperty green;
public SerializedProperty blue;
public SerializedProperty hueVShue;
public SerializedProperty hueVSsat;
public SerializedProperty satVSsat;
public SerializedProperty lumVSsat;
public SerializedProperty currentEditingCurve;
public SerializedProperty curveY;
public SerializedProperty curveR;
public SerializedProperty curveG;
public SerializedProperty curveB;
}
TonemappingSettings m_Tonemapping;
BasicSettings m_Basic;
ChannelMixerSettings m_ChannelMixer;
ColorWheelsSettings m_ColorWheels;
CurvesSettings m_Curves;
CurveEditor m_CurveEditor;
Dictionary<SerializedProperty, Color> m_CurveDict;
// Neutral tonemapping curve helper
const int k_CurveResolution = 24;
const float k_NeutralRangeX = 2f;
const float k_NeutralRangeY = 1f;
Vector3[] m_RectVertices = new Vector3[4];
Vector3[] m_LineVertices = new Vector3[2];
Vector3[] m_CurveVertices = new Vector3[k_CurveResolution];
Rect m_NeutralCurveRect;
public override void OnEnable()
{
// Tonemapping settings
m_Tonemapping = new TonemappingSettings
{
tonemapper = FindSetting((Settings x) => x.tonemapping.tonemapper),
neutralBlackIn = FindSetting((Settings x) => x.tonemapping.neutralBlackIn),
neutralWhiteIn = FindSetting((Settings x) => x.tonemapping.neutralWhiteIn),
neutralBlackOut = FindSetting((Settings x) => x.tonemapping.neutralBlackOut),
neutralWhiteOut = FindSetting((Settings x) => x.tonemapping.neutralWhiteOut),
neutralWhiteLevel = FindSetting((Settings x) => x.tonemapping.neutralWhiteLevel),
neutralWhiteClip = FindSetting((Settings x) => x.tonemapping.neutralWhiteClip)
};
// Basic settings
m_Basic = new BasicSettings
{
exposure = FindSetting((Settings x) => x.basic.postExposure),
temperature = FindSetting((Settings x) => x.basic.temperature),
tint = FindSetting((Settings x) => x.basic.tint),
hueShift = FindSetting((Settings x) => x.basic.hueShift),
saturation = FindSetting((Settings x) => x.basic.saturation),
contrast = FindSetting((Settings x) => x.basic.contrast)
};
// Channel mixer
m_ChannelMixer = new ChannelMixerSettings
{
channels = new[]
{
FindSetting((Settings x) => x.channelMixer.red),
FindSetting((Settings x) => x.channelMixer.green),
FindSetting((Settings x) => x.channelMixer.blue)
},
currentEditingChannel = FindSetting((Settings x) => x.channelMixer.currentEditingChannel)
};
// Color wheels
m_ColorWheels = new ColorWheelsSettings
{
mode = FindSetting((Settings x) => x.colorWheels.mode),
log = FindSetting((Settings x) => x.colorWheels.log),
linear = FindSetting((Settings x) => x.colorWheels.linear)
};
// Curves
m_Curves = new CurvesSettings
{
master = FindSetting((Settings x) => x.curves.master.curve),
red = FindSetting((Settings x) => x.curves.red.curve),
green = FindSetting((Settings x) => x.curves.green.curve),
blue = FindSetting((Settings x) => x.curves.blue.curve),
hueVShue = FindSetting((Settings x) => x.curves.hueVShue.curve),
hueVSsat = FindSetting((Settings x) => x.curves.hueVSsat.curve),
satVSsat = FindSetting((Settings x) => x.curves.satVSsat.curve),
lumVSsat = FindSetting((Settings x) => x.curves.lumVSsat.curve),
currentEditingCurve = FindSetting((Settings x) => x.curves.e_CurrentEditingCurve),
curveY = FindSetting((Settings x) => x.curves.e_CurveY),
curveR = FindSetting((Settings x) => x.curves.e_CurveR),
curveG = FindSetting((Settings x) => x.curves.e_CurveG),
curveB = FindSetting((Settings x) => x.curves.e_CurveB)
};
// Prepare the curve editor and extract curve display settings
m_CurveDict = new Dictionary<SerializedProperty, Color>();
var settings = CurveEditor.Settings.defaultSettings;
m_CurveEditor = new CurveEditor(settings);
AddCurve(m_Curves.master, new Color(1f, 1f, 1f), 2, false);
AddCurve(m_Curves.red, new Color(1f, 0f, 0f), 2, false);
AddCurve(m_Curves.green, new Color(0f, 1f, 0f), 2, false);
AddCurve(m_Curves.blue, new Color(0f, 0.5f, 1f), 2, false);
AddCurve(m_Curves.hueVShue, new Color(1f, 1f, 1f), 0, true);
AddCurve(m_Curves.hueVSsat, new Color(1f, 1f, 1f), 0, true);
AddCurve(m_Curves.satVSsat, new Color(1f, 1f, 1f), 0, false);
AddCurve(m_Curves.lumVSsat, new Color(1f, 1f, 1f), 0, false);
}
void AddCurve(SerializedProperty prop, Color color, uint minPointCount, bool loop)
{
var state = CurveEditor.CurveState.defaultState;
state.color = color;
state.visible = false;
state.minPointCount = minPointCount;
state.onlyShowHandlesOnSelection = true;
state.zeroKeyConstantValue = 0.5f;
state.loopInBounds = loop;
m_CurveEditor.Add(prop, state);
m_CurveDict.Add(prop, color);
}
public override void OnDisable()
{
m_CurveEditor.RemoveAll();
}
public override void OnInspectorGUI()
{
DoGUIFor("Tonemapping", DoTonemappingGUI);
EditorGUILayout.Space();
DoGUIFor("Basic", DoBasicGUI);
EditorGUILayout.Space();
DoGUIFor("Channel Mixer", DoChannelMixerGUI);
EditorGUILayout.Space();
DoGUIFor("Trackballs", DoColorWheelsGUI);
EditorGUILayout.Space();
DoGUIFor("Grading Curves", DoCurvesGUI);
}
void DoGUIFor(string title, Action func)
{
EditorGUILayout.LabelField(title, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
func();
EditorGUI.indentLevel--;
}
void DoTonemappingGUI()
{
int tid = EditorGUILayout.Popup(EditorGUIHelper.GetContent("Tonemapper"), m_Tonemapping.tonemapper.intValue, s_Tonemappers);
if (tid == (int)Tonemapper.Neutral)
{
DrawNeutralTonemappingCurve();
EditorGUILayout.PropertyField(m_Tonemapping.neutralBlackIn, EditorGUIHelper.GetContent("Black In"));
EditorGUILayout.PropertyField(m_Tonemapping.neutralWhiteIn, EditorGUIHelper.GetContent("White In"));
EditorGUILayout.PropertyField(m_Tonemapping.neutralBlackOut, EditorGUIHelper.GetContent("Black Out"));
EditorGUILayout.PropertyField(m_Tonemapping.neutralWhiteOut, EditorGUIHelper.GetContent("White Out"));
EditorGUILayout.PropertyField(m_Tonemapping.neutralWhiteLevel, EditorGUIHelper.GetContent("White Level"));
EditorGUILayout.PropertyField(m_Tonemapping.neutralWhiteClip, EditorGUIHelper.GetContent("White Clip"));
}
m_Tonemapping.tonemapper.intValue = tid;
}
void DrawNeutralTonemappingCurve()
{
using (new GUILayout.HorizontalScope())
{
GUILayout.Space(EditorGUI.indentLevel * 15f);
m_NeutralCurveRect = GUILayoutUtility.GetRect(128, 80);
}
// Background
m_RectVertices[0] = PointInRect( 0f, 0f);
m_RectVertices[1] = PointInRect(k_NeutralRangeX, 0f);
m_RectVertices[2] = PointInRect(k_NeutralRangeX, k_NeutralRangeY);
m_RectVertices[3] = PointInRect( 0f, k_NeutralRangeY);
Handles.DrawSolidRectangleWithOutline(
m_RectVertices,
Color.white * 0.1f,
Color.white * 0.4f
);
// Horizontal lines
for (var i = 1; i < k_NeutralRangeY; i++)
DrawLine(0, i, k_NeutralRangeX, i, 0.4f);
// Vertical lines
for (var i = 1; i < k_NeutralRangeX; i++)
DrawLine(i, 0, i, k_NeutralRangeY, 0.4f);
// Label
Handles.Label(
PointInRect(0, k_NeutralRangeY) + Vector3.right,
"Neutral Tonemapper", EditorStyles.miniLabel
);
// Precompute some values
var tonemap = ((ColorGradingModel)target).settings.tonemapping;
const float scaleFactor = 20f;
const float scaleFactorHalf = scaleFactor * 0.5f;
float inBlack = tonemap.neutralBlackIn * scaleFactor + 1f;
float outBlack = tonemap.neutralBlackOut * scaleFactorHalf + 1f;
float inWhite = tonemap.neutralWhiteIn / scaleFactor;
float outWhite = 1f - tonemap.neutralWhiteOut / scaleFactor;
float blackRatio = inBlack / outBlack;
float whiteRatio = inWhite / outWhite;
const float a = 0.2f;
float b = Mathf.Max(0f, Mathf.LerpUnclamped(0.57f, 0.37f, blackRatio));
float c = Mathf.LerpUnclamped(0.01f, 0.24f, whiteRatio);
float d = Mathf.Max(0f, Mathf.LerpUnclamped(0.02f, 0.20f, blackRatio));
const float e = 0.02f;
const float f = 0.30f;
float whiteLevel = tonemap.neutralWhiteLevel;
float whiteClip = tonemap.neutralWhiteClip / scaleFactorHalf;
// Tonemapping curve
var vcount = 0;
while (vcount < k_CurveResolution)
{
float x = k_NeutralRangeX * vcount / (k_CurveResolution - 1);
float y = NeutralTonemap(x, a, b, c, d, e, f, whiteLevel, whiteClip);
if (y < k_NeutralRangeY)
{
m_CurveVertices[vcount++] = PointInRect(x, y);
}
else
{
if (vcount > 1)
{
// Extend the last segment to the top edge of the rect.
var v1 = m_CurveVertices[vcount - 2];
var v2 = m_CurveVertices[vcount - 1];
var clip = (m_NeutralCurveRect.y - v1.y) / (v2.y - v1.y);
m_CurveVertices[vcount - 1] = v1 + (v2 - v1) * clip;
}
break;
}
}
if (vcount > 1)
{
Handles.color = Color.white * 0.9f;
Handles.DrawAAPolyLine(2.0f, vcount, m_CurveVertices);
}
}
void DrawLine(float x1, float y1, float x2, float y2, float grayscale)
{
m_LineVertices[0] = PointInRect(x1, y1);
m_LineVertices[1] = PointInRect(x2, y2);
Handles.color = Color.white * grayscale;
Handles.DrawAAPolyLine(2f, m_LineVertices);
}
Vector3 PointInRect(float x, float y)
{
x = Mathf.Lerp(m_NeutralCurveRect.x, m_NeutralCurveRect.xMax, x / k_NeutralRangeX);
y = Mathf.Lerp(m_NeutralCurveRect.yMax, m_NeutralCurveRect.y, y / k_NeutralRangeY);
return new Vector3(x, y, 0);
}
float NeutralCurve(float x, float a, float b, float c, float d, float e, float f)
{
return ((x * (a * x + c * b) + d * e) / (x * (a * x + b) + d * f)) - e / f;
}
float NeutralTonemap(float x, float a, float b, float c, float d, float e, float f, float whiteLevel, float whiteClip)
{
x = Mathf.Max(0f, x);
// Tonemap
float whiteScale = 1f / NeutralCurve(whiteLevel, a, b, c, d, e, f);
x = NeutralCurve(x * whiteScale, a, b, c, d, e, f);
x *= whiteScale;
// Post-curve white point adjustment
x /= whiteClip;
return x;
}
void DoBasicGUI()
{
EditorGUILayout.PropertyField(m_Basic.exposure, EditorGUIHelper.GetContent("Post Exposure (EV)"));
EditorGUILayout.PropertyField(m_Basic.temperature);
EditorGUILayout.PropertyField(m_Basic.tint);
EditorGUILayout.PropertyField(m_Basic.hueShift);
EditorGUILayout.PropertyField(m_Basic.saturation);
EditorGUILayout.PropertyField(m_Basic.contrast);
}
void DoChannelMixerGUI()
{
int currentChannel = m_ChannelMixer.currentEditingChannel.intValue;
EditorGUI.BeginChangeCheck();
{
using (new EditorGUILayout.HorizontalScope())
{
EditorGUILayout.PrefixLabel("Channel");
if (GUILayout.Toggle(currentChannel == 0, EditorGUIHelper.GetContent("Red|Red output channel."), EditorStyles.miniButtonLeft)) currentChannel = 0;
if (GUILayout.Toggle(currentChannel == 1, EditorGUIHelper.GetContent("Green|Green output channel."), EditorStyles.miniButtonMid)) currentChannel = 1;
if (GUILayout.Toggle(currentChannel == 2, EditorGUIHelper.GetContent("Blue|Blue output channel."), EditorStyles.miniButtonRight)) currentChannel = 2;
}
}
if (EditorGUI.EndChangeCheck())
{
GUI.FocusControl(null);
}
var serializedChannel = m_ChannelMixer.channels[currentChannel];
m_ChannelMixer.currentEditingChannel.intValue = currentChannel;
var v = serializedChannel.vector3Value;
v.x = EditorGUILayout.Slider(EditorGUIHelper.GetContent("Red|Modify influence of the red channel within the overall mix."), v.x, -2f, 2f);
v.y = EditorGUILayout.Slider(EditorGUIHelper.GetContent("Green|Modify influence of the green channel within the overall mix."), v.y, -2f, 2f);
v.z = EditorGUILayout.Slider(EditorGUIHelper.GetContent("Blue|Modify influence of the blue channel within the overall mix."), v.z, -2f, 2f);
serializedChannel.vector3Value = v;
}
void DoColorWheelsGUI()
{
int wheelMode = m_ColorWheels.mode.intValue;
using (new EditorGUILayout.HorizontalScope())
{
GUILayout.Space(15);
if (GUILayout.Toggle(wheelMode == (int)ColorWheelMode.Linear, "Linear", EditorStyles.miniButtonLeft)) wheelMode = (int)ColorWheelMode.Linear;
if (GUILayout.Toggle(wheelMode == (int)ColorWheelMode.Log, "Log", EditorStyles.miniButtonRight)) wheelMode = (int)ColorWheelMode.Log;
}
m_ColorWheels.mode.intValue = wheelMode;
EditorGUILayout.Space();
if (wheelMode == (int)ColorWheelMode.Linear)
{
EditorGUILayout.PropertyField(m_ColorWheels.linear);
WheelSetTitle(GUILayoutUtility.GetLastRect(), "Linear Controls");
}
else if (wheelMode == (int)ColorWheelMode.Log)
{
EditorGUILayout.PropertyField(m_ColorWheels.log);
WheelSetTitle(GUILayoutUtility.GetLastRect(), "Log Controls");
}
}
static void WheelSetTitle(Rect position, string label)
{
var matrix = GUI.matrix;
var rect = new Rect(position.x - 10f, position.y, TrackballGroupDrawer.m_Size, TrackballGroupDrawer.m_Size);
GUIUtility.RotateAroundPivot(-90f, rect.center);
GUI.Label(rect, label, FxStyles.centeredMiniLabel);
GUI.matrix = matrix;
}
void ResetVisibleCurves()
{
foreach (var curve in m_CurveDict)
{
var state = m_CurveEditor.GetCurveState(curve.Key);
state.visible = false;
m_CurveEditor.SetCurveState(curve.Key, state);
}
}
void SetCurveVisible(SerializedProperty prop)
{
var state = m_CurveEditor.GetCurveState(prop);
state.visible = true;
m_CurveEditor.SetCurveState(prop, state);
}
bool SpecialToggle(bool value, string name, out bool rightClicked)
{
var rect = GUILayoutUtility.GetRect(EditorGUIHelper.GetContent(name), EditorStyles.toolbarButton);
var e = Event.current;
rightClicked = (e.type == EventType.MouseUp && rect.Contains(e.mousePosition) && e.button == 1);
return GUI.Toggle(rect, value, name, EditorStyles.toolbarButton);
}
static Material s_MaterialSpline;
void DoCurvesGUI()
{
EditorGUILayout.Space();
EditorGUI.indentLevel -= 2;
ResetVisibleCurves();
using (new EditorGUI.DisabledGroupScope(serializedProperty.serializedObject.isEditingMultipleObjects))
{
int curveEditingId = 0;
// Top toolbar
using (new GUILayout.HorizontalScope(EditorStyles.toolbar))
{
curveEditingId = EditorGUILayout.Popup(m_Curves.currentEditingCurve.intValue, s_Curves, EditorStyles.toolbarPopup, GUILayout.MaxWidth(150f));
bool y = false, r = false, g = false, b = false;
if (curveEditingId == 0)
{
EditorGUILayout.Space();
bool rightClickedY, rightClickedR, rightClickedG, rightClickedB;
y = SpecialToggle(m_Curves.curveY.boolValue, "Y", out rightClickedY);
r = SpecialToggle(m_Curves.curveR.boolValue, "R", out rightClickedR);
g = SpecialToggle(m_Curves.curveG.boolValue, "G", out rightClickedG);
b = SpecialToggle(m_Curves.curveB.boolValue, "B", out rightClickedB);
if (!y && !r && !g && !b)
{
r = g = b = false;
y = true;
}
if (rightClickedY || rightClickedR || rightClickedG || rightClickedB)
{
y = rightClickedY;
r = rightClickedR;
g = rightClickedG;
b = rightClickedB;
}
if (y) SetCurveVisible(m_Curves.master);
if (r) SetCurveVisible(m_Curves.red);
if (g) SetCurveVisible(m_Curves.green);
if (b) SetCurveVisible(m_Curves.blue);
m_Curves.curveY.boolValue = y;
m_Curves.curveR.boolValue = r;
m_Curves.curveG.boolValue = g;
m_Curves.curveB.boolValue = b;
}
else
{
switch (curveEditingId)
{
case 1: SetCurveVisible(m_Curves.hueVShue);
break;
case 2: SetCurveVisible(m_Curves.hueVSsat);
break;
case 3: SetCurveVisible(m_Curves.satVSsat);
break;
case 4: SetCurveVisible(m_Curves.lumVSsat);
break;
}
}
GUILayout.FlexibleSpace();
if (GUILayout.Button("Reset", EditorStyles.toolbarButton))
{
switch (curveEditingId)
{
case 0:
if (y) m_Curves.master.animationCurveValue = AnimationCurve.Linear(0f, 0f, 1f, 1f);
if (r) m_Curves.red.animationCurveValue = AnimationCurve.Linear(0f, 0f, 1f, 1f);
if (g) m_Curves.green.animationCurveValue = AnimationCurve.Linear(0f, 0f, 1f, 1f);
if (b) m_Curves.blue.animationCurveValue = AnimationCurve.Linear(0f, 0f, 1f, 1f);
break;
case 1: m_Curves.hueVShue.animationCurveValue = new AnimationCurve();
break;
case 2: m_Curves.hueVSsat.animationCurveValue = new AnimationCurve();
break;
case 3: m_Curves.satVSsat.animationCurveValue = new AnimationCurve();
break;
case 4: m_Curves.lumVSsat.animationCurveValue = new AnimationCurve();
break;
}
}
m_Curves.currentEditingCurve.intValue = curveEditingId;
}
// Curve area
var settings = m_CurveEditor.settings;
var rect = GUILayoutUtility.GetAspectRect(2f);
var innerRect = settings.padding.Remove(rect);
if (Event.current.type == EventType.Repaint)
{
// Background
EditorGUI.DrawRect(rect, new Color(0.15f, 0.15f, 0.15f, 1f));
if (s_MaterialSpline == null)
s_MaterialSpline = new Material(Shader.Find("Hidden/Post FX/UI/Curve Background")) { hideFlags = HideFlags.HideAndDontSave };
if (curveEditingId == 1 || curveEditingId == 2)
DrawBackgroundTexture(innerRect, 0);
else if (curveEditingId == 3 || curveEditingId == 4)
DrawBackgroundTexture(innerRect, 1);
// Bounds
Handles.color = Color.white;
Handles.DrawSolidRectangleWithOutline(innerRect, Color.clear, new Color(0.8f, 0.8f, 0.8f, 0.5f));
// Grid setup
Handles.color = new Color(1f, 1f, 1f, 0.05f);
int hLines = (int)Mathf.Sqrt(innerRect.width);
int vLines = (int)(hLines / (innerRect.width / innerRect.height));
// Vertical grid
int gridOffset = Mathf.FloorToInt(innerRect.width / hLines);
int gridPadding = ((int)(innerRect.width) % hLines) / 2;
for (int i = 1; i < hLines; i++)
{
var offset = i * Vector2.right * gridOffset;
offset.x += gridPadding;
Handles.DrawLine(innerRect.position + offset, new Vector2(innerRect.x, innerRect.yMax - 1) + offset);
}
// Horizontal grid
gridOffset = Mathf.FloorToInt(innerRect.height / vLines);
gridPadding = ((int)(innerRect.height) % vLines) / 2;
for (int i = 1; i < vLines; i++)
{
var offset = i * Vector2.up * gridOffset;
offset.y += gridPadding;
Handles.DrawLine(innerRect.position + offset, new Vector2(innerRect.xMax - 1, innerRect.y) + offset);
}
}
// Curve editor
if (m_CurveEditor.OnGUI(rect))
{
Repaint();
GUI.changed = true;
}
if (Event.current.type == EventType.Repaint)
{
// Borders
Handles.color = Color.black;
Handles.DrawLine(new Vector2(rect.x, rect.y - 18f), new Vector2(rect.xMax, rect.y - 18f));
Handles.DrawLine(new Vector2(rect.x, rect.y - 19f), new Vector2(rect.x, rect.yMax));
Handles.DrawLine(new Vector2(rect.x, rect.yMax), new Vector2(rect.xMax, rect.yMax));
Handles.DrawLine(new Vector2(rect.xMax, rect.yMax), new Vector2(rect.xMax, rect.y - 18f));
// Selection info
var selection = m_CurveEditor.GetSelection();
if (selection.curve != null && selection.keyframeIndex > -1)
{
var key = selection.keyframe.Value;
var infoRect = innerRect;
infoRect.x += 5f;
infoRect.width = 100f;
infoRect.height = 30f;
GUI.Label(infoRect, string.Format("{0}\n{1}", key.time.ToString("F3"), key.value.ToString("F3")), FxStyles.preLabel);
}
}
}
/*
EditorGUILayout.HelpBox(
@"Curve editor cheat sheet:
- [Del] or [Backspace] to remove a key
- [Ctrl] to break a tangent handle
- [Shift] to align tangent handles
- [Double click] to create a key on the curve(s) at mouse position
- [Alt] + [Double click] to create a key on the curve(s) at a given time",
MessageType.Info);
*/
EditorGUILayout.Space();
EditorGUI.indentLevel += 2;
}
void DrawBackgroundTexture(Rect rect, int pass)
{
float scale = EditorGUIUtility.pixelsPerPoint;
var oldRt = RenderTexture.active;
var rt = RenderTexture.GetTemporary(Mathf.CeilToInt(rect.width * scale), Mathf.CeilToInt(rect.height * scale), 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
s_MaterialSpline.SetFloat("_DisabledState", GUI.enabled ? 1f : 0.5f);
s_MaterialSpline.SetFloat("_PixelScaling", EditorGUIUtility.pixelsPerPoint);
Graphics.Blit(null, rt, s_MaterialSpline, pass);
RenderTexture.active = oldRt;
GUI.DrawTexture(rect, rt);
RenderTexture.ReleaseTemporary(rt);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c3e3bce1d5c900d4fa7aa0f2b21814cf
timeCreated: 1467190133
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,22 @@
using System.Collections.Generic;
namespace UnityEditor.PostProcessing
{
public class DefaultPostFxModelEditor : PostProcessingModelEditor
{
List<SerializedProperty> m_Properties = new List<SerializedProperty>();
public override void OnEnable()
{
var iter = m_SettingsProperty.Copy().GetEnumerator();
while (iter.MoveNext())
m_Properties.Add(((SerializedProperty)iter.Current).Copy());
}
public override void OnInspectorGUI()
{
foreach (var property in m_Properties)
EditorGUILayout.PropertyField(property);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c15016a7fef58974f91a6a4d6b132d94
timeCreated: 1467190133
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,37 @@
using UnityEngine.PostProcessing;
namespace UnityEditor.PostProcessing
{
using Settings = DepthOfFieldModel.Settings;
[PostProcessingModelEditor(typeof(DepthOfFieldModel))]
public class DepthOfFieldModelEditor : PostProcessingModelEditor
{
SerializedProperty m_FocusDistance;
SerializedProperty m_Aperture;
SerializedProperty m_FocalLength;
SerializedProperty m_UseCameraFov;
SerializedProperty m_KernelSize;
public override void OnEnable()
{
m_FocusDistance = FindSetting((Settings x) => x.focusDistance);
m_Aperture = FindSetting((Settings x) => x.aperture);
m_FocalLength = FindSetting((Settings x) => x.focalLength);
m_UseCameraFov = FindSetting((Settings x) => x.useCameraFov);
m_KernelSize = FindSetting((Settings x) => x.kernelSize);
}
public override void OnInspectorGUI()
{
EditorGUILayout.PropertyField(m_FocusDistance);
EditorGUILayout.PropertyField(m_Aperture, EditorGUIHelper.GetContent("Aperture (f-stop)"));
EditorGUILayout.PropertyField(m_UseCameraFov, EditorGUIHelper.GetContent("Use Camera FOV"));
if (!m_UseCameraFov.boolValue)
EditorGUILayout.PropertyField(m_FocalLength, EditorGUIHelper.GetContent("Focal Length (mm)"));
EditorGUILayout.PropertyField(m_KernelSize);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: dc2f388440e9f8b4f8fc7bb43c01cc7d
timeCreated: 1467190133
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
using UnityEngine.PostProcessing;
namespace UnityEditor.PostProcessing
{
[PostProcessingModelEditor(typeof(DitheringModel))]
public class DitheringModelEditor : PostProcessingModelEditor
{
public override void OnInspectorGUI()
{
if (profile.grain.enabled && target.enabled)
EditorGUILayout.HelpBox("Grain is enabled, you probably don't need dithering !", MessageType.Warning);
else
EditorGUILayout.HelpBox("Nothing to configure !", MessageType.Info);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 87377c86d84f49a4e912d37d28353e7f
timeCreated: 1485179854
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,86 @@
using UnityEngine;
using UnityEngine.PostProcessing;
namespace UnityEditor.PostProcessing
{
using Settings = EyeAdaptationModel.Settings;
[PostProcessingModelEditor(typeof(EyeAdaptationModel))]
public class EyeAdaptationModelEditor : PostProcessingModelEditor
{
SerializedProperty m_LowPercent;
SerializedProperty m_HighPercent;
SerializedProperty m_MinLuminance;
SerializedProperty m_MaxLuminance;
SerializedProperty m_KeyValue;
SerializedProperty m_DynamicKeyValue;
SerializedProperty m_AdaptationType;
SerializedProperty m_SpeedUp;
SerializedProperty m_SpeedDown;
SerializedProperty m_LogMin;
SerializedProperty m_LogMax;
public override void OnEnable()
{
m_LowPercent = FindSetting((Settings x) => x.lowPercent);
m_HighPercent = FindSetting((Settings x) => x.highPercent);
m_MinLuminance = FindSetting((Settings x) => x.minLuminance);
m_MaxLuminance = FindSetting((Settings x) => x.maxLuminance);
m_KeyValue = FindSetting((Settings x) => x.keyValue);
m_DynamicKeyValue = FindSetting((Settings x) => x.dynamicKeyValue);
m_AdaptationType = FindSetting((Settings x) => x.adaptationType);
m_SpeedUp = FindSetting((Settings x) => x.speedUp);
m_SpeedDown = FindSetting((Settings x) => x.speedDown);
m_LogMin = FindSetting((Settings x) => x.logMin);
m_LogMax = FindSetting((Settings x) => x.logMax);
}
public override void OnInspectorGUI()
{
if (!GraphicsUtils.supportsDX11)
EditorGUILayout.HelpBox("This effect requires support for compute shaders. Enabling it won't do anything on unsupported platforms.", MessageType.Warning);
EditorGUILayout.LabelField("Luminosity range", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_LogMin, EditorGUIHelper.GetContent("Minimum (EV)"));
EditorGUILayout.PropertyField(m_LogMax, EditorGUIHelper.GetContent("Maximum (EV)"));
EditorGUI.indentLevel--;
EditorGUILayout.Space();
EditorGUILayout.LabelField("Auto exposure", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
float low = m_LowPercent.floatValue;
float high = m_HighPercent.floatValue;
EditorGUILayout.MinMaxSlider(EditorGUIHelper.GetContent("Histogram filtering|These values are the lower and upper percentages of the histogram that will be used to find a stable average luminance. Values outside of this range will be discarded and won't contribute to the average luminance."), ref low, ref high, 1f, 99f);
m_LowPercent.floatValue = low;
m_HighPercent.floatValue = high;
EditorGUILayout.PropertyField(m_MinLuminance, EditorGUIHelper.GetContent("Minimum (EV)"));
EditorGUILayout.PropertyField(m_MaxLuminance, EditorGUIHelper.GetContent("Maximum (EV)"));
EditorGUILayout.PropertyField(m_DynamicKeyValue);
if (!m_DynamicKeyValue.boolValue)
EditorGUILayout.PropertyField(m_KeyValue);
EditorGUI.indentLevel--;
EditorGUILayout.Space();
EditorGUILayout.LabelField("Adaptation", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_AdaptationType, EditorGUIHelper.GetContent("Type"));
if (m_AdaptationType.intValue == (int)EyeAdaptationModel.EyeAdaptationType.Progressive)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_SpeedUp);
EditorGUILayout.PropertyField(m_SpeedDown);
EditorGUI.indentLevel--;
}
EditorGUI.indentLevel--;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 489b5c785ba0f614d90c322fa0827216
timeCreated: 1467190133
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,24 @@
using UnityEngine.PostProcessing;
namespace UnityEditor.PostProcessing
{
using Settings = FogModel.Settings;
[PostProcessingModelEditor(typeof(FogModel))]
public class FogModelEditor : PostProcessingModelEditor
{
SerializedProperty m_ExcludeSkybox;
public override void OnEnable()
{
m_ExcludeSkybox = FindSetting((Settings x) => x.excludeSkybox);
}
public override void OnInspectorGUI()
{
EditorGUILayout.HelpBox("This effect adds fog compatibility to the deferred rendering path; enabling it with the forward rendering path won't have any effect. Actual fog settings should be set in the Lighting panel.", MessageType.Info);
EditorGUILayout.PropertyField(m_ExcludeSkybox);
EditorGUI.indentLevel--;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 44a64b44ec891d24b96ed84d958c3d4f
timeCreated: 1487335049
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,31 @@
using UnityEngine.PostProcessing;
namespace UnityEditor.PostProcessing
{
using Settings = GrainModel.Settings;
[PostProcessingModelEditor(typeof(GrainModel))]
public class GrainModelEditor : PostProcessingModelEditor
{
SerializedProperty m_Colored;
SerializedProperty m_Intensity;
SerializedProperty m_Size;
SerializedProperty m_LuminanceContribution;
public override void OnEnable()
{
m_Colored = FindSetting((Settings x) => x.colored);
m_Intensity = FindSetting((Settings x) => x.intensity);
m_Size = FindSetting((Settings x) => x.size);
m_LuminanceContribution = FindSetting((Settings x) => x.luminanceContribution);
}
public override void OnInspectorGUI()
{
EditorGUILayout.PropertyField(m_Intensity);
EditorGUILayout.PropertyField(m_LuminanceContribution);
EditorGUILayout.PropertyField(m_Size);
EditorGUILayout.PropertyField(m_Colored);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 8330694e2c90c284f81153ac83b3cb4a
timeCreated: 1467190133
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,197 @@
using UnityEngine;
using UnityEngine.PostProcessing;
namespace UnityEditor.PostProcessing
{
using Settings = MotionBlurModel.Settings;
[PostProcessingModelEditor(typeof(MotionBlurModel))]
public class MotionBlurModelEditor : PostProcessingModelEditor
{
SerializedProperty m_ShutterAngle;
SerializedProperty m_SampleCount;
SerializedProperty m_FrameBlending;
GraphDrawer m_GraphDrawer;
class GraphDrawer
{
const float k_Height = 32f;
Texture m_BlendingIcon;
GUIStyle m_LowerCenterStyle;
GUIStyle m_MiddleCenterStyle;
Color m_ColorDark;
Color m_ColorGray;
Vector3[] m_RectVertices = new Vector3[4];
public GraphDrawer()
{
m_BlendingIcon = EditorResources.Load<Texture>("UI/MotionBlendingIcon.png");
m_LowerCenterStyle = new GUIStyle(EditorStyles.miniLabel) { alignment = TextAnchor.LowerCenter };
m_MiddleCenterStyle = new GUIStyle(EditorStyles.miniLabel) { alignment = TextAnchor.MiddleCenter };
if (EditorGUIUtility.isProSkin)
{
m_ColorDark = new Color(0.18f, 0.18f, 0.18f);
m_ColorGray = new Color(0.43f, 0.43f, 0.43f);
}
else
{
m_ColorDark = new Color(0.64f, 0.64f, 0.64f);
m_ColorGray = new Color(0.92f, 0.92f, 0.92f);
}
}
public void DrawShutterGraph(float angle)
{
var center = GUILayoutUtility.GetRect(128, k_Height).center;
// Parameters used to make transitions smooth.
var zeroWhenOff = Mathf.Min(1f, angle * 0.1f);
var zeroWhenFull = Mathf.Min(1f, (360f - angle) * 0.02f);
// Shutter angle graph
var discCenter = center - new Vector2(k_Height * 2.4f, 0f);
// - exposure duration indicator
DrawDisc(discCenter, k_Height * Mathf.Lerp(0.5f, 0.38f, zeroWhenFull), m_ColorGray);
// - shutter disc
DrawDisc(discCenter, k_Height * 0.16f * zeroWhenFull, m_ColorDark);
// - shutter blade
DrawArc(discCenter, k_Height * 0.5f, 360f - angle, m_ColorDark);
// - shutter axis
DrawDisc(discCenter, zeroWhenOff, m_ColorGray);
// Shutter label (off/full)
var labelSize = new Vector2(k_Height, k_Height);
var labelOrigin = discCenter - labelSize * 0.5f;
var labelRect = new Rect(labelOrigin, labelSize);
if (Mathf.Approximately(angle, 0f))
GUI.Label(labelRect, "Off", m_MiddleCenterStyle);
else if (Mathf.Approximately(angle, 360f))
GUI.Label(labelRect, "Full", m_MiddleCenterStyle);
// Exposure time bar graph
var outerBarSize = new Vector2(4.75f, 0.5f) * k_Height;
var innerBarSize = outerBarSize;
innerBarSize.x *= angle / 360f;
var barCenter = center + new Vector2(k_Height * 0.9f, 0f);
var barOrigin = barCenter - outerBarSize * 0.5f;
DrawRect(barOrigin, outerBarSize, m_ColorDark);
DrawRect(barOrigin, innerBarSize, m_ColorGray);
var barText = "Exposure time = " + (angle / 3.6f).ToString("0") + "% of ΔT";
GUI.Label(new Rect(barOrigin, outerBarSize), barText, m_MiddleCenterStyle);
}
public void DrawBlendingGraph(float strength)
{
var center = GUILayoutUtility.GetRect(128, k_Height).center;
var iconSize = new Vector2(k_Height, k_Height);
var iconStride = new Vector2(k_Height * 0.9f, 0f);
var iconOrigin = center - iconSize * 0.5f - iconStride * 2f;
for (var i = 0; i < 5; i++)
{
var weight = BlendingWeight(strength, i / 60f);
var rect = new Rect(iconOrigin + iconStride * i, iconSize);
var color = m_ColorGray;
color.a = weight;
GUI.color = color;
GUI.Label(rect, m_BlendingIcon);
GUI.color = Color.white;
GUI.Label(rect, (weight * 100).ToString("0") + "%", m_LowerCenterStyle);
}
// EditorGUIUtility.isProSkin
}
// Weight function for multi frame blending
float BlendingWeight(float strength, float time)
{
if (strength > 0f || Mathf.Approximately(time, 0f))
return Mathf.Exp(-time * Mathf.Lerp(80f, 10f, strength));
return 0;
}
// Draw a solid disc in the graph rect.
void DrawDisc(Vector2 center, float radius, Color fill)
{
Handles.color = fill;
Handles.DrawSolidDisc(center, Vector3.forward, radius);
}
// Draw an arc in the graph rect.
void DrawArc(Vector2 center, float radius, float angle, Color fill)
{
var start = new Vector2(
-Mathf.Cos(Mathf.Deg2Rad * angle / 2f),
Mathf.Sin(Mathf.Deg2Rad * angle / 2f)
);
Handles.color = fill;
Handles.DrawSolidArc(center, Vector3.forward, start, angle, radius);
}
// Draw a rectangle in the graph rect.
void DrawRect(Vector2 origin, Vector2 size, Color color)
{
var p0 = origin;
var p1 = origin + size;
m_RectVertices[0] = p0;
m_RectVertices[1] = new Vector2(p1.x, p0.y);
m_RectVertices[2] = p1;
m_RectVertices[3] = new Vector2(p0.x, p1.y);
Handles.color = Color.white;
Handles.DrawSolidRectangleWithOutline(m_RectVertices, color, Color.clear);
}
}
public override void OnEnable()
{
m_ShutterAngle = FindSetting((Settings x) => x.shutterAngle);
m_SampleCount = FindSetting((Settings x) => x.sampleCount);
m_FrameBlending = FindSetting((Settings x) => x.frameBlending);
}
public override void OnInspectorGUI()
{
if (m_GraphDrawer == null)
m_GraphDrawer = new GraphDrawer();
EditorGUILayout.LabelField("Shutter Speed Simulation", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
m_GraphDrawer.DrawShutterGraph(m_ShutterAngle.floatValue);
EditorGUILayout.PropertyField(m_ShutterAngle);
EditorGUILayout.PropertyField(m_SampleCount);
EditorGUI.indentLevel--;
EditorGUILayout.Space();
EditorGUILayout.LabelField("Multiple Frame Blending", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
float fbValue = m_FrameBlending.floatValue;
m_GraphDrawer.DrawBlendingGraph(fbValue);
EditorGUILayout.PropertyField(m_FrameBlending);
if (fbValue > 0f)
EditorGUILayout.HelpBox("Multi-Frame Blending lowers precision of the final picture for optimization purposes.", MessageType.Info);
EditorGUI.indentLevel--;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 870806eda355b5144879155e2ba37eb6
timeCreated: 1468325681
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,100 @@
using UnityEngine;
using UnityEngine.PostProcessing;
namespace UnityEditor.PostProcessing
{
using Settings = ScreenSpaceReflectionModel.Settings;
[PostProcessingModelEditor(typeof(ScreenSpaceReflectionModel))]
public class ScreenSpaceReflectionModelEditor : PostProcessingModelEditor
{
struct IntensitySettings
{
public SerializedProperty reflectionMultiplier;
public SerializedProperty fadeDistance;
public SerializedProperty fresnelFade;
public SerializedProperty fresnelFadePower;
}
struct ReflectionSettings
{
public SerializedProperty blendType;
public SerializedProperty reflectionQuality;
public SerializedProperty maxDistance;
public SerializedProperty iterationCount;
public SerializedProperty stepSize;
public SerializedProperty widthModifier;
public SerializedProperty reflectionBlur;
public SerializedProperty reflectBackfaces;
}
struct ScreenEdgeMask
{
public SerializedProperty intensity;
}
IntensitySettings m_Intensity;
ReflectionSettings m_Reflection;
ScreenEdgeMask m_ScreenEdgeMask;
public override void OnEnable()
{
m_Intensity = new IntensitySettings
{
reflectionMultiplier = FindSetting((Settings x) => x.intensity.reflectionMultiplier),
fadeDistance = FindSetting((Settings x) => x.intensity.fadeDistance),
fresnelFade = FindSetting((Settings x) => x.intensity.fresnelFade),
fresnelFadePower = FindSetting((Settings x) => x.intensity.fresnelFadePower)
};
m_Reflection = new ReflectionSettings
{
blendType = FindSetting((Settings x) => x.reflection.blendType),
reflectionQuality = FindSetting((Settings x) => x.reflection.reflectionQuality),
maxDistance = FindSetting((Settings x) => x.reflection.maxDistance),
iterationCount = FindSetting((Settings x) => x.reflection.iterationCount),
stepSize = FindSetting((Settings x) => x.reflection.stepSize),
widthModifier = FindSetting((Settings x) => x.reflection.widthModifier),
reflectionBlur = FindSetting((Settings x) => x.reflection.reflectionBlur),
reflectBackfaces = FindSetting((Settings x) => x.reflection.reflectBackfaces)
};
m_ScreenEdgeMask = new ScreenEdgeMask
{
intensity = FindSetting((Settings x) => x.screenEdgeMask.intensity)
};
}
public override void OnInspectorGUI()
{
EditorGUILayout.HelpBox("This effect only works with the deferred rendering path.", MessageType.Info);
EditorGUILayout.LabelField("Reflection", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_Reflection.blendType);
EditorGUILayout.PropertyField(m_Reflection.reflectionQuality);
EditorGUILayout.PropertyField(m_Reflection.maxDistance);
EditorGUILayout.PropertyField(m_Reflection.iterationCount);
EditorGUILayout.PropertyField(m_Reflection.stepSize);
EditorGUILayout.PropertyField(m_Reflection.widthModifier);
EditorGUILayout.PropertyField(m_Reflection.reflectionBlur);
EditorGUILayout.PropertyField(m_Reflection.reflectBackfaces);
EditorGUI.indentLevel--;
EditorGUILayout.Space();
EditorGUILayout.LabelField("Intensity", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_Intensity.reflectionMultiplier);
EditorGUILayout.PropertyField(m_Intensity.fadeDistance);
EditorGUILayout.PropertyField(m_Intensity.fresnelFade);
EditorGUILayout.PropertyField(m_Intensity.fresnelFadePower);
EditorGUI.indentLevel--;
EditorGUILayout.Space();
EditorGUILayout.LabelField("Screen Edge Mask", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_ScreenEdgeMask.intensity);
EditorGUI.indentLevel--;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 57bbe1f20eec7bb4d9bc90fc65ef381b
timeCreated: 1467190133
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,87 @@
using UnityEngine;
using UnityEngine.PostProcessing;
namespace UnityEditor.PostProcessing
{
using Settings = UserLutModel.Settings;
[PostProcessingModelEditor(typeof(UserLutModel))]
public class UserLutModelEditor : PostProcessingModelEditor
{
SerializedProperty m_Texture;
SerializedProperty m_Contribution;
public override void OnEnable()
{
m_Texture = FindSetting((Settings x) => x.lut);
m_Contribution = FindSetting((Settings x) => x.contribution);
}
public override void OnInspectorGUI()
{
var lut = (target as UserLutModel).settings.lut;
// Checks import settings on the lut, offers to fix them if invalid
if (lut != null)
{
var importer = (TextureImporter)AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(lut));
if (importer != null) // Fails when using an internal texture
{
#if UNITY_5_5_OR_NEWER
bool valid = importer.anisoLevel == 0
&& importer.mipmapEnabled == false
&& importer.sRGBTexture == false
&& (importer.textureCompression == TextureImporterCompression.Uncompressed);
#else
bool valid = importer.anisoLevel == 0
&& importer.mipmapEnabled == false
&& importer.linearTexture == true
&& (importer.textureFormat == TextureImporterFormat.RGB24 || importer.textureFormat == TextureImporterFormat.AutomaticTruecolor);
#endif
if (!valid)
{
EditorGUILayout.HelpBox("Invalid LUT import settings.", MessageType.Warning);
GUILayout.Space(-32);
using (new EditorGUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
if (GUILayout.Button("Fix", GUILayout.Width(60)))
{
SetLUTImportSettings(importer);
AssetDatabase.Refresh();
}
GUILayout.Space(8);
}
GUILayout.Space(11);
}
}
else
{
m_Texture.objectReferenceValue = null;
}
}
EditorGUILayout.PropertyField(m_Texture);
EditorGUILayout.PropertyField(m_Contribution);
}
void SetLUTImportSettings(TextureImporter importer)
{
#if UNITY_5_5_OR_NEWER
importer.textureType = TextureImporterType.Default;
importer.sRGBTexture = false;
importer.textureCompression = TextureImporterCompression.Uncompressed;
#else
importer.textureType = TextureImporterType.Advanced;
importer.linearTexture = true;
importer.textureFormat = TextureImporterFormat.RGB24;
#endif
importer.anisoLevel = 0;
importer.mipmapEnabled = false;
importer.SaveAndReimport();
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b235eb1c486b38c4fa06470234bbfd32
timeCreated: 1466769818
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,118 @@
using UnityEngine;
using UnityEngine.PostProcessing;
namespace UnityEditor.PostProcessing
{
using VignetteMode = VignetteModel.Mode;
using Settings = VignetteModel.Settings;
[PostProcessingModelEditor(typeof(VignetteModel))]
public class VignetteModelEditor : PostProcessingModelEditor
{
SerializedProperty m_Mode;
SerializedProperty m_Color;
SerializedProperty m_Center;
SerializedProperty m_Intensity;
SerializedProperty m_Smoothness;
SerializedProperty m_Roundness;
SerializedProperty m_Mask;
SerializedProperty m_Opacity;
SerializedProperty m_Rounded;
public override void OnEnable()
{
m_Mode = FindSetting((Settings x) => x.mode);
m_Color = FindSetting((Settings x) => x.color);
m_Center = FindSetting((Settings x) => x.center);
m_Intensity = FindSetting((Settings x) => x.intensity);
m_Smoothness = FindSetting((Settings x) => x.smoothness);
m_Roundness = FindSetting((Settings x) => x.roundness);
m_Mask = FindSetting((Settings x) => x.mask);
m_Opacity = FindSetting((Settings x) => x.opacity);
m_Rounded = FindSetting((Settings x) => x.rounded);
}
public override void OnInspectorGUI()
{
EditorGUILayout.PropertyField(m_Mode);
EditorGUILayout.PropertyField(m_Color);
if (m_Mode.intValue < (int)VignetteMode.Masked)
{
EditorGUILayout.PropertyField(m_Center);
EditorGUILayout.PropertyField(m_Intensity);
EditorGUILayout.PropertyField(m_Smoothness);
EditorGUILayout.PropertyField(m_Roundness);
EditorGUILayout.PropertyField(m_Rounded);
}
else
{
var mask = (target as VignetteModel).settings.mask;
// Checks import settings on the mask, offers to fix them if invalid
if (mask != null)
{
var importer = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(mask)) as TextureImporter;
if (importer != null) // Fails when using an internal texture
{
#if UNITY_5_5_OR_NEWER
bool valid = importer.anisoLevel == 0
&& importer.mipmapEnabled == false
//&& importer.alphaUsage == TextureImporterAlphaUsage.FromGrayScale
&& importer.alphaSource == TextureImporterAlphaSource.FromGrayScale
&& importer.textureCompression == TextureImporterCompression.Uncompressed
&& importer.wrapMode == TextureWrapMode.Clamp;
#else
bool valid = importer.anisoLevel == 0
&& importer.mipmapEnabled == false
&& importer.grayscaleToAlpha == true
&& importer.textureFormat == TextureImporterFormat.Alpha8
&& importer.wrapMode == TextureWrapMode.Clamp;
#endif
if (!valid)
{
EditorGUILayout.HelpBox("Invalid mask import settings.", MessageType.Warning);
GUILayout.Space(-32);
using (new EditorGUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
if (GUILayout.Button("Fix", GUILayout.Width(60)))
{
SetMaskImportSettings(importer);
AssetDatabase.Refresh();
}
GUILayout.Space(8);
}
GUILayout.Space(11);
}
}
}
EditorGUILayout.PropertyField(m_Mask);
EditorGUILayout.PropertyField(m_Opacity);
}
}
void SetMaskImportSettings(TextureImporter importer)
{
#if UNITY_5_5_OR_NEWER
importer.textureType = TextureImporterType.SingleChannel;
//importer.alphaUsage = TextureImporterAlphaUsage.FromGrayScale;
importer.alphaSource = TextureImporterAlphaSource.FromGrayScale;
importer.textureCompression = TextureImporterCompression.Uncompressed;
#else
importer.textureType = TextureImporterType.Advanced;
importer.grayscaleToAlpha = true;
importer.textureFormat = TextureImporterFormat.Alpha8;
#endif
importer.anisoLevel = 0;
importer.mipmapEnabled = false;
importer.wrapMode = TextureWrapMode.Clamp;
importer.SaveAndReimport();
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 745ad42620dabf04b94761acc86189ba
timeCreated: 1467190133
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: