Dynamic textures filtering

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Ktwru

Is there a way to dynamically enable and disable texture filtering?

I use pixel art, the default is 1 texture pixel to 1 monitor pixel. If some node moves slowly enough, then the movement is jittering, slow jumps in 1 pixel, and this is very noticeable. If I import a texture with filter enabled, then everything looks good, but if the camera zoom is below 1.0, then the image is blurry. I would like to enable filtering at 1.0 zoom and disable at 0.5. Please, help!

:bust_in_silhouette: Reply From: Ktwru

Solved:
Found out it’s ok to just load/preload an image and enable filter in this object flags.

var image = load(“res://src/assets/sprites/tiles.png”)
image.flags |= Texture.FLAG_FILTER # enable filter
image.flags &= ~Texture.FLAG_FILTER # disable filter

It will affect nodes which use “tiles.png” because godot loads resource only once and we patch this loaded instance.