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
2k stars 262 forks source link

Objects inside a SoftMask are not batched together (v2.2.3) #188

Closed ManeFunction closed 1 week ago

ManeFunction commented 2 weeks ago

I have a list of identical objects cloned from the same prefab. Objects contain TMPro text and an Image. In standard conditions they are rendered with 2 draw calls (all the texts + all the images), but If I put my list inside a SoftMask, it applies a custom material to each object, so all the batching is broken. I can confirm the material is different, as I've checked the InstanceID of them.

I've saw that it was the same issue in the past (https://github.com/mob-sakai/SoftMaskForUGUI/issues/76) that was fixed, but looks like it comes back with new features.

Is this a known issue? Is there any active work towards solving this issue? Is there any advices to solve this issue? Or I can freely start to work my own solution to contribute for this? Have a pretty tightly packed schedule for now, but really need this to be fixed, so I would do it myself if no one already on it.

mob-sakai commented 2 weeks ago

Thank you for your reporting! Could you please attach a minimal project (included Assets, Packages and ProjectSettings directories) that reproduces the issue? Of course, you don't need to include any secret assets from your project. Feel free to use free assets instead.

repos

ManeFunction commented 2 weeks ago

Ok, I have this in my work project, that I cannot share, so I would create a blank project reproducing an issue as soon as I can.

mob-sakai commented 2 weeks ago

Ah, I think I've found the cause. It's related to the Use Stencil Outside Screen feature. Please try to disable it by going to Project Settings > UI > Soft Mask > Use Stencil Outside Screen.

image
mob-sakai commented 2 weeks ago

In the Scene view, objects outside the screen are displayed as stencil masks, allowing for more intuitive editing.

mob-sakai commented 2 weeks ago

I think it's necessary to investigate whether this code, which is responsible for generating materials, is even needed. https://github.com/mob-sakai/SoftMaskForUGUI/blob/main/Runtime/SoftMaskable.cs#L123

ManeFunction commented 2 weeks ago

Thank you, this helps. So, it's affecting only in-editor batching, as on device this is always disabled... I think it'll be great to update this feature description with this information shown explicitly to eliminate possible confusion in the future.

github-actions[bot] commented 1 week ago

:tada: This issue has been resolved in version 2.3.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

github-actions[bot] commented 1 week ago

:tada: This issue has been resolved in version 3.0.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: