mob-sakai / SoftMaskForUGUI

Enhance Unity UI (uGUI) with advanced soft-masking features to create more visually appealing effects!
https://github.com/mob-sakai/SoftMaskForUGUI
MIT License
2.08k stars 269 forks source link

Projection Matrix check always true when using world space canvas #67

Closed AndreasMLarsen closed 4 years ago

AndreasMLarsen commented 4 years ago

When using a World Space camera that is not moving, nowVP and previousVP is never the same causing sm.hasChanged to be set to true. This in turn causes the mask to be drawn every frame.

Steps to reproduce the behavior:

  1. Add a orthographic world space camera and set the culling mask to UI
  2. Add a World Space Canvas and set the layer to UI
  3. Add a Image with the SoftMask script and a child image with the SoftMaskable script

    • Platform: Tested on windows editor and IOS
    • Unity: 2019.2.6f1
    • SoftMaskForUGUI: v0.9.0

I've added a project with a lite version of the setup we are currently running. SoftMaskTest.zip SoftMask

mob-sakai commented 4 years ago

Hi @AndreasMLarsen ,

Thank you for your reporting!

AndreasMLarsen commented 4 years ago

Hi @mob-sakai, I've look through the changes and it doesn't seem to be fixed, however changing line 484-491 from:

#if !UNITY_2018_1_OR_NEWER
s_previousViewProjectionMatrices.Clear ();
foreach (int id in s_previousViewProjectionMatrices.Keys)
{
    s_previousViewProjectionMatrices [id] = s_nowViewProjectionMatrices [id];
}
s_nowViewProjectionMatrices.Clear ();
#endif

to:

s_previousViewProjectionMatrices.Clear ();
foreach (int id in s_nowViewProjectionMatrices.Keys)
{
    s_previousViewProjectionMatrices [id] = s_nowViewProjectionMatrices [id];
}
s_nowViewProjectionMatrices.Clear ();

Seems to work

mob-sakai commented 4 years ago

@AndreasMLarsen

Thanks!