Skip to content
New issue

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

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

Already on GitHub? # to your account

Soft mask doesn't work with dynamic resolution on Android #227

Closed
Escuedro opened this issue Feb 3, 2025 · 5 comments
Closed

Soft mask doesn't work with dynamic resolution on Android #227

Escuedro opened this issue Feb 3, 2025 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@Escuedro
Copy link

Escuedro commented Feb 3, 2025

I use URP. I have two cameras - main camera which is rendering everything but UI layer and UI camera for UI layer. Main camera is Base, UI camera is Overlay and it's in Main camera's stack. When I use Allow Dynamic Resolution on Main camera - it stops working on Android. It works fine in Editor.

Image

To Reproduce
Steps to reproduce the behavior:

  1. Download minimal project:
    SoftMaskDynamicResolution.zip

  2. Build Android Build

Expected behavior
Working soft mask on Android with Dynamic resolution

Screenshots
How it looks in Editor:

Image

How it looks on Android device:

Image

Environment (please complete the following information):

  • Version 3.2.2
  • Platform: Android
  • Unity version: 2022.3.56f1
  • Build options: IL2CPP, .Net Standard 2.1, URP
@Escuedro Escuedro added the bug Something isn't working label Feb 3, 2025
@mob-sakai
Copy link
Owner

Thank you for your reporting!

@mob-sakai
Copy link
Owner

Hmm, it seems that when AllowDynamicResolution=true, SoftMask may disappear depending on the combination of dynamic resolution and render scale.

  • RenderScale=1、DynamicResolution=(1.0, 1.0): NG
  • RenderScale=0.5、DynamicResolution=(1.0, 1.0): NG
  • RenderScale=0.96、DynamicResolution=(0.9, 0.9): NG
  • RenderScale=0.95、DynamicResolution=(0.9, 0.9): OK
  • RenderScale=1、DynamicResolution=(0.9, 0.9): OK
private void Awake()
{
    const float dynamicResolutionScale = 0.5f;
    const float renderScale = 0.5f;
    
    ScalableBufferManager.ResizeBuffers(dynamicResolutionScale, dynamicResolutionScale);
    var pipelineAsset = GraphicsSettings.currentRenderPipeline;
    if (pipelineAsset)
    {
        pipelineAsset
            .GetType()
            .GetProperty("renderScale")
            .SetValue(pipelineAsset, renderScale);
    }

    camera.allowDynamicResolution = true;
}

@mob-sakai
Copy link
Owner

mob-sakai commented Feb 4, 2025

Solution based on this result: If dynamicResolutionScale=1, set AllowDynamicResolution=false.
Especially for URP, use only RenderScale and set AllowDynamicResolution=false.

@Escuedro
Copy link
Author

Escuedro commented Feb 6, 2025

Thanks, it worked for me! So now when I want to use dynamic resolution, I only call ScalableBufferManager.ResizeBuffers() and change RenderScale

I guess you should mention this case in Limitations

@mob-sakai
Copy link
Owner

That makes sense.
I have updated the README. ✅

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants