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


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 =      #This is supposed to be final images background
bg.fill(setcolor(data["tier"]))        # You know, blue for uncommon and so on
model.queue_free()          #model that was taken picture of is released
var pict =
$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()


var img = $Control/ViewportContainer/Viewport.get_texture().get_data()
var pict =
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