godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.17k stars 98 forks source link

Allow importing textures with gaussian blurred mipmaps #9998

Open djrain opened 5 months ago

djrain commented 5 months ago

Describe the project you are working on

games

Describe the problem or limitation you are having in your project

For various effects it can be useful to blur a single sprite/texture using textureLod(), for instance a 2D motion blur shader I'm working on. But since the mipmaps are not gaussian blurred when generated, the result looks blocky and ugly:

blurred screen texture

Screenshot 2024-06-18 at 12 57 35 PM

"blurred" sprite

Screenshot 2024-06-18 at 12 57 12 PM

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Add a toggle to the Texture2D import settings to allow gaussian blurred mipmaps. This would allow blurring either the screen texture or an arbitrary texture with the same nice results.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

N/A

If this enhancement will not be used often, can it be worked around with a few lines of script?

No, not efficiently

Is there a reason why this should be core and not an add-on in the asset library?

Not sure if possible through addon, also it kinda just exposes an existing feature to more use cases.

Calinou commented 5 months ago

Thanks for the report! Consolidating in https://github.com/godotengine/godot-proposals/issues/2450.

djrain commented 5 months ago

@Calinou I had seen that proposal and it seemed related at most - it sounds like the opposite of intentional blurring. Could you explain how that would allow to achieve a heavy gaussian blur?

clayjohn commented 5 months ago

I agree. The use case is different. Kaiser filtering is a blur + sharpen whereas Guassian is a very soft blur. Kaiser is used to increase contrast for smaller mipmaps while the proposal here is about having a cheap way of blurring textures in 2D

Alex-Sand-0 commented 6 days ago

hi, I stumbled here looking for a way to slightly blur my mipmaps; the reason I'm interested in blurred mipmaps looks different but the solution would likely be the same. (a flag controlling the mipmap generation, or even better a float controlling the gaussian blur radius)

here is my use case: I have a 2d game with a "free" camera which can be zoomed in/out at will, so not pixel perfect. One big issue in this setting is aliasing effects which makes some pixels flicker when the camera move; especially visible and ugly when the camera slows down. This effect is mostly visible on textures with high contrast between neighboring pixels , which switch from being displayed at their exact color to getting averaged with their neighbour as the camera moves. I "mostly" solved the issue by avoiding textures with too contrasted small details. But when zooming out, some texture mipmaps have these "highly contrasted neighboring pixels", and the aliasing effect is visible there. For these reason I would be interested in slightly blurring the mipmaps, to limit such artefacts.