diff --git a/CHANGELOG.md b/CHANGELOG.md
index f6152f4..5b3256b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,7 +3,20 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/); this project adheres to [Semantic Versioning](http://semver.org/).
+## [0.8.5] - 2021.11.18
+
+Bugfixes and improvements.
+
+### Added
+- Added support for HDR color pickers ([#42](https://github.com/Arvtesh/UnityFx.Outline/issues/42)).
+
+### Fixed
+- 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)).
+- Added loop unroll statement to make shaders compatible with some platforms (WebGL 1.0) ([#45](https://github.com/Arvtesh/UnityFx.Outline/issues/45)).
+- Removed `BeginSample`/`EndSample` profiler calls when rendering outlines to get rid of the editor errors ([#44](https://github.com/Arvtesh/UnityFx.Outline/issues/44)).
+
## [0.8.4] - 2021.08.17
+
Misc improvements.
### Added
diff --git a/Outline.Core/Packages/UnityFx.Outline/CHANGELOG.md b/Outline.Core/Packages/UnityFx.Outline/CHANGELOG.md
index 59b696d..c3599af 100644
--- a/Outline.Core/Packages/UnityFx.Outline/CHANGELOG.md
+++ b/Outline.Core/Packages/UnityFx.Outline/CHANGELOG.md
@@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/); this project adheres to [Semantic Versioning](http://semver.org/).
+## [0.8.5] - 2021.11.18
+
+Bugfixes and improvements.
+
+### Added
+- Added support for HDR color pickers ([#42](https://github.com/Arvtesh/UnityFx.Outline/issues/42)).
+
+### Fixed
+- Added loop unroll statement to make shaders compatible with some platforms (WebGL 1.0) ([#45](https://github.com/Arvtesh/UnityFx.Outline/issues/45)).
+
## [0.8.4] - 2021.08.17
Misc improvements.
diff --git a/Outline.Core/Packages/UnityFx.Outline/Editor/Scripts/OutlineEditorUtility.cs b/Outline.Core/Packages/UnityFx.Outline/Editor/Scripts/OutlineEditorUtility.cs
index dcb2756..df53c31 100644
--- a/Outline.Core/Packages/UnityFx.Outline/Editor/Scripts/OutlineEditorUtility.cs
+++ b/Outline.Core/Packages/UnityFx.Outline/Editor/Scripts/OutlineEditorUtility.cs
@@ -11,6 +11,15 @@ namespace UnityFx.Outline
{
public static class OutlineEditorUtility
{
+ public static readonly GUIContent FilterSettingsContent = new GUIContent("Outline Filter Settings", "");
+ public static readonly GUIContent LayerMaskContent = new GUIContent("Layer Mask", OutlineResources.OutlineLayerMaskTooltip);
+ public static readonly GUIContent RenderingLayerMaskContent = new GUIContent("Rendering Layer Mask", OutlineResources.OutlineRenderingLayerMaskTooltip);
+ public static readonly GUIContent ColorContent = new GUIContent("Color", "Outline color.");
+ public static readonly GUIContent WidthContent = new GUIContent("Width", "Outline width in pixels.");
+ public static readonly GUIContent RenderFlagsContent = new GUIContent("Render Flags", "Outline render flags. Multiple values can be selected at the same time.");
+ public static readonly GUIContent BlurIntensityContent = new GUIContent("Blur Intensity", "Outline intensity value. It is only usable for blurred outlines.");
+ 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.");
+
public static void RenderPreview(OutlineLayer layer, int layerIndex, bool showObjects)
{
if (layer != null)
diff --git a/Outline.Core/Packages/UnityFx.Outline/Editor/Scripts/OutlineLayerCollectionEditor.cs b/Outline.Core/Packages/UnityFx.Outline/Editor/Scripts/OutlineLayerCollectionEditor.cs
index 9a7b838..94e799d 100644
--- a/Outline.Core/Packages/UnityFx.Outline/Editor/Scripts/OutlineLayerCollectionEditor.cs
+++ b/Outline.Core/Packages/UnityFx.Outline/Editor/Scripts/OutlineLayerCollectionEditor.cs
@@ -128,24 +128,24 @@ private void OnDrawLayer(Rect rect, int index, bool isActive, bool isFocused)
{
EditorGUI.BeginDisabledGroup(obj != null);
- color = EditorGUI.ColorField(new Rect(rect.x, y, rect.width, lineHeight), "Color", color);
+ color = EditorGUI.ColorField(new Rect(rect.x, y, rect.width, lineHeight), OutlineEditorUtility.ColorContent, color, true, true, true);
y += lineOffset;
- width = EditorGUI.IntSlider(new Rect(rect.x, y, rect.width, lineHeight), "Width", width, OutlineResources.MinWidth, OutlineResources.MaxWidth);
+ width = EditorGUI.IntSlider(new Rect(rect.x, y, rect.width, lineHeight), OutlineEditorUtility.WidthContent, width, OutlineResources.MinWidth, OutlineResources.MaxWidth);
y += lineOffset;
- renderMode = (OutlineRenderFlags)EditorGUI.EnumFlagsField(new Rect(rect.x, y, rect.width, lineHeight), "Render Flags", renderMode);
+ renderMode = (OutlineRenderFlags)EditorGUI.EnumFlagsField(new Rect(rect.x, y, rect.width, lineHeight), OutlineEditorUtility.RenderFlagsContent, renderMode);
y += lineOffset;
if ((renderMode & OutlineRenderFlags.Blurred) != 0)
{
- blurIntensity = EditorGUI.Slider(new Rect(rect.x, y, rect.width, lineHeight), "Blur Intensity", blurIntensity, OutlineResources.MinIntensity, OutlineResources.MaxIntensity);
+ blurIntensity = EditorGUI.Slider(new Rect(rect.x, y, rect.width, lineHeight), OutlineEditorUtility.BlurIntensityContent, blurIntensity, OutlineResources.MinIntensity, OutlineResources.MaxIntensity);
y += lineOffset;
}
if ((renderMode & OutlineRenderFlags.EnableAlphaTesting) != 0)
{
- alphaCutoff = EditorGUI.Slider(new Rect(rect.x, y, rect.width, lineHeight), "Alpha Cutoff", alphaCutoff, OutlineResources.MinAlphaCutoff, OutlineResources.MaxAlphaCutoff);
+ alphaCutoff = EditorGUI.Slider(new Rect(rect.x, y, rect.width, lineHeight), OutlineEditorUtility.AlphaCutoffContent, alphaCutoff, OutlineResources.MinAlphaCutoff, OutlineResources.MaxAlphaCutoff);
}
EditorGUI.EndDisabledGroup();
diff --git a/Outline.Core/Packages/UnityFx.Outline/Editor/Scripts/OutlineSettingsEditor.cs b/Outline.Core/Packages/UnityFx.Outline/Editor/Scripts/OutlineSettingsEditor.cs
index f9a382a..116c7dc 100644
--- a/Outline.Core/Packages/UnityFx.Outline/Editor/Scripts/OutlineSettingsEditor.cs
+++ b/Outline.Core/Packages/UnityFx.Outline/Editor/Scripts/OutlineSettingsEditor.cs
@@ -22,15 +22,6 @@ public class OutlineSettingsEditor : Editor
private const string _cutoffPropName = "_outlineAlphaCutoff";
private const string _renderModePropName = "_outlineMode";
- private static readonly GUIContent _filterModeContent = new GUIContent("Outline Filter Settings", "");
- private static readonly GUIContent _layerMaskContent = new GUIContent("Layer Mask", OutlineResources.OutlineLayerMaskTooltip);
- private static readonly GUIContent _renderingLayerMaskContent = new GUIContent("Rendering Layer Mask", OutlineResources.OutlineRenderingLayerMaskTooltip);
- private static readonly GUIContent _colorContent = new GUIContent("Color", "Outline color.");
- private static readonly GUIContent _widthContent = new GUIContent("Width", "Outline width in pixels.");
- private static readonly GUIContent _renderModeContent = new GUIContent("Render Flags", "Outline render flags. Multiple values can be selected at the same time.");
- private static readonly GUIContent _intensityContent = new GUIContent("Blur Intensity", "Outline intensity value. It is only usable for blurred outlines.");
- 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.");
-
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
@@ -42,20 +33,22 @@ public override void OnInspectorGUI()
var renderModeProp = serializedObject.FindProperty(_renderModePropName);
var renderMode = (OutlineRenderFlags)renderModeProp.intValue;
- EditorGUILayout.PropertyField(colorProp, _colorContent);
- EditorGUILayout.PropertyField(widthProp, _widthContent);
+ //EditorGUILayout.PropertyField(colorProp, _colorContent);
+ colorProp.colorValue = EditorGUILayout.ColorField(OutlineEditorUtility.ColorContent, colorProp.colorValue, true, true, true);
+
+ EditorGUILayout.PropertyField(widthProp, OutlineEditorUtility.WidthContent);
//EditorGUILayout.PropertyField(renderModeProp, _renderModeContent);
- renderModeProp.intValue = (int)(OutlineRenderFlags)EditorGUILayout.EnumFlagsField(_renderModeContent, renderMode);
+ renderModeProp.intValue = (int)(OutlineRenderFlags)EditorGUILayout.EnumFlagsField(OutlineEditorUtility.RenderFlagsContent, renderMode);
if ((renderMode & OutlineRenderFlags.Blurred) != 0)
{
- EditorGUILayout.PropertyField(intensityProp, _intensityContent);
+ EditorGUILayout.PropertyField(intensityProp, OutlineEditorUtility.BlurIntensityContent);
}
if ((renderMode & OutlineRenderFlags.EnableAlphaTesting) != 0)
{
- EditorGUILayout.PropertyField(cutoffProp, _cutoffContent);
+ EditorGUILayout.PropertyField(cutoffProp, OutlineEditorUtility.AlphaCutoffContent);
}
serializedObject.ApplyModifiedProperties();
@@ -159,14 +152,14 @@ internal static void DrawSettingsWithMask(Rect rc, SerializedProperty property)
var lineCy = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
var filterModeProp = property.FindPropertyRelative(_filterModePropName);
- EditorGUI.PropertyField(new Rect(rc.x, rc.y, rc.width, EditorGUIUtility.singleLineHeight), filterModeProp, _filterModeContent);
+ EditorGUI.PropertyField(new Rect(rc.x, rc.y, rc.width, EditorGUIUtility.singleLineHeight), filterModeProp, OutlineEditorUtility.FilterSettingsContent);
if (filterModeProp.intValue == (int)OutlineFilterMode.UseLayerMask)
{
var layerMaskProp = property.FindPropertyRelative(_layerMaskPropName);
EditorGUI.indentLevel += 1;
- EditorGUI.PropertyField(new Rect(rc.x, rc.y + lineCy, rc.width, EditorGUIUtility.singleLineHeight), layerMaskProp, _layerMaskContent);
+ EditorGUI.PropertyField(new Rect(rc.x, rc.y + lineCy, rc.width, EditorGUIUtility.singleLineHeight), layerMaskProp, OutlineEditorUtility.LayerMaskContent);
EditorGUI.indentLevel -= 1;
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)
var renderingLayerMaskProp = property.FindPropertyRelative(_renderingLayerMaskPropName);
EditorGUI.indentLevel += 1;
- EditorGUI.PropertyField(new Rect(rc.x, rc.y + lineCy, rc.width, EditorGUIUtility.singleLineHeight), renderingLayerMaskProp, _renderingLayerMaskContent);
+ EditorGUI.PropertyField(new Rect(rc.x, rc.y + lineCy, rc.width, EditorGUIUtility.singleLineHeight), renderingLayerMaskProp, OutlineEditorUtility.RenderingLayerMaskContent);
EditorGUI.indentLevel -= 1;
- DrawSettingsInstance(new Rect(rc.x, rc.y + lineCy * 2, rc.width, rc.height - lineCy), property);
+ DrawSettingsInstance(new Rect(rc.x, rc.y + lineCy * 2, rc.width, rc.height - lineCy), property);
}
}
@@ -189,20 +182,22 @@ private static void DrawSettingsInternal(Rect rc, SerializedProperty colorProp,
var lineCy = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
var n = 4;
- EditorGUI.PropertyField(new Rect(rc.x, rc.y + 1 * lineCy, rc.width, EditorGUIUtility.singleLineHeight), colorProp, _colorContent);
- EditorGUI.PropertyField(new Rect(rc.x, rc.y + 2 * lineCy, rc.width, EditorGUIUtility.singleLineHeight), widthProp, _widthContent);
+ //EditorGUI.PropertyField(new Rect(rc.x, rc.y + 1 * lineCy, rc.width, EditorGUIUtility.singleLineHeight), colorProp, _colorContent);
+ colorProp.colorValue = EditorGUI.ColorField(new Rect(rc.x, rc.y + 1 * lineCy, rc.width, EditorGUIUtility.singleLineHeight), OutlineEditorUtility.ColorContent, colorProp.colorValue, true, true, true);
+
+ EditorGUI.PropertyField(new Rect(rc.x, rc.y + 2 * lineCy, rc.width, EditorGUIUtility.singleLineHeight), widthProp, OutlineEditorUtility.WidthContent);
// NOTE: EditorGUI.PropertyField doesn't allow multi-selection, have to use EnumFlagsField explixitly.
- renderModeProp.intValue = (int)(OutlineRenderFlags)EditorGUI.EnumFlagsField(new Rect(rc.x, rc.y + 3 * lineCy, rc.width, EditorGUIUtility.singleLineHeight), _renderModeContent, renderMode);
+ renderModeProp.intValue = (int)(OutlineRenderFlags)EditorGUI.EnumFlagsField(new Rect(rc.x, rc.y + 3 * lineCy, rc.width, EditorGUIUtility.singleLineHeight), OutlineEditorUtility.RenderFlagsContent, renderMode);
if ((renderMode & OutlineRenderFlags.Blurred) != 0)
{
- EditorGUI.PropertyField(new Rect(rc.x, rc.y + n++ * lineCy, rc.width, EditorGUIUtility.singleLineHeight), intensityProp, _intensityContent);
+ EditorGUI.PropertyField(new Rect(rc.x, rc.y + n++ * lineCy, rc.width, EditorGUIUtility.singleLineHeight), intensityProp, OutlineEditorUtility.BlurIntensityContent);
}
if ((renderMode & OutlineRenderFlags.EnableAlphaTesting) != 0)
{
- EditorGUI.PropertyField(new Rect(rc.x, rc.y + n * lineCy, rc.width, EditorGUIUtility.singleLineHeight), cutoffProp, _cutoffContent);
+ EditorGUI.PropertyField(new Rect(rc.x, rc.y + n * lineCy, rc.width, EditorGUIUtility.singleLineHeight), cutoffProp, OutlineEditorUtility.AlphaCutoffContent);
}
}
}
diff --git a/Outline.Core/Packages/UnityFx.Outline/Runtime/Scripts/OutlineResources.cs b/Outline.Core/Packages/UnityFx.Outline/Runtime/Scripts/OutlineResources.cs
index f721ccc..d425b37 100644
--- a/Outline.Core/Packages/UnityFx.Outline/Runtime/Scripts/OutlineResources.cs
+++ b/Outline.Core/Packages/UnityFx.Outline/Runtime/Scripts/OutlineResources.cs
@@ -44,6 +44,9 @@ public sealed class OutlineResources : ScriptableObject
///
/// Maximum value of outline width parameter.
///
+ ///
+ /// If the value is changed here, it should be adjusted in Outline.shader as well.
+ ///
///
public const int MaxWidth = 32;
diff --git a/Outline.Core/Packages/UnityFx.Outline/Runtime/Scripts/Rendering/OutlineRenderer.cs b/Outline.Core/Packages/UnityFx.Outline/Runtime/Scripts/Rendering/OutlineRenderer.cs
index 54cd213..3a351ed 100644
--- a/Outline.Core/Packages/UnityFx.Outline/Runtime/Scripts/Rendering/OutlineRenderer.cs
+++ b/Outline.Core/Packages/UnityFx.Outline/Runtime/Scripts/Rendering/OutlineRenderer.cs
@@ -263,12 +263,13 @@ public void Render(IReadOnlyList renderers, IOutlineSettings settings,
if (renderers.Count > 0)
{
- if (string.IsNullOrEmpty(sampleName))
- {
- sampleName = renderers[0].name;
- }
+ // NOTE: Remove BeginSample/EndSample for now (https://github.com/Arvtesh/UnityFx.Outline/issues/44).
+ //if (string.IsNullOrEmpty(sampleName))
+ //{
+ // sampleName = renderers[0].name;
+ //}
- _commandBuffer.BeginSample(sampleName);
+ //_commandBuffer.BeginSample(sampleName);
{
RenderObjectClear(settings.OutlineRenderMode);
@@ -279,7 +280,7 @@ public void Render(IReadOnlyList renderers, IOutlineSettings settings,
RenderOutline(settings);
}
- _commandBuffer.EndSample(sampleName);
+ //_commandBuffer.EndSample(sampleName);
}
}
@@ -303,18 +304,20 @@ public void Render(Renderer renderer, IOutlineSettings settings, string sampleNa
throw new ArgumentNullException(nameof(settings));
}
- if (string.IsNullOrEmpty(sampleName))
- {
- sampleName = renderer.name;
- }
+ // NOTE: Remove BeginSample/EndSample for now (https://github.com/Arvtesh/UnityFx.Outline/issues/44).
+ //if (string.IsNullOrEmpty(sampleName))
+ //{
+ // sampleName = renderer.name;
+ //}
- _commandBuffer.BeginSample(sampleName);
+ // NOTE: Remove this for now (https://github.com/Arvtesh/UnityFx.Outline/issues/44).
+ //_commandBuffer.BeginSample(sampleName);
{
RenderObjectClear(settings.OutlineRenderMode);
DrawRenderer(renderer, settings);
RenderOutline(settings);
}
- _commandBuffer.EndSample(sampleName);
+ //_commandBuffer.EndSample(sampleName);
}
///
diff --git a/Outline.Core/Packages/UnityFx.Outline/Runtime/Shaders/Outline.shader b/Outline.Core/Packages/UnityFx.Outline/Runtime/Shaders/Outline.shader
index 63cbdcc..41f6332 100644
--- a/Outline.Core/Packages/UnityFx.Outline/Runtime/Shaders/Outline.shader
+++ b/Outline.Core/Packages/UnityFx.Outline/Runtime/Shaders/Outline.shader
@@ -64,17 +64,34 @@ Shader "Hidden/UnityFx/Outline"
#endif
+ float CalcIntensityN0(float2 uv, float2 offset, int k)
+ {
+ return UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv + k * offset).r * _GaussSamples[k];
+ }
+
+ float CalcIntensityN1(float2 uv, float2 offset, int k)
+ {
+ return UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv - k * offset).r * _GaussSamples[k];
+ }
+
float CalcIntensity(float2 uv, float2 offset)
{
float intensity = 0;
// Accumulates horizontal or vertical blur intensity for the specified texture position.
// Set offset = (tx, 0) for horizontal sampling and offset = (0, ty) for vertical.
- for (int k = -_Width; k <= _Width; ++k)
+ //
+ // NOTE: Unroll directive is needed to make the method function on platforms like WebGL 1.0 where loops are not supported.
+ // If maximum outline width is changed here, it should be changed in OutlineResources.MaxWidth as well.
+ //
+ [unroll(32)]
+ for (int k = 1; k <= _Width; ++k)
{
- intensity += UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv + k * offset).r * _GaussSamples[abs(k)];
+ intensity += CalcIntensityN0(uv, offset, k);
+ intensity += CalcIntensityN1(uv, offset, k);
}
+ intensity += CalcIntensityN0(uv, offset, 0);
return intensity;
}
diff --git a/Outline.Core/Packages/UnityFx.Outline/package.json b/Outline.Core/Packages/UnityFx.Outline/package.json
index 8984b03..99bc8c6 100644
--- a/Outline.Core/Packages/UnityFx.Outline/package.json
+++ b/Outline.Core/Packages/UnityFx.Outline/package.json
@@ -1,6 +1,6 @@
{
"name": "com.unityfx.outline",
- "version": "0.8.4",
+ "version": "0.8.5",
"displayName": "Outline toolkit",
"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.",
"unity": "2018.4",
diff --git a/Outline.URP/Packages/UnityFx.Outline.URP/CHANGELOG.md b/Outline.URP/Packages/UnityFx.Outline.URP/CHANGELOG.md
index 3b54861..77008a1 100644
--- a/Outline.URP/Packages/UnityFx.Outline.URP/CHANGELOG.md
+++ b/Outline.URP/Packages/UnityFx.Outline.URP/CHANGELOG.md
@@ -3,6 +3,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/); this project adheres to [Semantic Versioning](http://semver.org/).
+## [0.5.0] - 2021.11.18
+
+Bugfixes and improvements.
+
+### Added
+- Added support for HDR color pickers ([#42](https://github.com/Arvtesh/UnityFx.Outline/issues/42)).
+
+### Fixed
+- 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)).
+- Added loop unroll statement to make shaders compatible with some platforms (WebGL 1.0) ([#45](https://github.com/Arvtesh/UnityFx.Outline/issues/45)).
+- Removed `BeginSample`/`EndSample` profiler calls when rendering outlines to get rid of the editor errors ([#44](https://github.com/Arvtesh/UnityFx.Outline/issues/44)).
+
## [0.4.0] - 2021.08.17
Misc improvements.
diff --git a/Outline.URP/Packages/UnityFx.Outline.URP/Runtime/Scripts/OutlinePass.cs b/Outline.URP/Packages/UnityFx.Outline.URP/Runtime/Scripts/OutlinePass.cs
index 14f4d6f..81de878 100644
--- a/Outline.URP/Packages/UnityFx.Outline.URP/Runtime/Scripts/OutlinePass.cs
+++ b/Outline.URP/Packages/UnityFx.Outline.URP/Runtime/Scripts/OutlinePass.cs
@@ -94,8 +94,9 @@ public override void Execute(ScriptableRenderContext context, ref RenderingData
if (_feature.OutlineLayers)
{
var cmd = CommandBufferPool.Get(OutlineResources.EffectName);
+ var depthTexture = new RenderTargetIdentifier("_CameraDepthTexture");
- using (var renderer = new OutlineRenderer(cmd, outlineResources, _renderer.cameraColorTarget, _renderer.cameraDepth, camData.cameraTargetDescriptor))
+ using (var renderer = new OutlineRenderer(cmd, outlineResources, _renderer.cameraColorTarget, depthTexture /*_renderer.cameraDepth*/, camData.cameraTargetDescriptor))
{
_renderObjects.Clear();
_feature.OutlineLayers.GetRenderObjects(_renderObjects);
diff --git a/Outline.URP/Packages/UnityFx.Outline.URP/Runtime/Shaders/Outline.URP.shader b/Outline.URP/Packages/UnityFx.Outline.URP/Runtime/Shaders/Outline.URP.shader
index 7840e26..ff05f0e 100644
--- a/Outline.URP/Packages/UnityFx.Outline.URP/Runtime/Shaders/Outline.URP.shader
+++ b/Outline.URP/Packages/UnityFx.Outline.URP/Runtime/Shaders/Outline.URP.shader
@@ -75,17 +75,34 @@ Shader "Hidden/UnityFx/Outline.URP"
#endif
+ float CalcIntensityN0(float2 uv, float2 offset, int k)
+ {
+ return SAMPLE_TEXTURE2D_X(_MainTex, sampler_MainTex, uv + k * offset).r * _GaussSamples[k];
+ }
+
+ float CalcIntensityN1(float2 uv, float2 offset, int k)
+ {
+ return SAMPLE_TEXTURE2D_X(_MainTex, sampler_MainTex, uv - k * offset).r * _GaussSamples[k];
+ }
+
float CalcIntensity(float2 uv, float2 offset)
{
float intensity = 0;
// Accumulates horizontal or vertical blur intensity for the specified texture position.
// Set offset = (tx, 0) for horizontal sampling and offset = (0, ty) for vertical.
- for (int k = -_Width; k <= _Width; ++k)
+ //
+ // NOTE: Unroll directive is needed to make the method function on platforms like WebGL 1.0 where loops are not supported.
+ // If maximum outline width is changed here, it should be changed in OutlineResources.MaxWidth as well.
+ //
+ [unroll(32)]
+ for (int k = 1; k <= _Width; ++k)
{
- intensity += SAMPLE_TEXTURE2D_X(_MainTex, sampler_MainTex, uv + k * offset).r * _GaussSamples[abs(k)];
+ intensity += CalcIntensityN0(uv, offset, k);
+ intensity += CalcIntensityN1(uv, offset, k);
}
+ intensity += CalcIntensityN0(uv, offset, 0);
return intensity;
}
diff --git a/Outline.URP/Packages/UnityFx.Outline.URP/package.json b/Outline.URP/Packages/UnityFx.Outline.URP/package.json
index c32398b..8cf173e 100644
--- a/Outline.URP/Packages/UnityFx.Outline.URP/package.json
+++ b/Outline.URP/Packages/UnityFx.Outline.URP/package.json
@@ -1,11 +1,11 @@
{
"name": "com.unityfx.outline.urp",
- "version": "0.4.0",
+ "version": "0.5.0",
"displayName": "Outline toolkit (URP)",
"description": "This package contains configurable outline implementation for Universal Render Pipeline.",
"unity": "2019.4",
"dependencies": {
- "com.unityfx.outline": "0.8.4",
+ "com.unityfx.outline": "0.8.5",
"com.unity.render-pipelines.universal": "7.0.0"
},
"keywords": [
diff --git a/Outline.URP/Packages/packages-lock.json b/Outline.URP/Packages/packages-lock.json
index 51ddcf9..62446e5 100644
--- a/Outline.URP/Packages/packages-lock.json
+++ b/Outline.URP/Packages/packages-lock.json
@@ -84,7 +84,7 @@
"depth": 0,
"source": "embedded",
"dependencies": {
- "com.unityfx.outline": "0.8.3",
+ "com.unityfx.outline": "0.8.5",
"com.unity.render-pipelines.universal": "7.0.0"
}
},
diff --git a/README.md b/README.md
index bcb45b4..cd4e3f5 100644
--- a/README.md
+++ b/README.md
@@ -35,6 +35,7 @@ Supported platforms:
- Windows/Mac standalone;
- Android;
- iOS;
+- WebGL;
- Other platforms (untested).
Please see [CHANGELOG](CHANGELOG.md) for information on recent changes.
@@ -68,8 +69,8 @@ Npm core package is available at [npmjs.com](https://www.npmjs.com/package/com.u
}
],
"dependencies": {
- "com.unityfx.outline": "0.8.4",
- "com.unityfx.outline.urp": "0.4.0",
+ "com.unityfx.outline": "0.8.5",
+ "com.unityfx.outline.urp": "0.5.0",
}
}
```