Compare commits
5 Commits
Author | SHA1 | Date |
---|---|---|
|
b870d64b57 | |
|
c85409e56f | |
|
29def6dbe5 | |
|
40b450ba24 | |
|
50c41f29cc |
15
CHANGELOG.md
15
CHANGELOG.md
|
@ -1,3 +1,18 @@
|
||||||
|
## [1.0.2](https://github.com/mob-sakai/SoftMaskForUGUI/compare/1.0.1...1.0.2) (2022-05-15)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* support TextMeshPro v2 or later ([c85409e](https://github.com/mob-sakai/SoftMaskForUGUI/commit/c85409e56ff09607244061c59518f5d1f460a918))
|
||||||
|
|
||||||
|
## [1.0.1](https://github.com/mob-sakai/SoftMaskForUGUI/compare/1.0.0...1.0.1) (2022-05-15)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* applied a workaround to fix a Microsoft HLSL compiler issue ([50c41f2](https://github.com/mob-sakai/SoftMaskForUGUI/commit/50c41f29ccc9b70acdd7f15490debd8eacf5a102)), closes [#131](https://github.com/mob-sakai/SoftMaskForUGUI/issues/131)
|
||||||
|
* fixed shader compilation in some platforms ([40b450b](https://github.com/mob-sakai/SoftMaskForUGUI/commit/40b450ba24e77c34c97fe8411f7b0b1dd103d487))
|
||||||
|
|
||||||
# [1.0.0](https://github.com/mob-sakai/SoftMaskForUGUI/compare/0.9.1...1.0.0) (2021-02-24)
|
# [1.0.0](https://github.com/mob-sakai/SoftMaskForUGUI/compare/0.9.1...1.0.0) (2021-02-24)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -124,8 +124,13 @@ SubShader {
|
||||||
|
|
||||||
#include "UnityCG.cginc"
|
#include "UnityCG.cginc"
|
||||||
#include "UnityUI.cginc"
|
#include "UnityUI.cginc"
|
||||||
|
#if UNITY_VERSION < 201910
|
||||||
#include "Assets/TextMesh Pro/Resources/Shaders/TMPro_Properties.cginc"
|
#include "Assets/TextMesh Pro/Resources/Shaders/TMPro_Properties.cginc"
|
||||||
#include "Assets/TextMesh Pro/Resources/Shaders/TMPro.cginc"
|
#include "Assets/TextMesh Pro/Resources/Shaders/TMPro.cginc"
|
||||||
|
#else
|
||||||
|
#include "Assets/TextMesh Pro/Shaders/TMPro_Properties.cginc"
|
||||||
|
#include "Assets/TextMesh Pro/Shaders/TMPro.cginc"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
|
#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
|
||||||
#pragma shader_feature __ SOFTMASK_EDITOR
|
#pragma shader_feature __ SOFTMASK_EDITOR
|
||||||
|
|
|
@ -93,7 +93,11 @@ SubShader {
|
||||||
|
|
||||||
#include "UnityCG.cginc"
|
#include "UnityCG.cginc"
|
||||||
#include "UnityUI.cginc"
|
#include "UnityUI.cginc"
|
||||||
|
#if UNITY_VERSION < 201910
|
||||||
#include "Assets/TextMesh Pro/Resources/Shaders/TMPro_Properties.cginc"
|
#include "Assets/TextMesh Pro/Resources/Shaders/TMPro_Properties.cginc"
|
||||||
|
#else
|
||||||
|
#include "Assets/TextMesh Pro/Shaders/TMPro_Properties.cginc"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
|
#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
|
||||||
#pragma shader_feature __ SOFTMASK_EDITOR
|
#pragma shader_feature __ SOFTMASK_EDITOR
|
||||||
|
|
|
@ -7,9 +7,21 @@ float4x4 _GameVP;
|
||||||
float4x4 _GameTVP;
|
float4x4 _GameTVP;
|
||||||
half4 _MaskInteraction;
|
half4 _MaskInteraction;
|
||||||
|
|
||||||
|
float CustomStep(float a, float x)
|
||||||
|
{
|
||||||
|
return x >= a;
|
||||||
|
}
|
||||||
|
|
||||||
fixed Approximately(float4x4 a, float4x4 b)
|
fixed Approximately(float4x4 a, float4x4 b)
|
||||||
{
|
{
|
||||||
float4x4 d = abs(a - b);
|
float4x4 d = a - b;
|
||||||
|
d = float4x4(
|
||||||
|
abs(d[0]),
|
||||||
|
abs(d[1]),
|
||||||
|
abs(d[2]),
|
||||||
|
abs(d[3])
|
||||||
|
);
|
||||||
|
|
||||||
return step(
|
return step(
|
||||||
max(d._m00,max(d._m01,max(d._m02,max(d._m03,
|
max(d._m00,max(d._m01,max(d._m02,max(d._m03,
|
||||||
max(d._m10,max(d._m11,max(d._m12,max(d._m13,
|
max(d._m10,max(d._m11,max(d._m12,max(d._m13,
|
||||||
|
@ -30,16 +42,16 @@ float SoftMaskInternal(float4 clipPos)
|
||||||
float4 cpos = mul(_GameTVP, mul(UNITY_MATRIX_M, wpos));
|
float4 cpos = mul(_GameTVP, mul(UNITY_MATRIX_M, wpos));
|
||||||
view = lerp(view, cpos.xy / cpos.w * 0.5 + 0.5, isSceneView);
|
view = lerp(view, cpos.xy / cpos.w * 0.5 + 0.5, isSceneView);
|
||||||
#if UNITY_UV_STARTS_AT_TOP
|
#if UNITY_UV_STARTS_AT_TOP
|
||||||
view.y = lerp(view.y, 1 - view.y, step(0, _ProjectionParams.x));
|
view.y = lerp(view.y, 1 - view.y, CustomStep(0, _ProjectionParams.x));
|
||||||
#endif
|
#endif
|
||||||
#elif UNITY_UV_STARTS_AT_TOP
|
#elif UNITY_UV_STARTS_AT_TOP
|
||||||
view.y = lerp(view.y, 1 - view.y, step(0, _ProjectionParams.x));
|
view.y = lerp(view.y, 1 - view.y, CustomStep(0, _ProjectionParams.x));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fixed4 mask = tex2D(_SoftMaskTex, view);
|
fixed4 mask = tex2D(_SoftMaskTex, view);
|
||||||
half4 alpha = saturate(lerp(fixed4(1, 1, 1, 1), lerp(mask, 1 - mask, _MaskInteraction - 1), _MaskInteraction));
|
half4 alpha = saturate(lerp(fixed4(1, 1, 1, 1), lerp(mask, 1 - mask, _MaskInteraction - 1), _MaskInteraction));
|
||||||
#if SOFTMASK_EDITOR
|
#if SOFTMASK_EDITOR
|
||||||
alpha *= step(0, view.x) * step(view.x, 1) * step(0, view.y) * step(view.y, 1);
|
alpha *= CustomStep(0, view.x) * CustomStep(view.x, 1) * CustomStep(0, view.y) * CustomStep(view.y, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return alpha.x * alpha.y * alpha.z * alpha.w;
|
return alpha.x * alpha.y * alpha.z * alpha.w;
|
||||||
|
@ -53,4 +65,4 @@ float SoftMaskInternal(float4 clipPos)
|
||||||
#define SoftMask(clipPos, worldPosition) SoftMaskInternal(clipPos)
|
#define SoftMask(clipPos, worldPosition) SoftMaskInternal(clipPos)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // UI_SOFTMASK_INCLUDED
|
#endif // UI_SOFTMASK_INCLUDED
|
|
@ -2,7 +2,7 @@
|
||||||
"name": "com.coffee.softmask-for-ugui",
|
"name": "com.coffee.softmask-for-ugui",
|
||||||
"displayName": "UI Soft Mask",
|
"displayName": "UI Soft Mask",
|
||||||
"description": "UI Soft Mask is a smooth masking component for Unity UI (uGUI) elements.\nBy using SoftMask instead of the default Mask component, you can beautifully represent the rounded edges of UI elements.",
|
"description": "UI Soft Mask is a smooth masking component for Unity UI (uGUI) elements.\nBy using SoftMask instead of the default Mask component, you can beautifully represent the rounded edges of UI elements.",
|
||||||
"version": "1.0.0",
|
"version": "1.0.2",
|
||||||
"unity": "2017.1",
|
"unity": "2017.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
Loading…
Reference in New Issue