Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ShaderGraph is not working correctly #191

Closed
mob-sakai opened this issue Sep 5, 2024 · 15 comments
Closed

ShaderGraph is not working correctly #191

mob-sakai opened this issue Sep 5, 2024 · 15 comments

Comments

@mob-sakai
Copy link
Owner

          It seems I've encountered a bug after testing. it appears that the bug only occurs when using the Soft Masking mode, which sometimes causes an unknown square to mask some sides of the image that we want to mask.

Masking mode: Soft Masking
UIDefault (SoftMaskable):

Custom ShaderGraph shader:

The other mode appears to be normal.
Masking mode: Anti Aliasing

Masking mode: Normal

I have already tried testing it on the new scene, and the bug appears there as well, but it's not as noticeable as in the current scene I'm using.

Originally posted by @GID0317 in #190 (comment)

@mob-sakai
Copy link
Owner Author

mob-sakai commented Sep 5, 2024

@GID0317

I would like to know more about this issue.
Tell me about your develop/build environment.

  • version [e.g. 2.3.1]
  • Platform: [e.g. Editor(Windows/Mac), Standalone(Windows/Mac), iOS, Android, WebGL]
  • Unity version: [e.g. 6000.0.0f1]
  • Build options: [e.g. IL2CPP, .Net 4.x, URP/HDRP]

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

@GID0317
Copy link

GID0317 commented Sep 5, 2024

Alright, I'll send over the project files later after finishing moving the files to minimal project

@GID0317
Copy link

GID0317 commented Sep 5, 2024

develop/build environment:

  • version: 2.3.1
  • Platform: Editor(Windows 11 23H2), Android
  • Unity version: 6000.0.17f1 (Unity 6 Preview)
  • Build options: IL2CPP, .Net Framework, URP 17.0.3

And here the minimal project files.
ShaderGraphBugReport.zip

@mob-sakai
Copy link
Owner Author

Thank you!

@mob-sakai
Copy link
Owner Author

mob-sakai commented Sep 6, 2024

I'm testing it on 6000.0.16f1.
The issue was reproduced under the following conditions:

  • URP
  • Canvas.renderMode = ScreenSpaceCamera
  • In editor

The same problem exists with Hidden/UI/Default (SoftMaskable).

@mob-sakai
Copy link
Owner Author

mob-sakai commented Sep 6, 2024

Sorry.
Part of my report was a misunderstanding.
Hidden/UI/Default (SoftMaskable) works correctly.

@GID0317
Copy link

GID0317 commented Sep 7, 2024

Thank you for the update. It seems that using Shader Graph with soft mask support along with Canvas.renderMode set to ScreenSpaceCamera can lead to this bug occurring. Are there any workarounds for this issue?

@mob-sakai
Copy link
Owner Author

Are there any workarounds for this issue?

Not at the moment.

Additionally, with Vulkan API, it may be not rendered correctly when the screen rotates.
We might need to use UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION.
https://github.com/mob-sakai/SoftMaskForUGUI/blob/2.3.3/Shaders/SoftMask.cginc#L50-L61

@mob-sakai
Copy link
Owner Author

Maybe we should implement a RendererFeature to fix this.
I don`t know much about RP, but this is a good opportunity to learn.

@GID0317
Copy link

GID0317 commented Sep 8, 2024

Sounds like a good plan! I’m not too familiar with RP RendererFeature either, it’s indeed a great chance to learn. But I think there’s no need to rush since it only affects Canvas.renderMode set to ScreenSpaceCamera with the soft mask mode. We can use another two-mode left that works for now!

@mob-sakai
Copy link
Owner Author

WIP: With a custom RendererFeature, soft masking works correctly in the GameView, and the stencil is enabled in the SceneView.
Umm, it is not perfect... but it provides a slightly improved editor experience.

mob-sakai added a commit that referenced this issue Sep 12, 2024
The renderer feature `SoftMaskable ShaderGraph Support (Editor)` is required in the editor.
![](https://github.com/user-attachments/assets/43dd860d-11dc-4fb5-9cf8-619019a378eb)

:warning: Currently, the soft-maskable ShaderGraph does not display correctly in the SceneView.
@mob-sakai
Copy link
Owner Author

mob-sakai commented Sep 12, 2024

If you are interested you can try the RC version.

"com.coffee.softmask-for-ugui": "https://github.com/mob-sakai/SoftMaskForUGUI.git?path=Packages/src#develop",

For details, see https://github.com/mob-sakai/SoftMaskForUGUI/tree/develop/Packages/src#usage-with-shadergraph

To use the soft-maskable ShaderGraph in the editor, the SoftMaskable ShaderGraph Support (Editor) renderer feature is required.
This feature is specifically for previewing SoftMaskable ShaderGraph in the editor and will be automatically removed during the build process.
SoftMaskable ShaderGraph Support

⚠️ Currently, the soft-maskable ShaderGraph does not display correctly in the SceneView.

@GID0317
Copy link

GID0317 commented Sep 12, 2024

Sure, I'll give it a try later

@GID0317
Copy link

GID0317 commented Sep 13, 2024

Great! It seems the issue has been resolved after trying out the latest RC version
image

github-actions bot pushed a commit that referenced this issue Sep 14, 2024
## [2.3.4](v2.3.3...v2.3.4) (2024-09-14)

### Bug Fixes

* MaskingShapeContainer NullReferenceException in demo ([#195](#195)) ([96a090f](96a090f))
* ShaderGraph is not working correctly ([#191](#191)) ([82c38dd](82c38dd))
* subtract mode `MaskingShape` does not display correctly in the editor ([f83a647](f83a647))
github-actions bot pushed a commit that referenced this issue Sep 14, 2024
The renderer feature `SoftMaskable ShaderGraph Support (Editor)` is required in the editor.
![](https://github.com/user-attachments/assets/43dd860d-11dc-4fb5-9cf8-619019a378eb)

:warning: Currently, the soft-maskable ShaderGraph does not display correctly in the SceneView.
github-actions bot pushed a commit that referenced this issue Sep 14, 2024
## [2.3.4](v2.3.3...v2.3.4) (2024-09-14)

### Bug Fixes

* MaskingShapeContainer NullReferenceException in demo ([#195](#195)) ([96a090f](96a090f))
* ShaderGraph is not working correctly ([#191](#191)) ([82c38dd](82c38dd))
* subtract mode `MaskingShape` does not display correctly in the editor ([f83a647](f83a647))
@mob-sakai
Copy link
Owner Author

🎉 This issue has been resolved in version 2.3.4 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants