godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.34k stars 21.06k forks source link

Texture preview in the editor always uses filtering, even for very low-resolution textures #60150

Closed h0lley closed 2 years ago

h0lley commented 2 years ago

Godot version

v4.0.alpha6.official [e4f0fc50f]

System information

Ubuntu, Windows

Issue description

For projects that use mainly pixel art assets, all previews are displayed blurry now.

Godot 3.5 to the left, and 4 alpha to the right.

shrroms

Since the filter setting is now no longer stored with the imported resource, perhaps it could be solved via an editor setting. Alternatively, perhaps it could use different filters based on texture resolution.

Steps to reproduce

  1. In the FileSystem panel, double-click any low res pixel art sprite to preview it the inspecor
  2. Notice it being blurry

Minimal reproduction project

No response

Calinou commented 2 years ago

Related to https://github.com/godotengine/godot/issues/57550 and https://github.com/godotengine/godot/issues/52332.

My suggestion is to detect the image size and the rendered preview size, and use nearest-neighbor filtering if the scale factor is greater than or equal to 4.0. This is similar to what image editors such as GIMP do.

Alternatively, if drawing the image as large as possible isn't important, integer scaling can be forced and filtering can always be disabled. Either solution is good to me.

riazey commented 2 years ago

A few extra areas to tack on so it doesn't get missed in testing juuuust in case!

The blurriness affects shaders that are pulling color from a sampler2D which is small in size, like say a pixel color palette in a color replacement shader because it pulls the color from the blurred image~ (Including global shader params)

Using edit region on pixel art is a bit of a "guess which pixel is the edge" game~ xD