Seperate Alpha Blending

What it says on the tin: a place to discuss proposed new features.
Post Reply
User avatar
SirShane
Gremlin
Posts: 185
Joined: Thu May 31, 2007 5:36 am
Contact:

Seperate Alpha Blending

Post by SirShane »

Hi guys,

I'm currently working on porting a buffered GUI system over to Ogre, and I have a problem regarding separate alpha channel blending.

Direct3D (And I assume OpenGL as well) supports doing alpha blending on both the color channels and the alpha channels as separate operations. Normally you only need to do blending on the color channel, but when rendering to a render target with an alpha channel on it, you can have issues where the alpha channel is not blended properly and gets replaced.

This is an issue for my GUI because it renders alpha blended polygons into a texture which has an alpha channel. Because Ogre does not seem to support separate alpha channel blending, it produces holes in the texture where the polygons have transparency.

Are there any plans to support separate alpha channel blending? If not, I can probably do it myself and provide a patch. I just want to make sure I'm not going to be re-inventing the wheel.

Thanks. :)
Last edited by SirShane on Thu May 31, 2007 7:47 am, edited 1 time in total.
Shane Parker
Right Brain Games
http://www.rightbraingames.com
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

alpha_op_ex?
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
User avatar
SirShane
Gremlin
Posts: 185
Joined: Thu May 31, 2007 5:36 am
Contact:

Post by SirShane »

I'm not sure exactly what alpha_op_ex is. I don't think it's what i'm looking for. The specific functionality i'm seeking is provided in OpenGL with the function glBlendFuncSeparate and in Direct3D with the state mode D3DRS_SEPARATEALPHABLENDENABLE. It tells the device to blend the alpha and color channels seperately.
Last edited by SirShane on Thu May 31, 2007 7:47 am, edited 1 time in total.
Shane Parker
Right Brain Games
http://www.rightbraingames.com
User avatar
Kencho
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4011
Joined: Fri Sep 19, 2003 6:28 pm
Location: Burgos, Spain
x 2
Contact:

Post by Kencho »

SirShane wrote:I'm not sure exactly what alpha_op_ex is. I don't think it's what i'm looking for.
How can you tell it's not what you're looking for if you haven't read the docs?

It indeed fits your description, as there is both alpha_op_ex and colour_op_ex.
Image
User avatar
SirShane
Gremlin
Posts: 185
Joined: Thu May 31, 2007 5:36 am
Contact:

Post by SirShane »

I've done a search through the Ogre source code for D3DRS_SEPARATEALPHABLENDENABLE in the Direct3D renderer (It does not exist in my copy). If alpha_op_ex sounds like what i'm describing, then I'm probably not explaining it correctly. From what I understand, alpha_op_ex is a fixed-function state for managing the way alpha is blended between texture layers. That's not what i'm looking for. What i'm looking for is a way to manage how scene blending is performed for the alpha channel, seperately from the color channel. This has nothing to do with texture unit blending.
Last edited by SirShane on Thu May 31, 2007 7:47 am, edited 1 time in total.
Shane Parker
Right Brain Games
http://www.rightbraingames.com
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

You can control the blending for the scene separately as well:

http://www.ogre3d.org/docs/manual/manual_16.html#SEC41
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
User avatar
SirShane
Gremlin
Posts: 185
Joined: Thu May 31, 2007 5:36 am
Contact:

Post by SirShane »

scene_blend applies blending to the color channel and the alpha channel using the same algorithm, as far as I can tell. I need a way to set the algorithm used separately: one algorithm for the color channels (RBG) and another for alpha.

For example, we might have the same scene_blend command and then add an additional scene_blend_alpha, which acts like scene_blend but only for the alpha channel.

I apologize if Ogre already provides this functionality, but as far as I can tell it doesn't. The documentation does not talk about it at all, and the source code does not appear to have the code necessary to make it work.
Shane Parker
Right Brain Games
http://www.rightbraingames.com
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
x 8
Contact:

Post by haffax »

Hi SirShane,

I guess you're right, this is indeed not in Ogre. scene_blend is combined, and alpha_op_ex only works between texture units / vertex colours but doesn't respect the current scene pixel.

Your proposal sounds good to me and it doesn't change the old behaviour, so it doesn't break anything. I can't speak for the team but a patch is probably welcome. :)
team-pantheon programmer
creators of Rastullahs Lockenpracht
User avatar
SirShane
Gremlin
Posts: 185
Joined: Thu May 31, 2007 5:36 am
Contact:

Post by SirShane »

Haffax,

Thanks. I'm working on a patch right now and I'll submit it as soon as I test it for both GL and D3D. :)
Shane Parker
Right Brain Games
http://www.rightbraingames.com
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67
Contact:

Post by sinbad »

Yep, we don't do this yet, I've never really thought about it. Guess it's handy for RTT renders, look forward to the patch.

Good to see you back after so long :)
User avatar
SirShane
Gremlin
Posts: 185
Joined: Thu May 31, 2007 5:36 am
Contact:

Post by SirShane »

Hi Sinbad,

I've submitted a patch for this feature here: http://sourceforge.net/tracker/index.ph ... tid=302997
Shane Parker
Right Brain Games
http://www.rightbraingames.com
Post Reply