Scaling texture created dynamically from image scales its color !?

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

Hello.

So I created inventory UI, it is basically GridContainer ( tried with ItemList too), with texture rects as children. When item is created anew its preview is rendered behind the scenes, creating ImageTexture converted from rendered viewporttexture - and it works, I can save these images, check them out in editor, use it anywhere in sprite2d, their colour is perfect.
I wanted to use these images as previews in inventory grid.

The problem happens when Inventory screen is scaled down due to changing game window size. The smaller inventory parent node is, the more pale color of items get, they are losing brightness and at some point become invisible. Their color is good only at parents scale of 100 %. This effect does not happen when I use any already existing textures, including the very same viewport rendered pictures as long as they were saved as png files instead of created in runtime.

This is very ridicolous problem, is it a thing about storing images ??
This is a process of creating image on the go :

     var img = $Control/ViewportContainer/Viewport.get_texture().get_data()
var bg = Image.new()      #This is supposed to be final images background
bg.create(128,128,true,Image.FORMAT_RGBA8)
img.convert(bg.get_format())
img.resize(128,128)
bg.fill(setcolor(data["tier"]))        # You know, blue for uncommon and so on
bg.blend_rect(img,Rect2(Vector2.ZERO,img.get_size()),Vector2(0,0))
model.queue_free()          #model that was taken picture of is released
var pict = ImageTexture.new()
pict.create_from_image(bg)
$Control/ViewportContainer/Viewport.disable_3d = true   #and studio is too
return pict

does the effect remain if you return the img directly? like

return $Control/ViewportContainer/Viewport.get_texture()

or

var img = $Control/ViewportContainer/Viewport.get_texture().get_data()
var pict = ImageTexture.new()
pict.create_from_image(bg)
return pict

Andrea | 2021-08-24 17:21

Hah, that first option I tried before, and it also gives ridicolous results. It seems that type of viewport texture is always being actualized, it is more like a movie than picture. And so using it directly as preview results in living actual camera view from rendering studio, just like it would be small viewport containers. But the colors were fine back then, however I couldn’t call them textures actually

I tried your other sollution, without colour filled background and it also has colors broken at smaller sizes.

But You made me think and I started experimenting with TEXTURE_FLAGS and TEXTURE_FLAG_ANISOTROPIC_FILTER completely repaired the issue !

Inces | 2021-08-24 20:23