Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Scaling low resolution keeping sharp pixels on higher res.

Discussion in 'General Graphics' started by chaosmonger, Jul 15, 2023.

  1. chaosmonger

    chaosmonger

    Joined:
    Jan 23, 2019
    Posts:
    68
    Premise: I know Pixel Perfect Camera does something similar, but I'm looking for a solution to avoid Pixel Perfect Camera and actually launching the game on a very low resolution.
    In my case I'm working with a resolution of 426x240. All my level design, UI, characters, etc. are designed to fix an area of 426x240. All work great (except some particles stuff), but all in all, what I'd like is for players to use a resolution of the app set at 426 which scales/adapts to their monitor (this also improves performance).
    Now, I'm unticking "Default is Native Resolution" on the Player Settings, and manually set a 426x240 res.
    But when I test on my UHD monitor (3840x2160), the image is scaled up rather blurry, and I miss the sharpness of my pixels (if I scale in Unity Editor 8X times all is sharp). Is it due to the fact that 426 is not a dividend of 3840? Why a 426x240 scaled window full screen on a 3840x2160 is so blurry? Can't I have a full-screen non-blurred version?
    Any hints?

    P.S. selecting "Exclusive Full Screen" does scale on an integer, but it also changes resolution.
     
    Last edited: Jul 15, 2023
  2. Sluggy

    Sluggy

    Joined:
    Nov 27, 2012
    Posts:
    839
    This has been a problem that has plagued non-CRT monitors since they came into existence. Any non-native resolution will end up using interpolation to scale to the physical limits of the screen. Even resolutions that exactly divide the native resolution have this problem although certain factorization do work better than others.

    You absolutely do not want to make the mistake of forcing the physical resolution to something the end user can't adjust because of this issue. Luckily, the solution that is commonly used is just as simple. Render to a RenderTexture and then display that image scaled to the screen size taking into consideration any ratio differences and needs for letterboxing or such. It's pretty much the way all retro-style games that want to appear to have a consistent pixel size have done it for ages.

    Here's an excerpt of exactly this method as it was used for Hyper Light Drifter.
    https://nightmargin.tumblr.com/post/102886823891/on-resolution
     
  3. chaosmonger

    chaosmonger

    Joined:
    Jan 23, 2019
    Posts:
    68
    Thanks a lot for your reply, appreciated.
    Isn't the Pixel Perfect Camera doing exactly something like that? (render to a texture and then scale?)

    I will look at the link you shared, maybe I'll find more info and solutions.
    Thanks again.
     
  4. Sluggy

    Sluggy

    Joined:
    Nov 27, 2012
    Posts:
    839
    The pixel perfect camera is more about locking positions to world space increments that objects rendered by it are always on exact pixel boundaries so that no sub-pixel scaling occurs which can cause some pixels to appear bigger or smaller than others depending on which way they round. It might also do other things but since I've never used it I can't say for sure.