Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Horrible Pixel Scaling in URP

Discussion in 'General Graphics' started by stumpytheangry, Sep 13, 2021.

  1. stumpytheangry

    stumpytheangry

    Joined:
    Jan 13, 2021
    Posts:
    8
    I have an image - it's a 256^256 two-color texture with point-filtering and clamp wrap mode.
    texture256.png


    When I apply this via either default or custom shaders to a cube or plane the pixel scaling is uneven. Individual pixels are totally differently sized with whole rows/columns being different sizes from their neighbours. This is particularly noticeable when zoomed in.

    pixels.png

    I have tried many different image and camera setting combinations but cannot get this image (or those like it) to scale up uniformly.

    I've tried many different sized objects at different distances from the camera and even tried orthographic cameras too.

    Thoughts welcome.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    Basically this is "working as intended". If you scale a texture to a non-integer scale you'll get pixels of different sizes scaled up pixels.

    If you want uniform scaling, you have to calculate the exact scale amount to the current camera projection, screen resolution, object scale, and texture resolution. There are a bunch of Pixel Perfect Camera utilities / assets / tutorials out there to help you get there. Otherwise randomly trying values out is unlikely to ever get you to the exact values you need.
     
  3. Squishyaura

    Squishyaura

    Joined:
    Aug 28, 2016
    Posts:
    3
    @
    Terribly sorry to revive this old thread, but I'm really stuck on this problem. My pixels are rectangular and I don't really understand how to fix it through URP.

    This is my shader graph:
    upload_2022-5-22_2-28-55.png

    Here's how my pixels look in-game (I've set the pixel scaling to 8, to further show the pixel width issue):
    upload_2022-5-22_2-30-9.png
    As you can see, my pixels are wider than their height. Any help how to set up the shader map to fix this would be greatly appreciated. Thanks!