gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Simplified alpha blending question

#154517 - abszero - Thu Apr 17, 2008 5:09 am

Does the DS' alpha blending system allow for a top layer to blend with all the layers and sprites below it?

My understanding is that it does if you use something like
BLEND_CR = BLEND_ALPHA | BLEND_SRC_BG0 | BLEND_DST_BG1 | BLEND_DST_BG2 | BLEND_DST_BG3 | BLEND_DST_SPRITE

assuming BG0 is the top layer and sprites have an appropriate priority.

Is that correct? Thanks

#154518 - eKid - Thu Apr 17, 2008 5:18 am

That's right, but you also have to set the blending factors in BLEND_AB
Code:

BLEND_AB = 0x0808;

The two bytes in this register are the values affect the first and second alpha blending targets. The value ranges from 0->16 so 8 and 8 will blend the targets half-half. A value of 0x1010 will simply add the pixels together.

#154557 - abszero - Fri Apr 18, 2008 3:08 am

Mhm, I'm doing that as well, and yet I still get inexplicable color saturation...

I'm trying to make a transparent -say 50% for simplicity- blue overlay for the entire screen basically. I can achieve the correct effect by adjusting all the palette entries (averaging them with the desired color) but that won't work long term. However, using blending with the same effective alpha value (0x0808) gives me an entirely different effect, reducing the screen to an apparent palette of two or three shades of blue. This number seems independent of the blend value, so I don't think it's a numeric precision issue, but I guess it might be somehow.