3 ms·
Yeah but when I'm making a game it would be nice to render exactly the right amount of pixels for a desktop display I targeted Firefox and ended up with some b
by 01HNNWZ0MV43FF 1y ago
Yeah but when I'm making a game it would be nice to render exactly the right amount of pixels for a desktop display
I targeted Firefox and ended up with some bonkers magic constant where a pixel was actually like 1.05 pixels or something.
If I don't render enough it'll be blurry. If I render too many it's wasteful. If I am slightly off then the filtering will make it look weird
It's not a phone with a Bayer matrix, it's not VR, I don't know why they have to be weird about it
- SAI_Peregrinus 1y agoIf I play your pixel-exact game on my 21" diagonal 3840x2160 pixel monitor, does it show up as 1/4 the size from when I play it on my 21" diagonal 1920x1080 monitor?
- FrostKiwi 1y agoThat of course depends on the implementation. The point is not the game or the UI ignoring DPI scaling or browser zoom, in fact you would want to support that. The point is, that you cannot do so on a pixel perfect-level across the board, because the widely supported way to do so, DevicePixelRatio, is just that: a ratio with precision issues under certain combinations of screen dpi and browser zoom. The browser can do pixel perfect rendering, it has to for sharp text. But in WebGL there is no reliable way to get the coordinates to do so as well. Browser specific ways to do so exist, but using standard APIs doesn't work browser zooms like 130% or DPI scales like 1.25 in combination with certain resolutions.
- paulddraper 1y agoTo be honest, a lot of what you're saying doesn't make sense. But yes you can have "bonkers" devicePixelRatio. Namely, when the browser is zoomed. Logical pixels measure UI "size." And Physical pixels (logical pixels * devicePixelRatio) is the number of dots. Your game layout should target logical pixels. And rasterization, textures, etc should target physical pixels. If weird devicePixelRatio causes problems with a lot of pixel-exact UI, you may choose to use your own logical pixels that has a rounded devicePixelRatio. --- I have a MacBook with a retina display. Versus a non-retina display, I would not expect that everything is 2x smaller, but rather 2x more detailed (or, if not that, the same level of detail but same size). That important distinction is reason for two different constants.
- FrostKiwi 1y ago> If weird devicePixelRatio causes problems with a lot of pixel-exact UI, you may choose to use your own logical pixels that has a rounded devicePixelRatio. Exactly that is unfortunately not possible, you may or may not get off by one resolution. > I would not expect that everything is 2x smaller Of course. > but rather 2x more detailed That's specifically the thing you cannot guarantee, as sometimes due to lack of standarization, it maybe 2.01x size, leading to those UI elements being the right size, but slightly blurry due to pixel grid mismatches.