0
W trakcie analizy

Scene Color makes point-sampled pixels slightly blurry

Shadi Muklashy 10 lat temu Ostatnio zmodyfikowane przez Freya Holmér (Developer) 9 lat temu 9
I'm working on a game that uses point-sampling for 2D sprites to preserve hard edges. If I try and have a mesh over the game using the Scene Color node (to apply post-effects to the scene behind it), the pixels are slightly blurry and lose their hard-edge nearest-neighbor look. Any ideas? Here's an image showing the simple shader and the (subtle) difference in the look.

Image 263

Odpowiedź

Odpowiedź
To nie jest błąd
It's OpenGL vs DirectX coordinate system discrepancies most likely. DX is Microsoft only (Xbox & Windows)
Actually this doesn't appear to be happening on my Mac. It only happens on my Windows 7 machine.
W trakcie analizy
That's quite strange. There might be some half-pixel offset issues, but I'm not quire sure. Try using the Scene UVs node and offset the UVs by half a pixel, using the screen parameters node.
Yes, that seems to be correct. Modifying the output by a half-pixel seems to correct it and it's perfectly sharp after that. Here's what I did to modify it, and this fixes it. However, it is interesting that it was already perfect on Mac, but this half-pixel offset is only an issue on Windows.

Odpowiedź
To nie jest błąd
It's OpenGL vs DirectX coordinate system discrepancies most likely. DX is Microsoft only (Xbox & Windows)
Also, you can append before the divide and add, making the graph a bit cleaner :)
Ah I see, thanks for the info. Is this an exception I can somehow make on my end, or is this something to be fixed in a future Shader Forge update? Also, thanks for pointing out my shameful rookie mistakes... I'm still new to shader editing. :)
I solved this issue by using the Code node, and essentially adding 0.0 or 0.5 to the pixels offset depending on platform. Hopefully this isn't too expensive:

Actually I just discovered that this pixel offset for Direct3D 11 is the same as OpenGL, so both of those are sharp. However if I adjust for non-OpenGL (as in the example here), then one of the Direct3D's (9 or 11) will be blurry. I can maybe check for each version of Direct3D, but do you think this subpixel offset can be built into shader forge?
W trakcie analizy
It should be, yeah