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

screen.resolution is expired data. #15973

Closed
smallmain opened this issue Aug 16, 2023 · 7 comments
Closed

screen.resolution is expired data. #15973

smallmain opened this issue Aug 16, 2023 · 7 comments
Labels
Bug Needs Triage Needs to be assigned by the team

Comments

@smallmain
Copy link

Cocos Creator version

3.8.0

System information

MacOS

Issue description

Modify shadingScale, screen.resolution will not be refreshed.

Relevant error log output

No response

Steps to reproduce

RT.

Minimal reproduction project

No response

@smallmain smallmain added Bug Needs Triage Needs to be assigned by the team labels Aug 16, 2023
@dumganhar
Copy link
Contributor

dumganhar commented Dec 7, 2023

screen.resolution is a readonly property, so if you modify its return value directly like screen.resolution.width = xxx;, it will not take effect.

    /**
     * @en Get the current resolution of game.
     * This is a readonly property.
     * @zh 获取当前游戏的分辨率。
     * 这是一个只读属性。
     *
     * @readonly
     */
    public get resolution (): Size {
        return screenAdapter.resolution;
    }

And about shadingScale, did you mean director.root.pipeline.shadingScale?

@smallmain
Copy link
Author

screen.resolution is a readonly property, so if you modify its return value directly like screen.resolution.width = xxx;, it will not take effect.

    /**
     * @en Get the current resolution of game.
     * This is a readonly property.
     * @zh 获取当前游戏的分辨率。
     * 这是一个只读属性。
     *
     * @readonly
     */
    public get resolution (): Size {
        return screenAdapter.resolution;
    }

And about shadingScale, did you mean director.root.pipeline.shadingScale?

Yeah I know, I mean

director.root.pipeline.shadingScale
screen.resolutionScale
screen.resolution

The relationship between these three looks like:

  • resolution in the code is the actual rendering resolution (winSize * resolutionScale)
  • resolutionScale has the same meaning as shadingScale

Modifying resolutionScale will cause shadingScale to change, but modifying shadingScale will not, so resolution has not changed, but the actual rendering resolution has changed.

@dumganhar
Copy link
Contributor

I found screen.resolutionScale method was commented at https://github.com/cocos/cocos-engine/pull/9642/files#diff-be2bdcc494d154ec3dc114bc27094a50d857d8eff8f9f18c122eb342dadc63ed . It was a change from v3.4.0. So you probably could not use screen.resolutionScale now.

I will check this functionality later.

@star-e
Copy link
Contributor

star-e commented Dec 8, 2023

director.root.resize changes screen size. For example window size 1920 x 1080 -> 1280 x 720
director.root.pipeline.shadingScale does not change window size. It changes render pipeline render targets' sizes.
For example, if screen size is 1920 x 1080, shading can be done at 1280 x 720 by changing shading scale, and then copied to 1920 x 1080 screen.
@smallmain

@smallmain
Copy link
Author

director.root.resize changes screen size. For example window size 1920 x 1080 -> 1280 x 720 director.root.pipeline.shadingScale does not change window size. It changes render pipeline render targets' sizes. For example, if screen size is 1920 x 1080, shading can be done at 1280 x 720 by changing shading scale, and then copied to 1920 x 1080 screen. @smallmain

ah, what is the difference between director.root.resize and setting screen.windowSize?

@dumganhar
Copy link
Contributor

cc.screen.windowSize changes the system window size.
director.root.resize changes the rendering target size.

@smallmain
Copy link
Author

smallmain commented Dec 8, 2023

cc.screen.windowSize changes the system window size. director.root.resize changes the rendering target size.

director.root.pipeline.shadingScale does not change window size. It changes render pipeline render targets' sizes.

ah, what is the difference between director.root.resize and setting director.root.pipeline.shadingScale?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Needs to be assigned by the team
Projects
None yet
Development

No branches or pull requests

3 participants