Pixel Perfect Camera should NOT have bilinear as a filter mode option.

Every time I open up the editor, I have to manually go into this file and modify it to always return Point to ensure that my art actually looks like nice pixel-perfect pixel art. If I don’t, it looks like blurry garbage. I don’t understand why this is an option to begin with. The whole point of this package is to achieve crisp, pixel-perfect art.

Please fix this.

Thanks.

3 Likes

You can see from the code that the filter mode is set based on the m_Internal.useStretchFill boolean being true. Why is it true?

From the blog post about Pixel Perfect 2D:

[quote]
Stretch Fill – Becomes available if you enable both x and y for Crop Frame. This causes the camera to scale to the game view to fit the screen in a way that preserves aspect ratio. Because this scaling won’t happen only in whole number multiples of the reference resolution, it will cause pixel-perfectness to be lost at any resolution which is not a whole number multiple of the reference resolution. The advantage here is that even though you lose pixel-perfectness for many resolutions, you won’t have the black bar margins and will instead have a fully filled screen. Note that although blurring often occurs from stretch fill, the usual alert display message does not show up.
[/quote]2D Pixel Perfect: How to set up your Unity project for retro 8-bit games

It has the complete opposite effect for my mobile game.

We really need the ability to override the use of the bilinear filter mode. I understand why you have it in place but there’s no reason to not be able to override it. For my game, I do not want it.

Using stretch fill causes the render texture to be stretched to fill the desired resolution, which needs to calculate the required size of the sprites and resize them. Doing this with point filter would be inaccurate as bilinear uses an average to calculate this size.

If this is not desired disable “Stretch Fill”. Could you post some screenshots of your camera view and Pixel Perfect Camera component so we can possibly advise you of your best options.

The problem is I still require the ability to use Stretch Fill and have the filter mode set to Point. Otherwise, I have to manually edit the script every time I open up the editor and before I build.

1 Like

This feature would be welcomed. I can get it working by editing PixelPerfectCamera.cs myself, but obviously that’s not a permanent solution.

But the issue with doing that is you have to change it every time you open Unity!

I can’t believe this isn’t permanent any more, and I can’t believe it hasn’t been added as a toggle. Can I just read-only the file or something?

Like we mentioned in the blogpost, if we stretch an already pixel-perfect image to an arbitrary screen size using point sampling, the pixel-perfectness will be lost, which defeats the whole purpose of the Pixel Perfect Camera.

I understand that might be tolerable for some use cases, but if you can accept a not-pixel-perfect image (meaning you might get swimming pixels if the camera moves), what is the motivation of using Pixel Perfect Camera in the first place? Are there any ‘hidden’ benefits you can get from using this component?

1 Like

Well, the camera is useful for more than just absolute perfectness, it calculates everything properly and is the easiest way of making a pixel-perfectly positioned rendertexture. If it’s still not being planned after all this time and numerous requests for it, I’ll just fork the folder, remove it from package manager and hack the single line in myself.

2 Likes

Oh, and also, I don’t get “swimming pixels” since I work out exactly which resolution will upscale to integers on a 16:9 1920x1080 screen (really doesn’t matter to me on a screen that isn’t 16:9 or 1920x1080).

I think almost anybody making a pixel-art game would rather have swimming pixels and not-so-pixelness to an unbelievably bad bilinear smoothed mess. Seriously, it looks like when you don’t upscale old games in Dosbox and it hits your monitor at the original non-native resolution, nobody in the world wants this.

Of course, you could try to implement the type of bilinear that first upscales to as close as possible by integers, then bilinear smooths the remainder (Sonic Mania does this, Shovel Knight, etc). This has also been mentioned before in great detail (over a year ago on the last thread) but you also don’t seem to like that, so I’ll just have to change that one line to make a practically useless camera tool into an excellent camera tool.

2 Likes

First off that’s not an excuse to add an option, non whole number pixel sizes don’t “defeat the purpose” of anything. Besides there’s already the option to not use upscaled render textures which looks like a slightly scaled down then scaled up version of a normal camera.

6016496--648581--Strectch No Upscale RT.png

6016496--648584--Normal.png

Even if it is flimsy, it’s not even a valid excuse because pixel perfectness isn’t even lost, the only difference is whether or not the implied pixels are whole number multiples of the real pixels or not. When emulating older hardware it’s preferable that there be no filters by default so you can have a more accurate representation of how they would display on digital displays.

You can see that even though the implied pixels aren’t whole number multiples of the real pixels of my display, it doesn’t interfere with the readability of what’s being shown.

6016496--648587--Upscale RT No Stretch.png

6016496--648590--Upscale RT + Stretch (B).png

6016496--648593--Upscale RT + Stretch (P).png

By forcing people to only use bilinear filtering when using stretch fill, your limiting the usability of your tool. It doesn’t matter if you personally find it unappealing some people may find a use for it, especially when there’s no other way to get that result except by using the pixel perfect camera.

It took me an hour to figure out why things were being filtered when I used the stretch fill and took me 10 minutes to fix it for myself. It’s not difficult and it has a use, the least you can do is just add it

2 Likes

I couldn’t agree MORE! What was your solution?

I just copied the folder where the package was saved, changed the PixelPerfectCamera.cs of the copy to my liking, then removed the package then imported my copy

1 Like

This seems to be the accepted practice for this abandoned(?) package.

Thank you all for articulating your rationales behind this. I understand now trading absolute pixel-perfectness for an overall sharper image is oftentimes a valid use case.

Here’s what I’m gonna do:

  • Add an option to disable filtering when Stretch Fill is enabled. This option will be off by default.
  • If you do prefer bilinear filtering when stretching, we’ll fix the excessively blurry image when Upscale Render Texture is also used by first upscaling to the closest pixel perfect resolution before stretching to fill the entire screen.
3 Likes

Awesome! That second option should be very close to how Sonic Mania (and I think Sonic CD) does it, which makes for a very crisp image, but still smooths out any integer jankiness. I will still keep it totally off by default, but this would allow me to add a pixel-friendly smoothing setting for users that won’t blow everything out into a billinear smear.

Sorry to tag along with this, but 2dlight buffer filtermode and shadow (and normal, mask) should also be able to set as point sampling and able to match the screen buffer resolution as well. Right now the light buffer is just set to be screen resolution multiplied by resolution value and all bilinear filtering. We need option to be able select filter mode and match the pixel perfectness set by the pixel perfect camea component.

I just wanted to chime in that this all sounds great, thank you! I’m especially interested in that first point, since not everyone will be on resolutions that can be targeted with perfect integer scales of the reference resolution, being able to offer those players the option of black borders, or stretched with filtering, or stretched with no filtering sounds ideal.