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.

Coding > Varying degrees of transparency in a background

#55938 - blacksun - Tue Oct 04, 2005 7:13 pm

I was wondering if there is a way to set different transparency values in a tile. What I want is a fully transparent background with 2 grids, and the grids I only want slightly transparent.

#55943 - headspin - Tue Oct 04, 2005 8:17 pm

From Cowbite.

Quote:
- If there is more than one target layer, the blend will only occur for a target with lower priority in areas where it shows through targets of higher priority due to the transparent pixel being set
- Source layers will only blend with areas of a target layer that are visible beneath them. If another layer is blocking the way (even if it is another source layer), there will be no blend and the original source color will be drawn.
- As a result of these two conditions, it is never possible for any given pixel to be a blend of more than 2 layers. This eliminates the possiblity of using these registers to have 3 or more layers of translucent graphics showing through one another.

_________________
Warhawk DS | Manic Miner: The Lost Levels | The Detective Game

#57798 - Palamon - Tue Oct 18, 2005 5:01 pm

So in other words, you can have a full transparent background by using the transparent BG color and use alpha blending to make one grid translucent, but you can't have the two grids at different levels of translucence.

Which is why in games where you shine a light in the darkness, you don't see the ray of light taper off very well.

#57803 - phirewind - Tue Oct 18, 2005 5:32 pm

Unless you use bitmap mode, keep virtual copies of each screen, use a custom blitter to draw your graphics on the appropriate copy, then use your own code to blend all of the layers together and plot each pixel to the display.

Of course, you're probably talking about a pretty serious demand on the CPU and available RAM if you're on the GBA, so whether or not it would work would most likely depend on just how good you manage your other resources.