Alpha blending weirdness on GMA 950

Moderator
Posts: 1,140
Joined: 2005.07
Post: #1
In my cloth demo (thread on that here), which uses the terrain engine I described earlier, I noticed some areas don't work on the GMA 950. These areas are for transitions between up to 4 textures: the sloped and flat textures for the current level mixing with the sloped and flat textures for the next level. To achieve this 4-way blending, I put the 4-way LERP values into the alpha part of the color on each vertex for the 4 layers, one layer representing each texture. I draw the first layer setting the blend function to GL_SRC_ALPHA, GL_ZERO, then on the second layer I set the depth mask to 0 and set the blend function to GL_SRC_ALPHA, GL_ONE and draw the other 3 layers. Afterwards I then reset the depth mask and blend function. It works fine except on the GMA 950, which shows all those areas as the top texture fading to white. I do set the depth function to GL_LEQUAL, so I'm wondering if it's a bug in the implementation or if there's a flaw in my algorithm that makes it work under certain implementations and not in others.
Quote this message in a reply
Moderator
Posts: 133
Joined: 2008.05
Post: #2
Does the GMA 950 support that many texture units? That's my guess.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #3
I never use more than 2 texture units at one time. For this particular case that's showing the problem, I'm only using 1 texture unit at a time. (essentially I bind a new texture each time I render the next layer)

Edit: I can also show a screenshot once my mom gets back on Sunday or so with her MacBook. If somebody else with a GMA 950 wants to check it out, here's the download.
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #4
Your terrain does have some white faces on my Intel Mini (GMA 950 of course). Hope you can get to the bottom of it. The cloth looks cool though, good job!
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #5
Do you use texture combining? If so, it seems the GMA 950 doesn't really like combining, but works fine with shaders that do the same thing.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #6
Actually, it's the other stuff that uses texture combining. Rasp As I said with this one, it's just 1 texture alpha blended. However, I can check to make sure that I'm properly disabling combining before I draw this part.

Edit: there doesn't seem to be much information on texture combiners, so I'll just double check here: this is how I set up the combiner for the texture units:
texture 0:
Code:
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB);

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE0_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE1_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_PRIMARY_COLOR_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_SRC_ALPHA);
texture unit 1:
Code:
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PRIMARY_COLOR_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);

Now this would be before I draw the part with the problem. When I draw the part with the problem, I disable texture unit 1, though some of the textures used would have been binded to texture unit 1 for the interpolation combiner. When I do run the part which has problems, I just bind the texture unit and call glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE). Is this enough to clear out the combiners?
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #7
akb825 Wrote:there doesn't seem to be much information on texture combiners

Here's a big table with links to ARB_texture_env_combine and ARB_texture_env_crossbar.


Quote:texture 0:
Code:
...
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE1_ARB);

You are accessing unit 1 from unit 0's combiner. This is ARB_texture_env_crossbar functionality. The GMA 950 doesn't export ARB_texture_env_crossbar, so I wouldn't expect this to work.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #8
I can run some more tests once I have access to a computer with the GMA 950 again, but I thought the part that used the combiners was working, and the other parts weren't. Regardless, if this is causing the problem, I guess I'll need to have a fallback that either uses complete alpha LERPing or one with shaders. (given the fact that more vertices would cause the GMA 950 to choke, I'd imagine shaders would be the best option)
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #9
Upon closer inspection, it is indeed the part with the texture combiners that aren't working correctly. A few assumptions on my part plus the relatively quick inspection I made earlier made me think the otherwise. Now that that's discovered, is there anything I can do short of using a purely alpha-blended LERP or shader-based fallback?

As an aside, I find it kind of funny that there are a total of 2 cards that don't support that extension on your list: the Rage 128 and the GMA 950. Not quite the class of cards you want the GMA 950 compared to...
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #10
In the GMA's case I'm sure it's not due to a lack of functionality (it can do exactly that in a fragment program, after all). More likely due to the driver engineers not feeling that it's a worthwhile expenditure of investment. It's not like anyone ever used the extension, what with the ATI/NV fight over it, after all.
Quote this message in a reply
Member
Posts: 26
Joined: 2006.09
Post: #11
I was only able to do 3 texture reads on GMA950:

http://www.idevgames.com/forum/showthread.php?t=13636

The driver reports up to 8 native reads, but it does not seem to be the case.
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #12
After hundreds if not thousands GMA 950 users downloaded an older version of GL Golf, I found that the texture blending didn't work and produced ugly results. I never bothered fixing it because a small percentage of my users had the GMA 950 and I figured apple would have something a little better in their macbooks/imacs in the future. Instead I just reverted to an older non-blended texture mode I programmed several years ago.

This post probably isn't that helpful to you, but I just wanted to let you know your not alone with GMA 950 troubles.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #13
I figured out how I could make it work by having texture unit 0 use texture 0 as GL_REPLACE, then have texture unit 1 LERP texture unit 1 and GL_PREVIOUS, then have texture unit 2 modulate GL_PREVIOUS with GL_SRC_COLOR. However, that would also destroy support for the GeForce MX 2 and 4, since they only support 2 texture units. I guess I'll just have a transparent fallback for the GMA 950 that uses fragment shaders. In the meantime, the Rage 128 won't be supported, but in all reality it's so old and slow, I doubt I could support it without making extreme sacrifices in geometry and texture detail.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #14
Has anyone filed radars about their GMA 950 problems?
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #15
I finally got around to working on some of my code, so I figured I might as well follow up on this thread. I have made a solution using texture combiners that uses 3 texture units and works on the GMA 950. I essentially use the first texture unit to simply replace with the current texture, use the second texture unit to interpolate between the previous result and the current texture, and have a third texture unit to modulate with the previous result and primary color for the lighting. After testing it out, I found out it was actually a bit faster than my normal 2-texture unit method (since it doesn't have to reach out to other texture units), so I'm now using that as my main method. If the video card supports less than 3 texture units, it falls back to my 2-texture method I showed earlier. (specifically for the GeForce 2 and 4) Now it should work on all video cards featured on arekkusu's page except for the Rage 128. (which I figure is a lost cause for all but the most basic techniques anyway. Rasp)
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Alpha Blending lbtori 1 2,332 May 1, 2008 01:35 PM
Last Post: TomorrowPlusX
  Weirdness with glClipPlane TomorrowPlusX 12 7,330 Jan 8, 2008 10:36 AM
Last Post: TomorrowPlusX
  general blending versus texture blending questions WhatMeWorry 2 5,259 Dec 7, 2006 02:43 PM
Last Post: arekkusu
  OpenGL weirdness DoG 9 4,140 Oct 31, 2006 04:49 AM
Last Post: DoG
  png without alpha fine, png with alpha, nothing dave05 6 6,952 Jun 11, 2005 10:31 AM
Last Post: dave05