I was wondering my 4k project looks pixelated when I build it in 1080p. My understanding is that unity handles downsampling with no problem. Am I not understanding something or doing something wrong?
I am working on a 2d RPG and I am using Unity version 2022.3.9f1
Maybe you got the concept wrong? If you set the build’s resolution to 1080p then that’s the resolution it gets rendered in, and this isn’t downsampling, it is rendering at 1080p if you set it to render at 1080p in player settings.
Nothing about your project makes it “4k” or any other resolution for that matter. What matters is the display resolution of the build or game view.
Still, it shouldn’t look “pixelated” unless you use upscaling. You may want to add a screenshot of build and editor.
Looks like a scaling issue. I presume the roof may even seem “noisy” while the camera moves. The image of the house may be scaled smaller than the image itself is, thus some pixels are not rendered. This effect is called image aliasing.
Anti-aliasing will fix this only up to some point. Ideally you’ll want to avoid scaling the image smaller than it is. Upscaling is less of an issue.
Now, I understand what you are explaining about scaling because, yes, those two images are approximately 4000 pixels tall and anti-aliasing does help a little bit, but what I fail to understand is why even smaller images, say a 200px x 200px also looks pixelated in the editor and build. In fact, the smaller images look worse. Why are those being downscaled?
The effect you see is the opposite, as in “there are too many pixels in the image and not all of them get displayed”. This is aliasing. Let’s say every third pixel in a row is not rendered, and you have very thin lines, and that pixel is part of the line, then that line disappears. Especially while the camera moves, this leads to an on/off kind of flickering of fine details.
This probably has to do with camera zoom. If you want crisp 2d images you’d have to use orthographic projection at a scale of 1x. If you move the camera further away (which I think the 20x does) then the images get smaller and thus you get aliasing.
Yes, I understand. So, if my calculations are correct, right now, my 4000 pixels tall asset with the orthographic projection set at a scale of 20x is being reduced to 54% or 2160 pixels tall, which makes it fit exactly into a 4k screen. If I build the game at 1080p resolution, it is further reduced another 50%, hence the aliasing.
So perhaps you could tell if my current assumption is correct. Right now, for me, 1 unit in Unity is 100 pixels. I calculated that with an orthographic projection set at a scale of 10.8x, I would get 2160 pixels in height (10.8 x 100 = 2160). I confirmed this by making an image exactly 2160 pixels tall by 3840 wide; it fit perfectly into a 4k screen with the orthographic projection set at a scale of 10.8x . Now for my questions/assumptions:
Does this mean that in Unity, at an orthographic projection set at a scale of 10.8x, no asset is ever resized?
Is the unit size in Unity always 100 pixels? Or is there a way of changing this unit size?
Yeah, there’s a setting called ppu (pixels per unit). You should be able to set it for each sprite in the import settings. 100 is the default but you can set it to whatever you want.