Skip to content

Commit f415a97

Browse files
committed
Merge branch 'release/0.8.5'
2 parents b4d88ac + e585221 commit f415a97

File tree

15 files changed

+132
-51
lines changed

15 files changed

+132
-51
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,20 @@ All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](http://keepachangelog.com/); this project adheres to [Semantic Versioning](http://semver.org/).
55

6+
## [0.8.5] - 2021.11.18
7+
8+
Bugfixes and improvements.
9+
10+
### Added
11+
- Added support for HDR color pickers ([#42](https://github.com/Arvtesh/UnityFx.Outline/issues/42)).
12+
13+
### Fixed
14+
- Fixed URP depth testing with MSAA enabled when using `OutlineLayerCollection`, thanks @AGM-GR for the help ([#39](https://github.com/Arvtesh/UnityFx.Outline/issues/39)).
15+
- Added loop unroll statement to make shaders compatible with some platforms (WebGL 1.0) ([#45](https://github.com/Arvtesh/UnityFx.Outline/issues/45)).
16+
- Removed `BeginSample`/`EndSample` profiler calls when rendering outlines to get rid of the editor errors ([#44](https://github.com/Arvtesh/UnityFx.Outline/issues/44)).
17+
618
## [0.8.4] - 2021.08.17
19+
720
Misc improvements.
821

922
### Added

Outline.Core/Packages/UnityFx.Outline/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](http://keepachangelog.com/); this project adheres to [Semantic Versioning](http://semver.org/).
55

6+
## [0.8.5] - 2021.11.18
7+
8+
Bugfixes and improvements.
9+
10+
### Added
11+
- Added support for HDR color pickers ([#42](https://github.com/Arvtesh/UnityFx.Outline/issues/42)).
12+
13+
### Fixed
14+
- Added loop unroll statement to make shaders compatible with some platforms (WebGL 1.0) ([#45](https://github.com/Arvtesh/UnityFx.Outline/issues/45)).
15+
616
## [0.8.4] - 2021.08.17
717
Misc improvements.
818

Outline.Core/Packages/UnityFx.Outline/Editor/Scripts/OutlineEditorUtility.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ namespace UnityFx.Outline
1111
{
1212
public static class OutlineEditorUtility
1313
{
14+
public static readonly GUIContent FilterSettingsContent = new GUIContent("Outline Filter Settings", "");
15+
public static readonly GUIContent LayerMaskContent = new GUIContent("Layer Mask", OutlineResources.OutlineLayerMaskTooltip);
16+
public static readonly GUIContent RenderingLayerMaskContent = new GUIContent("Rendering Layer Mask", OutlineResources.OutlineRenderingLayerMaskTooltip);
17+
public static readonly GUIContent ColorContent = new GUIContent("Color", "Outline color.");
18+
public static readonly GUIContent WidthContent = new GUIContent("Width", "Outline width in pixels.");
19+
public static readonly GUIContent RenderFlagsContent = new GUIContent("Render Flags", "Outline render flags. Multiple values can be selected at the same time.");
20+
public static readonly GUIContent BlurIntensityContent = new GUIContent("Blur Intensity", "Outline intensity value. It is only usable for blurred outlines.");
21+
public static readonly GUIContent AlphaCutoffContent = new GUIContent("Alpha Cutoff", "Outline alpha cutoff value. It is only usable when alpha testing is enabled and the material doesn't have _Cutoff property.");
22+
1423
public static void RenderPreview(OutlineLayer layer, int layerIndex, bool showObjects)
1524
{
1625
if (layer != null)

Outline.Core/Packages/UnityFx.Outline/Editor/Scripts/OutlineLayerCollectionEditor.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,24 +128,24 @@ private void OnDrawLayer(Rect rect, int index, bool isActive, bool isFocused)
128128
{
129129
EditorGUI.BeginDisabledGroup(obj != null);
130130

131-
color = EditorGUI.ColorField(new Rect(rect.x, y, rect.width, lineHeight), "Color", color);
131+
color = EditorGUI.ColorField(new Rect(rect.x, y, rect.width, lineHeight), OutlineEditorUtility.ColorContent, color, true, true, true);
132132
y += lineOffset;
133133

134-
width = EditorGUI.IntSlider(new Rect(rect.x, y, rect.width, lineHeight), "Width", width, OutlineResources.MinWidth, OutlineResources.MaxWidth);
134+
width = EditorGUI.IntSlider(new Rect(rect.x, y, rect.width, lineHeight), OutlineEditorUtility.WidthContent, width, OutlineResources.MinWidth, OutlineResources.MaxWidth);
135135
y += lineOffset;
136136

137-
renderMode = (OutlineRenderFlags)EditorGUI.EnumFlagsField(new Rect(rect.x, y, rect.width, lineHeight), "Render Flags", renderMode);
137+
renderMode = (OutlineRenderFlags)EditorGUI.EnumFlagsField(new Rect(rect.x, y, rect.width, lineHeight), OutlineEditorUtility.RenderFlagsContent, renderMode);
138138
y += lineOffset;
139139

140140
if ((renderMode & OutlineRenderFlags.Blurred) != 0)
141141
{
142-
blurIntensity = EditorGUI.Slider(new Rect(rect.x, y, rect.width, lineHeight), "Blur Intensity", blurIntensity, OutlineResources.MinIntensity, OutlineResources.MaxIntensity);
142+
blurIntensity = EditorGUI.Slider(new Rect(rect.x, y, rect.width, lineHeight), OutlineEditorUtility.BlurIntensityContent, blurIntensity, OutlineResources.MinIntensity, OutlineResources.MaxIntensity);
143143
y += lineOffset;
144144
}
145145

146146
if ((renderMode & OutlineRenderFlags.EnableAlphaTesting) != 0)
147147
{
148-
alphaCutoff = EditorGUI.Slider(new Rect(rect.x, y, rect.width, lineHeight), "Alpha Cutoff", alphaCutoff, OutlineResources.MinAlphaCutoff, OutlineResources.MaxAlphaCutoff);
148+
alphaCutoff = EditorGUI.Slider(new Rect(rect.x, y, rect.width, lineHeight), OutlineEditorUtility.AlphaCutoffContent, alphaCutoff, OutlineResources.MinAlphaCutoff, OutlineResources.MaxAlphaCutoff);
149149
}
150150

151151
EditorGUI.EndDisabledGroup();

Outline.Core/Packages/UnityFx.Outline/Editor/Scripts/OutlineSettingsEditor.cs

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,6 @@ public class OutlineSettingsEditor : Editor
2222
private const string _cutoffPropName = "_outlineAlphaCutoff";
2323
private const string _renderModePropName = "_outlineMode";
2424

25-
private static readonly GUIContent _filterModeContent = new GUIContent("Outline Filter Settings", "");
26-
private static readonly GUIContent _layerMaskContent = new GUIContent("Layer Mask", OutlineResources.OutlineLayerMaskTooltip);
27-
private static readonly GUIContent _renderingLayerMaskContent = new GUIContent("Rendering Layer Mask", OutlineResources.OutlineRenderingLayerMaskTooltip);
28-
private static readonly GUIContent _colorContent = new GUIContent("Color", "Outline color.");
29-
private static readonly GUIContent _widthContent = new GUIContent("Width", "Outline width in pixels.");
30-
private static readonly GUIContent _renderModeContent = new GUIContent("Render Flags", "Outline render flags. Multiple values can be selected at the same time.");
31-
private static readonly GUIContent _intensityContent = new GUIContent("Blur Intensity", "Outline intensity value. It is only usable for blurred outlines.");
32-
private static readonly GUIContent _cutoffContent = new GUIContent("Alpha Cutoff", "Outline alpha cutoff value. It is only usable when alpha testing is enabled and the material doesn't have _Cutoff property.");
33-
3425
public override void OnInspectorGUI()
3526
{
3627
base.OnInspectorGUI();
@@ -42,20 +33,22 @@ public override void OnInspectorGUI()
4233
var renderModeProp = serializedObject.FindProperty(_renderModePropName);
4334
var renderMode = (OutlineRenderFlags)renderModeProp.intValue;
4435

45-
EditorGUILayout.PropertyField(colorProp, _colorContent);
46-
EditorGUILayout.PropertyField(widthProp, _widthContent);
36+
//EditorGUILayout.PropertyField(colorProp, _colorContent);
37+
colorProp.colorValue = EditorGUILayout.ColorField(OutlineEditorUtility.ColorContent, colorProp.colorValue, true, true, true);
38+
39+
EditorGUILayout.PropertyField(widthProp, OutlineEditorUtility.WidthContent);
4740

4841
//EditorGUILayout.PropertyField(renderModeProp, _renderModeContent);
49-
renderModeProp.intValue = (int)(OutlineRenderFlags)EditorGUILayout.EnumFlagsField(_renderModeContent, renderMode);
42+
renderModeProp.intValue = (int)(OutlineRenderFlags)EditorGUILayout.EnumFlagsField(OutlineEditorUtility.RenderFlagsContent, renderMode);
5043

5144
if ((renderMode & OutlineRenderFlags.Blurred) != 0)
5245
{
53-
EditorGUILayout.PropertyField(intensityProp, _intensityContent);
46+
EditorGUILayout.PropertyField(intensityProp, OutlineEditorUtility.BlurIntensityContent);
5447
}
5548

5649
if ((renderMode & OutlineRenderFlags.EnableAlphaTesting) != 0)
5750
{
58-
EditorGUILayout.PropertyField(cutoffProp, _cutoffContent);
51+
EditorGUILayout.PropertyField(cutoffProp, OutlineEditorUtility.AlphaCutoffContent);
5952
}
6053

6154
serializedObject.ApplyModifiedProperties();
@@ -159,14 +152,14 @@ internal static void DrawSettingsWithMask(Rect rc, SerializedProperty property)
159152
var lineCy = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
160153
var filterModeProp = property.FindPropertyRelative(_filterModePropName);
161154

162-
EditorGUI.PropertyField(new Rect(rc.x, rc.y, rc.width, EditorGUIUtility.singleLineHeight), filterModeProp, _filterModeContent);
155+
EditorGUI.PropertyField(new Rect(rc.x, rc.y, rc.width, EditorGUIUtility.singleLineHeight), filterModeProp, OutlineEditorUtility.FilterSettingsContent);
163156

164157
if (filterModeProp.intValue == (int)OutlineFilterMode.UseLayerMask)
165158
{
166159
var layerMaskProp = property.FindPropertyRelative(_layerMaskPropName);
167160

168161
EditorGUI.indentLevel += 1;
169-
EditorGUI.PropertyField(new Rect(rc.x, rc.y + lineCy, rc.width, EditorGUIUtility.singleLineHeight), layerMaskProp, _layerMaskContent);
162+
EditorGUI.PropertyField(new Rect(rc.x, rc.y + lineCy, rc.width, EditorGUIUtility.singleLineHeight), layerMaskProp, OutlineEditorUtility.LayerMaskContent);
170163
EditorGUI.indentLevel -= 1;
171164

172165
DrawSettingsInstance(new Rect(rc.x, rc.y + lineCy * 2, rc.width, rc.height - lineCy), property);
@@ -176,10 +169,10 @@ internal static void DrawSettingsWithMask(Rect rc, SerializedProperty property)
176169
var renderingLayerMaskProp = property.FindPropertyRelative(_renderingLayerMaskPropName);
177170

178171
EditorGUI.indentLevel += 1;
179-
EditorGUI.PropertyField(new Rect(rc.x, rc.y + lineCy, rc.width, EditorGUIUtility.singleLineHeight), renderingLayerMaskProp, _renderingLayerMaskContent);
172+
EditorGUI.PropertyField(new Rect(rc.x, rc.y + lineCy, rc.width, EditorGUIUtility.singleLineHeight), renderingLayerMaskProp, OutlineEditorUtility.RenderingLayerMaskContent);
180173
EditorGUI.indentLevel -= 1;
181174

182-
DrawSettingsInstance(new Rect(rc.x, rc.y + lineCy * 2, rc.width, rc.height - lineCy), property);
175+
DrawSettingsInstance(new Rect(rc.x, rc.y + lineCy * 2, rc.width, rc.height - lineCy), property);
183176
}
184177
}
185178

@@ -189,20 +182,22 @@ private static void DrawSettingsInternal(Rect rc, SerializedProperty colorProp,
189182
var lineCy = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
190183
var n = 4;
191184

192-
EditorGUI.PropertyField(new Rect(rc.x, rc.y + 1 * lineCy, rc.width, EditorGUIUtility.singleLineHeight), colorProp, _colorContent);
193-
EditorGUI.PropertyField(new Rect(rc.x, rc.y + 2 * lineCy, rc.width, EditorGUIUtility.singleLineHeight), widthProp, _widthContent);
185+
//EditorGUI.PropertyField(new Rect(rc.x, rc.y + 1 * lineCy, rc.width, EditorGUIUtility.singleLineHeight), colorProp, _colorContent);
186+
colorProp.colorValue = EditorGUI.ColorField(new Rect(rc.x, rc.y + 1 * lineCy, rc.width, EditorGUIUtility.singleLineHeight), OutlineEditorUtility.ColorContent, colorProp.colorValue, true, true, true);
187+
188+
EditorGUI.PropertyField(new Rect(rc.x, rc.y + 2 * lineCy, rc.width, EditorGUIUtility.singleLineHeight), widthProp, OutlineEditorUtility.WidthContent);
194189

195190
// NOTE: EditorGUI.PropertyField doesn't allow multi-selection, have to use EnumFlagsField explixitly.
196-
renderModeProp.intValue = (int)(OutlineRenderFlags)EditorGUI.EnumFlagsField(new Rect(rc.x, rc.y + 3 * lineCy, rc.width, EditorGUIUtility.singleLineHeight), _renderModeContent, renderMode);
191+
renderModeProp.intValue = (int)(OutlineRenderFlags)EditorGUI.EnumFlagsField(new Rect(rc.x, rc.y + 3 * lineCy, rc.width, EditorGUIUtility.singleLineHeight), OutlineEditorUtility.RenderFlagsContent, renderMode);
197192

198193
if ((renderMode & OutlineRenderFlags.Blurred) != 0)
199194
{
200-
EditorGUI.PropertyField(new Rect(rc.x, rc.y + n++ * lineCy, rc.width, EditorGUIUtility.singleLineHeight), intensityProp, _intensityContent);
195+
EditorGUI.PropertyField(new Rect(rc.x, rc.y + n++ * lineCy, rc.width, EditorGUIUtility.singleLineHeight), intensityProp, OutlineEditorUtility.BlurIntensityContent);
201196
}
202197

203198
if ((renderMode & OutlineRenderFlags.EnableAlphaTesting) != 0)
204199
{
205-
EditorGUI.PropertyField(new Rect(rc.x, rc.y + n * lineCy, rc.width, EditorGUIUtility.singleLineHeight), cutoffProp, _cutoffContent);
200+
EditorGUI.PropertyField(new Rect(rc.x, rc.y + n * lineCy, rc.width, EditorGUIUtility.singleLineHeight), cutoffProp, OutlineEditorUtility.AlphaCutoffContent);
206201
}
207202
}
208203
}

Outline.Core/Packages/UnityFx.Outline/Runtime/Scripts/OutlineResources.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ public sealed class OutlineResources : ScriptableObject
4444
/// <summary>
4545
/// Maximum value of outline width parameter.
4646
/// </summary>
47+
/// <remarks>
48+
/// If the value is changed here, it should be adjusted in Outline.shader as well.
49+
/// </remarks>
4750
/// <seealso cref="MinWidth"/>
4851
public const int MaxWidth = 32;
4952

Outline.Core/Packages/UnityFx.Outline/Runtime/Scripts/Rendering/OutlineRenderer.cs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,13 @@ public void Render(IReadOnlyList<Renderer> renderers, IOutlineSettings settings,
263263

264264
if (renderers.Count > 0)
265265
{
266-
if (string.IsNullOrEmpty(sampleName))
267-
{
268-
sampleName = renderers[0].name;
269-
}
266+
// NOTE: Remove BeginSample/EndSample for now (https://github.com/Arvtesh/UnityFx.Outline/issues/44).
267+
//if (string.IsNullOrEmpty(sampleName))
268+
//{
269+
// sampleName = renderers[0].name;
270+
//}
270271

271-
_commandBuffer.BeginSample(sampleName);
272+
//_commandBuffer.BeginSample(sampleName);
272273
{
273274
RenderObjectClear(settings.OutlineRenderMode);
274275

@@ -279,7 +280,7 @@ public void Render(IReadOnlyList<Renderer> renderers, IOutlineSettings settings,
279280

280281
RenderOutline(settings);
281282
}
282-
_commandBuffer.EndSample(sampleName);
283+
//_commandBuffer.EndSample(sampleName);
283284
}
284285
}
285286

@@ -303,18 +304,20 @@ public void Render(Renderer renderer, IOutlineSettings settings, string sampleNa
303304
throw new ArgumentNullException(nameof(settings));
304305
}
305306

306-
if (string.IsNullOrEmpty(sampleName))
307-
{
308-
sampleName = renderer.name;
309-
}
307+
// NOTE: Remove BeginSample/EndSample for now (https://github.com/Arvtesh/UnityFx.Outline/issues/44).
308+
//if (string.IsNullOrEmpty(sampleName))
309+
//{
310+
// sampleName = renderer.name;
311+
//}
310312

311-
_commandBuffer.BeginSample(sampleName);
313+
// NOTE: Remove this for now (https://github.com/Arvtesh/UnityFx.Outline/issues/44).
314+
//_commandBuffer.BeginSample(sampleName);
312315
{
313316
RenderObjectClear(settings.OutlineRenderMode);
314317
DrawRenderer(renderer, settings);
315318
RenderOutline(settings);
316319
}
317-
_commandBuffer.EndSample(sampleName);
320+
//_commandBuffer.EndSample(sampleName);
318321
}
319322

320323
/// <summary>

Outline.Core/Packages/UnityFx.Outline/Runtime/Shaders/Outline.shader

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,34 @@ Shader "Hidden/UnityFx/Outline"
6464

6565
#endif
6666

67+
float CalcIntensityN0(float2 uv, float2 offset, int k)
68+
{
69+
return UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv + k * offset).r * _GaussSamples[k];
70+
}
71+
72+
float CalcIntensityN1(float2 uv, float2 offset, int k)
73+
{
74+
return UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv - k * offset).r * _GaussSamples[k];
75+
}
76+
6777
float CalcIntensity(float2 uv, float2 offset)
6878
{
6979
float intensity = 0;
7080

7181
// Accumulates horizontal or vertical blur intensity for the specified texture position.
7282
// Set offset = (tx, 0) for horizontal sampling and offset = (0, ty) for vertical.
73-
for (int k = -_Width; k <= _Width; ++k)
83+
//
84+
// NOTE: Unroll directive is needed to make the method function on platforms like WebGL 1.0 where loops are not supported.
85+
// If maximum outline width is changed here, it should be changed in OutlineResources.MaxWidth as well.
86+
//
87+
[unroll(32)]
88+
for (int k = 1; k <= _Width; ++k)
7489
{
75-
intensity += UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv + k * offset).r * _GaussSamples[abs(k)];
90+
intensity += CalcIntensityN0(uv, offset, k);
91+
intensity += CalcIntensityN1(uv, offset, k);
7692
}
7793

94+
intensity += CalcIntensityN0(uv, offset, 0);
7895
return intensity;
7996
}
8097

Outline.Core/Packages/UnityFx.Outline/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "com.unityfx.outline",
3-
"version": "0.8.4",
3+
"version": "0.8.5",
44
"displayName": "Outline toolkit",
55
"description": "This package contains configurable per-object and per-camera outline effect implementation for built-in render pipeline. Both solid and blurred outline modes are supported (Gauss blur), as well as depth testing. Reusable and extensible API.",
66
"unity": "2018.4",

Outline.URP/Packages/UnityFx.Outline.URP/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@ All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](http://keepachangelog.com/); this project adheres to [Semantic Versioning](http://semver.org/).
55

6+
## [0.5.0] - 2021.11.18
7+
8+
Bugfixes and improvements.
9+
10+
### Added
11+
- Added support for HDR color pickers ([#42](https://github.com/Arvtesh/UnityFx.Outline/issues/42)).
12+
13+
### Fixed
14+
- Fixed URP depth testing with MSAA enabled when using `OutlineLayerCollection`, thanks @AGM-GR for the help ([#39](https://github.com/Arvtesh/UnityFx.Outline/issues/39)).
15+
- Added loop unroll statement to make shaders compatible with some platforms (WebGL 1.0) ([#45](https://github.com/Arvtesh/UnityFx.Outline/issues/45)).
16+
- Removed `BeginSample`/`EndSample` profiler calls when rendering outlines to get rid of the editor errors ([#44](https://github.com/Arvtesh/UnityFx.Outline/issues/44)).
17+
618
## [0.4.0] - 2021.08.17
719
Misc improvements.
820

0 commit comments

Comments
 (0)