Skip to content

Commit

Permalink
feat: softmask buffers are now baked considering Graphic.color.a
Browse files Browse the repository at this point in the history
  • Loading branch information
mob-sakai committed Jul 21, 2024
1 parent 8080cb2 commit 2eaaad6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Packages/src/Runtime/MaskingShape/MaskingShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ internal void DrawSoftMaskBuffer(CommandBuffer cb, int depth)
_mpb = SoftMaskUtils.materialPropertyBlockPool.Rent();
}

SoftMaskUtils.ApplyMaterialPropertyBlock(_mpb, depth, texture, softnessRange);
SoftMaskUtils.ApplyMaterialPropertyBlock(_mpb, depth, texture, softnessRange, alpha);
var softMaterial = SoftMaskUtils.GetSoftMaskingMaterial(maskingMethod);

cb.DrawMesh(mesh, transform.localToWorldMatrix, softMaterial, 0, 0, _mpb);
Expand Down
2 changes: 1 addition & 1 deletion Packages/src/Runtime/SoftMask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ private void RenderSoftMaskBuffer(CommandBuffer cb, Camera.MonoOrStereoscopicEye

Profiler.BeginSample("(SM4UI)[SoftMask] RenderSoftMaskBuffer > ApplyMaterialPropertyBlock");
var texture = graphic.mainTexture;
SoftMaskUtils.ApplyMaterialPropertyBlock(_mpb, softMaskDepth, texture, softnessRange);
SoftMaskUtils.ApplyMaterialPropertyBlock(_mpb, softMaskDepth, texture, softnessRange, alpha);
Profiler.EndSample();
}

Expand Down
4 changes: 2 additions & 2 deletions Packages/src/Runtime/Utilities/SoftMaskUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ private static void UpdateSubMeshUI(TextMeshProUGUI text, bool show, float aa, M
/// Applies properties to a MaterialPropertyBlock for soft masking.
/// </summary>
public static void ApplyMaterialPropertyBlock(MaterialPropertyBlock mpb, int depth, Texture texture,
MinMax01 threshold)
MinMax01 threshold, float alpha)
{
Profiler.BeginSample("(SM4UI)[SoftMaskUtils] ApplyMaterialPropertyBlock");
var colorMask = Vector4.zero;
colorMask[depth] = 1;
colorMask[depth] = alpha;
mpb.SetVector(s_ColorMask, colorMask);
mpb.SetTexture(s_MainTex, texture ? texture : null);
mpb.SetFloat(s_ThresholdMin, threshold.min);
Expand Down

0 comments on commit 2eaaad6

Please sign in to comment.