Gui node ignores texture alpha when texture created dynamically (SOLVED)

Why when I create texture with alpha = 0 and set it to box node the node is still visible?
Texture is created like this:
local w = 200
local h = 100
local red = string.char(0xff) … string.char(0x00) … string.char(0x00) … string.char(0x00)
gui.new_texture(“tx”, w, h, “rgba”, string.rep(red, w * h))
gui.set_texture(gui.get_node(“box”), “tx”)

There’s nothing except “box” node in the scene and node settings are default.

Test project attached:
test.zip (3.6 KB)

The result is this:
image

I think the built-in GUI shader expects the texture to be premultiplied (multiply r, g, and b by a). If you put something underneath your gui box you’ll see that it’s not actually opaque (but not really transparent either…).

4 Likes

That worked, thanks!

1 Like