0 votes

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
Godot version godot 3.2 stable
in Engine by (2,434 points)

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

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 TEXTUREFLAGS and TEXTUREFLAGANISOTROPICFILTER completely repaired the issue !

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.