LoTROInterface

LoTROInterface (https://www.lotrointerface.com/forums/index.php)
-   Lua Programming Help (L) (https://www.lotrointerface.com/forums/forumdisplay.php?f=50)
-   -   Transparency with tga images (https://www.lotrointerface.com/forums/showthread.php?t=1152)

Chiran 10-13-2010 07:50 AM

Transparency with tga images
 
I have a problem with making transparency work with tga images. What I have is a control with tga background image displayed on top of a window. The window background is 10% transparent so I'd like that the rounded corners of the tga image blend with the window background. At the moment I'm using 100% black corners which isn't too bad, but it isn't optimal.

I've toyed with the tga alpha channel (making corners black and such) and all the different blending modes but so far I haven't found a combination that would work the way I want. What usually happens is that the corners 'burn' a hole through the window, the image disappears completely, or the whole image burns a hole through the window.

Has anyone else encountered this problem and managed to make it work?

-Chiran

daimon 10-13-2010 08:12 AM

Not sure what you exactly mean. alpha layer is pretty straightforward as you probably know. black is transparent, white not, grey values somewhere between (there's lots of guides to can google about it).

In some rare cases I have noticed if you have a couple of targa files overlapping each others the part where they cross might not show the transparency at all. This applies to skinning however, no idea if it's same with your own LUA windows.

Perhaps up a few screenshots of your problem for us to see and that might help with locating the problem.

Chiran 10-13-2010 08:18 AM

Yes, I can post some pictures later.

Anyway, clearly I can make the corners transparent. But the problem is that it doesn't show the underlying window background under the corners. Instead, the game graphics shine through the corners.

-Chiran

Chiran 10-13-2010 12:21 PM

Here's a few example images.

Left: black button corners and 10% transparent window background (no alpha channel in the tga)
Middle: transparent corners, game graphics shining through
Right: Using Overlay blend mode, corners blend with window background but the underlying quickslot shines through (yeah it's a bit complicated heh)



The images are 300% zoomed so left and right images don't look that bad in-game.

-Chiran

daimon 10-13-2010 12:50 PM

And you tried to use same grey value on those corners in button files as you have on your background (not sure if you mean Overlay Blend term for this) ?

I'm gonna download your plugins to check the files and see if I could help that way. It looks a bit like a bug

daimon 10-13-2010 01:04 PM

Does your button alpha layer look like this (I downloaded the current Songbook that didn't have an alpha layer at all like you said) ?


Chiran 10-13-2010 01:06 PM

Quote:

Originally Posted by daimon (Post 5215)
Does your button alpha layer look like this (I downloaded the current Songbook that didn't have an alpha layer at all like you said) ?


Yes I'm pretty sure I tried that too with the same results.

In those test images the window background is the default black window background with 0.9 window opacity value. And the corners on the middle and right test image alpha channel are 90% white (rgb 230,230,230) while the rest of the image is 100% white. I'm not exactly sure if it's even supposed to work like that.

-Chiran

D.H1cks 10-13-2010 02:22 PM

I think I had a similar problem with alpha blending a custom control with a custom TGA. What I finally did was set the backcolor of the control to the same color as the parent. So in my case, I have a window with a button on it.
Code:

self:SetBackColor(self.bgColor);
self.toggleButton:SetBackColor(self.bgColor);
self.toggleButton:SetBackColorBlendMode(Turbine.UI.BlendMode.AlphaBlend);
self.toggleButton:SetBackground("....... point to tga file .... ");

I have to make sure I always set the back color of my control if I change the color of my window.

Have you tried the same?

Edit: Another possible way is: self.toggleButton:SetBackColorBlendMode(Turbine.UI .BlendMode.Undefined);
Edit2: You need to make sure you use self.toggleButton:SetBlendMode(Turbine.UI.BlendMod e.AlphaBlend); at the same time as the above line.

Chiran 10-13-2010 03:10 PM

Quote:

Originally Posted by D.H1cks (Post 5217)
I have to make sure I always set the back color of my control if I change the color of my window.

Have you tried the same?

Edit: Another possible way is: self.toggleButton:SetBackColorBlendMode(Turbine.UI .BlendMode.Undefined);
Edit2: You need to make sure you use self.toggleButton:SetBlendMode(Turbine.UI.BlendMod e.AlphaBlend); at the same time as the above line.

Oh, have to try that. Putting SetBackColor and SetBackColorBlendmode before SetBackground didn't work for me, but didn't try the second suggestion yet. Maybe something is a bit different in the situation, but the result was an all-black control. I guess I'll have to toy with it a bit more. Thanks for all the suggestions so far :).

-Chiran

Cearbhall 10-14-2010 05:45 PM

try

Code:

element:SetBlendMode(Turbine.UI.BlendMode.AlphaBlend)
element:SetBackColorBlendMode(Turbine.UI.BlendMode.None)
element:SetBackground('path/to/texture.tga')

setting the BackColorBlendMode to None will allow alpha blended texture to be rendered on top of other textures/backgrounds correctly


All times are GMT -5. The time now is 02:52 PM.

vBulletin® - Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© MMOUI