Enhance Unity UI (uGUI) with advanced soft-masking features to create more visually appealing effects!
See the code<< ๐ Description | ๐ Key Features | ๐ฎ Demo | โ Installation | ๐ Usage | ๐ค Contributing >>
Enhance Unity UI (uGUI) with advanced soft-masking features to create more visually appealing effects!
Mask component.
You can convert an existing Mask to SoftMask from the context menu.Text, Image, RawImage can be used as a masking graphic.SoftMask supports multiple sprites and SpriteAtlas.SoftMask supports up to 4 nested soft masks.SoftMask supports ScrollRect component.SoftMask supports overlay, camera space, and world space.UI/Dafault.SoftMaskable component will be added automatically at runtime as needed.MaskingShape component.MaskingShape component to inverse masking. You can implement effects such as iris out.TextMeshProUGUI by importing additional shaders.This package requires Unity 2019.4 or later.
openupm add com.coffee.softmask-for-ugui
Window > Package Manager) or run the following command with
@{version}:
openupm add [email protected]
Window > Package Manager to open Package Manager UI.+ > Add package from git URL... and input the repository URL:
https://github.com/mob-sakai/SoftMaskForUGUI.git?path=Packages/src#{version} to the target version.
https://github.com/mob-sakai/SoftMaskForUGUI.git?path=Packages/src#3.2.0Open the Packages/manifest.json file in your project. Then add this package somewhere in the dependencies block:
{
"dependencies": {
"com.coffee.softmask-for-ugui": "https://github.com/mob-sakai/SoftMaskForUGUI.git?path=Packages/src",
...
}
}
To update the package, change suffix #{version} to the target version.
"com.coffee.softmask-for-ugui": "https://github.com/mob-sakai/SoftMaskForUGUI.git?path=Packages/src#3.2.0",Source code (zip) file from Releases and
extract it.<extracted_dir>/Packages/src directory into your project's Packages directory.src directory if needed.Additional resources can be imported to extend functionality.
If you are currently using SoftMaskForUGUI v1.x/v2.x, the following breaking changes are included when upgrading to v3:
(From v1) API changes: Some APIs are obsolete.
SoftMask.alpha: Use Graphic.color.a instead.SoftMask.softness: Use SoftMask.softnessRange instead.SoftMask.partOfParent: Use MaskingShape component instead.SoftMask.ignoreParent: Removed.SoftMask.ignoreSelfGraphic: Removed.SoftMask.ignoreSelfStencil: Removed.SoftMaskable.useStencil: Removed.SoftMaskable.raycastFilter: Use SoftMask.alphaHitTest instead.SoftMaskable.maskInteraction: If you want to use as inverse mask, use MaskingShape component and
MaskingMethod=Subtract.(From v1) SoftMaskable component: SoftMaskable component is no longer required to be added explicitly.
(From v1) SoftMaskable shader: SoftMask() function has been updated with additional arguments.
// Before
color.a *= SoftMask(IN.vertex, IN.worldPosition);
// After
color.a *= SoftMask(IN.vertex, IN.worldPosition, color.a);
(From v2) SoftMaskable shader: SOFTMASKABLE shader feature is now required.
#pragma shader_feature_local _ SOFTMASKABLE
If you are installing via git URL, add ?path=Packages/src.
// v1/v2
"com.coffee.softmask-for-ugui": "https://github.com/mob-sakai/SoftMaskForUGUI.git",
// v3
"com.coffee.softmask-for-ugui": "https://github.com/mob-sakai/SoftMaskForUGUI.git?path=Packages/src",
Hidden/UI/SoftMask, Hidden/UI/TerminalMaskingShape and SoftMaskable shader variants used at runtime must be
registered in the Project Settings.
SoftMask does not display correctly in the player, open/play the scenes or prefabs in the editor. The shader
variants will be automatically registered.To apply these changes automatically, please follow the steps below:
Click Edit > Project Settings to open the Project Settings window and select UI > SoftMask category.
Click Upgrade All Assets For V3 to upgrade the assets.
Dry Run, you can check the changes before upgrading.Add a SoftMask component instead of Mask component.
Or, convert an existing Mask component to SoftMask component from the context menu (Convert To SoftMask).
Adjust the soft mask parameters in the inspector.
(Optional) By placing the MaskingShape component under SoftMask, you can add or remove the masking region.
Enjoy!
RectMask2D is a built-in component that supports soft masking.
SoftMask provides more advanced soft masking.
RenderTexture and soft-maskable shader.RenderTexture or soft-maskable shader, and works faster.Mask component.SoftMasking:
RenderTexture and soft-maskable shader.Project Settings > UI > Soft Mask > Soft Mask Enabled to use this mode.AntiAliasing:
RenderTexture or soft-maskable shader, and works faster.Normal: Same as Unity UI default Mask component.[!TIPS]
SoftMaskablecomponents are added automatically to GameObjects under aSoftMaskcomponent.
If the properties are set to their default values, it is marked asHideFlag.DontSaveand will not be saved in the scene or prefab.
Additive, SubtractSoftMask component.SoftMask component.Auto (Default): Same behavior as before. A mode similar to Masking Method is selected.Additive: When the pointer is within this shape, the raycast is enabled.Subtract: When the pointer is within this shape, the raycast is disabled.Ignore: This shape is ignored in raycast determination.[!TIPS]
MaskingShapecomponent allows you to add or remove the masking region.
PlacingMaskingShapecomponent (with anyGraphic) underSoftMaskcomponent.
[!TIPS] You can use it not only with
SoftMaskcomponent but also withMaskcomponent.
If theMaskingModeisAntiAliasingorNormal, or if you are using theMaskcomponent, theMaskingShapecomponent must be placed above the maskedGraphicin the hierarchy.
This is a limitation based on the stencil mask.
The available features depend on theMasking Mode.
Position (X/Y/Z), Rotation (X/Y/Z), Scale (X/Y/Z), Delta Size (X/Y).[!TIPS]
RectTransformFittercomponent follows the target RectTransform.
You can specify the properties to follow (position, rotation, scale, delta size) withRectTransformFitter.targetProperties.
By combining it with theMaskingShapecomponent, you can implement an effect that displays only the buttons during the tutorial.
You can adjust the project-wide settings for SoftMaskForUGUI. (Edit > Project Settings > UI > Soft Mask)
[!IMPORTANT] The setting file is usually saved in
Assets/ProjectSettings/UISoftMaskProjectSettings.asset. Include this file in your version control system.
The setting file is automatically added as a preloaded asset inProjectSettings/ProjectSettings.asset.
To hot-update the shader variants, seeAdvanced > Pre Load Settings In Build.

Soft Masking mode will behave as Normal mode.Low, Medium, High
SoftMaskable components under SoftMask.
Automatic: SoftMaskable components are added automatically as needed.Manual: You need to add SoftMaskable components explicitly.MaskingShapeContainer and TerminalMaskingShape
components.(SoftMaskable), that shader will be used.Hidden/<shader_name> (SoftMaskable) exists, that shader will be used.UI/Default (SoftMaskable) will be used.Unregistered Variants list.PlayerSettings.preloadedAssets in build.Resources, AssetBundles or Addressables to use this package.UISoftMaskProjectSettings. This allows you to hot update shader variants and presets.private static IEnumerator HotUpdateCoroutine()
{
const string k_SettingsAddress = "Assets/ProjectSettings/UISoftMaskProjectSettings.asset";
yield return Addressables.LoadAssetAsync<UISoftMaskProjectSettings>(k_SettingsAddress);
while (UISoftMaskProjectSettings.shaderVariantCollection.WarmUpProgressively(5) == false) yield return null;
}
var softMask = gameObject.GetComponent<SoftMask>();
softMask.maskingMode = SoftMask.MaskingMode.SoftMasking;
softMask.downSamplingRate = SoftMask.DownSamplingRate.x2;
softMask.softnessRange = new MinMax01(0.5f, 0.75f);
To use SoftMask with TextMeshPro or Spine, you need to import additional resources.
When a shader included in the samples is requested, an import dialog will automatically appear.
Click the Import button.
Alternatively, you can manually import the resources by following these steps:
Open the Package Manager window and select the UI Soft Mask package from the package list.
Click the Import button for each sample to import the required resources.
TextMeshPro SupportTextMeshPro Support (Unity 6)Spine SupportThe assets will be imported under Assets/Samples/UI Soft Mask/{version}.
[!TIP] If you have moved
TMPro_Properties.cgincandTMPro.cgincfrom their default install path (Assets/TextMesh Pro/Shaders/...), you will need to manually update the paths in the shaders underTextMeshPro SupportorTextMeshPro Support (Unity 6).
Here, let's
make UI/Additive
custom shader soft-maskable.
There are two ways to support SoftMask with custom shaders.
// Add the ` (SoftMaskable)` suffix to the shader name.
Shader "UI/Additive (SoftMaskable)"
// Import "SoftMask.cginc" and add shader features.
#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
#pragma shader_feature _ SOFTMASK_EDITOR
#pragma shader_feature_local _ SOFTMASKABLE
// "SoftMask" function returns [0-1]. Multiply this by the final output.
color.a *= SoftMask(IN.vertex, IN.worldPosition, color.a);
UI/Default.// Add the `Hidden/` prefix and ` (SoftMaskable)` suffix to the shader name.
Shader "Hidden/UI/Additive (SoftMaskable)"
// Import "SoftMask.cginc" and add shader features.
#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
#pragma shader_feature _ SOFTMASK_EDITOR
#pragma shader_feature_local _ SOFTMASKABLE
// "SoftMask" function returns [0-1]. Multiply this by the final output.
color.a *= SoftMask(IN.vertex, IN.worldPosition, color.a);
NOTE: Unity 2023.2/6000.0+ is required.
Open the Package Manager window and select the UI Soft Mask package in the package list and click the
ShaderGraph Support > Import button.
The sample includes UIDefault (SoftMaskable).shadergraph and SoftMask.subshadergraph.
You can use the sample as references to make your own shader graph compatible with SoftMask.
(SoftMaskable) at the end of the shader name.SOFTMASK_EDITOR and SOFTMASKABLE as a Boolean Keyword (Shader Feature).Sub Graphs > SoftMask node and connect it to the final alpha output.UIEffect is a package that allows you to intuitively apply rich Unity UI effects.
SoftMaskForUGUI (v3.3.0+) supports UIEffect (v5.6.0+).
When a shader included in the samples is requested, an import dialog will automatically appear.
Click the Import button.
The following are the limitations of SoftMaskForUGUI.
RGB ETC1 (+ Split alpha channel) texture format is not supported.
RGBA ETC2.Hidden/UI/SoftMask, Hidden/UI/TerminalMaskingShape and SoftMaskable shader variants used at runtime must be
registered in the Project Settings.DynamicResolution or RenderScale (URP), the display may not work correctly.
Issues are incredibly valuable to this project:
Pull requests offer a fantastic way to contribute your ideas to this repository.
Please refer to CONTRIBUTING.md
and develop branch.
This is an open-source project developed during my spare time.
If you appreciate it, consider supporting me.
Your support allows me to dedicate more time to development. ๐
180 followers ยท starred Dec 2020
110 followers ยท starred Jan 2026
67 followers ยท starred Jun 2019
6 followers ยท starred Feb 2020
Enhance Unity UI (uGUI) with advanced soft-masking features to create more visually appealing effects!
See the code<< ๐ Description | ๐ Key Features | ๐ฎ Demo | โ Installation | ๐ Usage | ๐ค Contributing >>
Enhance Unity UI (uGUI) with advanced soft-masking features to create more visually appealing effects!
Mask component.
You can convert an existing Mask to SoftMask from the context menu.Text, Image, RawImage can be used as a masking graphic.SoftMask supports multiple sprites and SpriteAtlas.SoftMask supports up to 4 nested soft masks.SoftMask supports ScrollRect component.SoftMask supports overlay, camera space, and world space.UI/Dafault.SoftMaskable component will be added automatically at runtime as needed.MaskingShape component.MaskingShape component to inverse masking. You can implement effects such as iris out.TextMeshProUGUI by importing additional shaders.This package requires Unity 2019.4 or later.
openupm add com.coffee.softmask-for-ugui
Window > Package Manager) or run the following command with
@{version}:
openupm add [email protected]
Window > Package Manager to open Package Manager UI.+ > Add package from git URL... and input the repository URL:
https://github.com/mob-sakai/SoftMaskForUGUI.git?path=Packages/src#{version} to the target version.
https://github.com/mob-sakai/SoftMaskForUGUI.git?path=Packages/src#3.2.0Open the Packages/manifest.json file in your project. Then add this package somewhere in the dependencies block:
{
"dependencies": {
"com.coffee.softmask-for-ugui": "https://github.com/mob-sakai/SoftMaskForUGUI.git?path=Packages/src",
...
}
}
To update the package, change suffix #{version} to the target version.
"com.coffee.softmask-for-ugui": "https://github.com/mob-sakai/SoftMaskForUGUI.git?path=Packages/src#3.2.0",Source code (zip) file from Releases and
extract it.<extracted_dir>/Packages/src directory into your project's Packages directory.src directory if needed.Additional resources can be imported to extend functionality.
If you are currently using SoftMaskForUGUI v1.x/v2.x, the following breaking changes are included when upgrading to v3:
(From v1) API changes: Some APIs are obsolete.
SoftMask.alpha: Use Graphic.color.a instead.SoftMask.softness: Use SoftMask.softnessRange instead.SoftMask.partOfParent: Use MaskingShape component instead.SoftMask.ignoreParent: Removed.SoftMask.ignoreSelfGraphic: Removed.SoftMask.ignoreSelfStencil: Removed.SoftMaskable.useStencil: Removed.SoftMaskable.raycastFilter: Use SoftMask.alphaHitTest instead.SoftMaskable.maskInteraction: If you want to use as inverse mask, use MaskingShape component and
MaskingMethod=Subtract.(From v1) SoftMaskable component: SoftMaskable component is no longer required to be added explicitly.
(From v1) SoftMaskable shader: SoftMask() function has been updated with additional arguments.
// Before
color.a *= SoftMask(IN.vertex, IN.worldPosition);
// After
color.a *= SoftMask(IN.vertex, IN.worldPosition, color.a);
(From v2) SoftMaskable shader: SOFTMASKABLE shader feature is now required.
#pragma shader_feature_local _ SOFTMASKABLE
If you are installing via git URL, add ?path=Packages/src.
// v1/v2
"com.coffee.softmask-for-ugui": "https://github.com/mob-sakai/SoftMaskForUGUI.git",
// v3
"com.coffee.softmask-for-ugui": "https://github.com/mob-sakai/SoftMaskForUGUI.git?path=Packages/src",
Hidden/UI/SoftMask, Hidden/UI/TerminalMaskingShape and SoftMaskable shader variants used at runtime must be
registered in the Project Settings.
SoftMask does not display correctly in the player, open/play the scenes or prefabs in the editor. The shader
variants will be automatically registered.To apply these changes automatically, please follow the steps below:
Click Edit > Project Settings to open the Project Settings window and select UI > SoftMask category.
Click Upgrade All Assets For V3 to upgrade the assets.
Dry Run, you can check the changes before upgrading.Add a SoftMask component instead of Mask component.
Or, convert an existing Mask component to SoftMask component from the context menu (Convert To SoftMask).
Adjust the soft mask parameters in the inspector.
(Optional) By placing the MaskingShape component under SoftMask, you can add or remove the masking region.
Enjoy!
RectMask2D is a built-in component that supports soft masking.
SoftMask provides more advanced soft masking.
RenderTexture and soft-maskable shader.RenderTexture or soft-maskable shader, and works faster.Mask component.SoftMasking:
RenderTexture and soft-maskable shader.Project Settings > UI > Soft Mask > Soft Mask Enabled to use this mode.AntiAliasing:
RenderTexture or soft-maskable shader, and works faster.Normal: Same as Unity UI default Mask component.[!TIPS]
SoftMaskablecomponents are added automatically to GameObjects under aSoftMaskcomponent.
If the properties are set to their default values, it is marked asHideFlag.DontSaveand will not be saved in the scene or prefab.
Additive, SubtractSoftMask component.SoftMask component.Auto (Default): Same behavior as before. A mode similar to Masking Method is selected.Additive: When the pointer is within this shape, the raycast is enabled.Subtract: When the pointer is within this shape, the raycast is disabled.Ignore: This shape is ignored in raycast determination.[!TIPS]
MaskingShapecomponent allows you to add or remove the masking region.
PlacingMaskingShapecomponent (with anyGraphic) underSoftMaskcomponent.
[!TIPS] You can use it not only with
SoftMaskcomponent but also withMaskcomponent.
If theMaskingModeisAntiAliasingorNormal, or if you are using theMaskcomponent, theMaskingShapecomponent must be placed above the maskedGraphicin the hierarchy.
This is a limitation based on the stencil mask.
The available features depend on theMasking Mode.
Position (X/Y/Z), Rotation (X/Y/Z), Scale (X/Y/Z), Delta Size (X/Y).[!TIPS]
RectTransformFittercomponent follows the target RectTransform.
You can specify the properties to follow (position, rotation, scale, delta size) withRectTransformFitter.targetProperties.
By combining it with theMaskingShapecomponent, you can implement an effect that displays only the buttons during the tutorial.
You can adjust the project-wide settings for SoftMaskForUGUI. (Edit > Project Settings > UI > Soft Mask)
[!IMPORTANT] The setting file is usually saved in
Assets/ProjectSettings/UISoftMaskProjectSettings.asset. Include this file in your version control system.
The setting file is automatically added as a preloaded asset inProjectSettings/ProjectSettings.asset.
To hot-update the shader variants, seeAdvanced > Pre Load Settings In Build.

Soft Masking mode will behave as Normal mode.Low, Medium, High
SoftMaskable components under SoftMask.
Automatic: SoftMaskable components are added automatically as needed.Manual: You need to add SoftMaskable components explicitly.MaskingShapeContainer and TerminalMaskingShape
components.(SoftMaskable), that shader will be used.Hidden/<shader_name> (SoftMaskable) exists, that shader will be used.UI/Default (SoftMaskable) will be used.Unregistered Variants list.PlayerSettings.preloadedAssets in build.Resources, AssetBundles or Addressables to use this package.UISoftMaskProjectSettings. This allows you to hot update shader variants and presets.private static IEnumerator HotUpdateCoroutine()
{
const string k_SettingsAddress = "Assets/ProjectSettings/UISoftMaskProjectSettings.asset";
yield return Addressables.LoadAssetAsync<UISoftMaskProjectSettings>(k_SettingsAddress);
while (UISoftMaskProjectSettings.shaderVariantCollection.WarmUpProgressively(5) == false) yield return null;
}
var softMask = gameObject.GetComponent<SoftMask>();
softMask.maskingMode = SoftMask.MaskingMode.SoftMasking;
softMask.downSamplingRate = SoftMask.DownSamplingRate.x2;
softMask.softnessRange = new MinMax01(0.5f, 0.75f);
To use SoftMask with TextMeshPro or Spine, you need to import additional resources.
When a shader included in the samples is requested, an import dialog will automatically appear.
Click the Import button.
Alternatively, you can manually import the resources by following these steps:
Open the Package Manager window and select the UI Soft Mask package from the package list.
Click the Import button for each sample to import the required resources.
TextMeshPro SupportTextMeshPro Support (Unity 6)Spine SupportThe assets will be imported under Assets/Samples/UI Soft Mask/{version}.
[!TIP] If you have moved
TMPro_Properties.cgincandTMPro.cgincfrom their default install path (Assets/TextMesh Pro/Shaders/...), you will need to manually update the paths in the shaders underTextMeshPro SupportorTextMeshPro Support (Unity 6).
Here, let's
make UI/Additive
custom shader soft-maskable.
There are two ways to support SoftMask with custom shaders.
// Add the ` (SoftMaskable)` suffix to the shader name.
Shader "UI/Additive (SoftMaskable)"
// Import "SoftMask.cginc" and add shader features.
#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
#pragma shader_feature _ SOFTMASK_EDITOR
#pragma shader_feature_local _ SOFTMASKABLE
// "SoftMask" function returns [0-1]. Multiply this by the final output.
color.a *= SoftMask(IN.vertex, IN.worldPosition, color.a);
UI/Default.// Add the `Hidden/` prefix and ` (SoftMaskable)` suffix to the shader name.
Shader "Hidden/UI/Additive (SoftMaskable)"
// Import "SoftMask.cginc" and add shader features.
#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
#pragma shader_feature _ SOFTMASK_EDITOR
#pragma shader_feature_local _ SOFTMASKABLE
// "SoftMask" function returns [0-1]. Multiply this by the final output.
color.a *= SoftMask(IN.vertex, IN.worldPosition, color.a);
NOTE: Unity 2023.2/6000.0+ is required.
Open the Package Manager window and select the UI Soft Mask package in the package list and click the
ShaderGraph Support > Import button.
The sample includes UIDefault (SoftMaskable).shadergraph and SoftMask.subshadergraph.
You can use the sample as references to make your own shader graph compatible with SoftMask.
(SoftMaskable) at the end of the shader name.SOFTMASK_EDITOR and SOFTMASKABLE as a Boolean Keyword (Shader Feature).Sub Graphs > SoftMask node and connect it to the final alpha output.UIEffect is a package that allows you to intuitively apply rich Unity UI effects.
SoftMaskForUGUI (v3.3.0+) supports UIEffect (v5.6.0+).
When a shader included in the samples is requested, an import dialog will automatically appear.
Click the Import button.
The following are the limitations of SoftMaskForUGUI.
RGB ETC1 (+ Split alpha channel) texture format is not supported.
RGBA ETC2.Hidden/UI/SoftMask, Hidden/UI/TerminalMaskingShape and SoftMaskable shader variants used at runtime must be
registered in the Project Settings.DynamicResolution or RenderScale (URP), the display may not work correctly.
Issues are incredibly valuable to this project:
Pull requests offer a fantastic way to contribute your ideas to this repository.
Please refer to CONTRIBUTING.md
and develop branch.
This is an open-source project developed during my spare time.
If you appreciate it, consider supporting me.
Your support allows me to dedicate more time to development. ๐
180 followers ยท starred Dec 2020
110 followers ยท starred Jan 2026
67 followers ยท starred Jun 2019
6 followers ยท starred Feb 2020