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.

Beginners > Transparency and Alpha channels

#14407 - WillyWonka - Tue Jan 06, 2004 1:55 am

I've been trying to figure out how to program the GBA for a couple of days now and I've read through the 7 GBA junkie tutorials and a number of other ones...

Anyways, I was taking a look at how Sonic Advance is put together in Visual Boy Advance and a couple of things poped up which I can't figure out.

1. When the Sonic Team and Sega logos appear, they have 2 different slide in effects, yet when I look in the background buffer, the final frame is there on background 2, even though it's animating on the screen. How are they doing that? (Mode 0)

2. While introducing the characters they use various background layers as masks. They have a white background with a cutout of sonic and below it they have a blue gradient. How do you punch out that hole in your image? Is there some way to set a specific colour to be 100% transparent? (Mode 0)

3. In the intro Dr. Eggman has a green gem in his hand and there are rays of light rotating around. Now as far as I can make out that's an alpha channel but viewing the top background layer in visual boy's tools just displays what appears to be random garbage. (And it's not a sprite)

They do something similar on the player select screen to fade the characters out by layering white blocks over the characters. Would this just be a background with 100% transparency somewhere and then they set some sort of fade variable?

The GBAJunkie tutorials don't cover this (At least I don't remember reading about these)

#14408 - yaustar - Tue Jan 06, 2004 2:16 am

I think I can answer 1 and 2 correctly but I am still a newbie ;)

1. I think they are just skewing the horizontal lines on the display similar to the way a mode 7 effect works. Probably something like a HBlank

2. The 'Black' cutout is just a transperent colour on the tiles

3. Complete lost, a long shot would be that they are using REG_BLDMOD register with another layer but again: stumped..

Watch as someone corrects me....:(
_________________
[Blog] [Portfolio]

#14411 - Miked0801 - Tue Jan 06, 2004 2:37 am

#3 sounds like a cheapo palette cycle effect - check to see if the palettes are changing :)

Mike

#14412 - DekuTree64 - Tue Jan 06, 2004 2:44 am

Haven't played it in a while so I don't remember what the slide in effects look like, but yeah, they are probably done by setting the BG0HOFS reg on HBlank.
And yes, the mask thing is easy to do. Color 0 is always transparent, so if you just draw what you want to show the gradient as color 0, then you can change the backdrop color (palette entry 0) on HBlank to fade the color down the screen.
And the spotlights are probably done by taking that scrambled mess background and making it partially transparent with REG_BLDMOD, and then using windows to only show part of that background on the screen, and changing the window left/right edges on (you guesed it) HBlank. That's going by my slightly guessing memory that the spotlights kind of have a glittery effect to them, which would be done by scrolling the scramblyness around each frame. That's some pretty advanced stuff though, so don't worry about learning how to do it until you've got a good grasp of the system.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#14426 - WillyWonka - Tue Jan 06, 2004 2:12 pm

Here are some screengrabs of the effects:

http://www.eightlines.com/neil/temp/sonic1.png
http://www.eightlines.com/neil/temp/sonic2.png

Quote:
#3 sounds like a cheapo palette cycle effect


I don't think it is because the rays of light overlap from frame to frame and I don't see any palette shifts.

Quote:
Color 0 is always transparent, so if you just draw what you want to show the gradient as color 0, then you can change the backdrop color (palette entry 0) on HBlank to fade the color down the screen.


Are there any tutorials on the net that you could point me to that demonstrate this?

[mod: feel free to provide a link to images so people can choose if they want to view/load them. thanks]

#14434 - tepples - Tue Jan 06, 2004 5:11 pm

sonic1.png is hblank writes to BG#HOFS.

sonic2.png is hblank writes to WIN0H and WIN1H.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#14441 - yaustar - Tue Jan 06, 2004 7:22 pm

How are the windows registers used to create the effect?
_________________
[Blog] [Portfolio]

#14446 - tepples - Tue Jan 06, 2004 8:07 pm

Game sets up the blend mode to darken the area outside the windows. Then it fills a buffer with the shape of each window, defined as the horizontal extents of the window on each scanline, and schedules an HDMA to write it to the window registers.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#14449 - yaustar - Tue Jan 06, 2004 10:04 pm

ahhh, very clever but perhaps a little to advanced for me....;)
_________________
[Blog] [Portfolio]