Opacity

For anything related to VDP (plane, color, sprite, tiles)

Moderators: BigEvilCorporation, Mask of Destiny

elusive
Very interested
Posts: 57
Joined: Fri Jan 27, 2012 12:03 am

Opacity

Post by elusive » Sun Sep 23, 2012 5:37 pm

I know the Genesis/Mega Drive doesn't have hardware opacity for sprites or layers, but I've seen it in a few games where it doesn't look dithered (Crusaders of Centy/Soleil, Adventures of Batman & Robin, etc).

How can this be achieved? I thought I saw something a while back about layers and sprite priorities and messing with that to get a silhouette type of opacity, but I haven't been able to do that.

Any ideas?

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Sun Sep 23, 2012 5:38 pm

Shadow/Highlight mode
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Sun Sep 23, 2012 7:24 pm

Genesis has *limited* hardware transparency support with highlight and shadow effect.

Charles MacDonald
Very interested
Posts: 292
Joined: Sat Apr 21, 2007 1:14 am

Re: Opacity

Post by Charles MacDonald » Sun Sep 23, 2012 10:16 pm

How can this be achieved? I thought I saw something a while back about layers and sprite priorities and messing with that to get a silhouette type of opacity, but I haven't been able to do that.
Here's how it works. I'll use Jackie Chan's Action Kung Fu as it has a clear example:

Image

The background actually looks like this, note that the pillars use a darker palette:

Image

And here are the sprites. The two people are low priority sprites that are defined earlier in the sprite list, and the two pillars with a brighter palette are high priority sprites that are defined _later_ in the sprite list:

Image

When two sprites overlap, the first one defined in the sprite list is drawn. That's why the people are overlapping the pillars in the sprites-only image.

But when the sprite layer is composited with the background layers, the two low-priority people go behind the darker pillar that's drawn on the background layer, and the remaining portion of the sprite pillars appear on top of the background layer:

Image

Here, the dark part of their silhouette is actually the background tiles of the dark pillar you saw in an earlier image.

So the general idea is for transparency is:

1. Draw the graphics you want to see normally as a high priority sprite.
2. Draw identical but darker (or lighter, etc.) graphics on the background layer beneath it.
3. Pass a low priority sprite in the shape of the silhouette you want through them, to reveal the darker background layer through the lighter high priority sprite.

You can use this in a couple of different ways. The background graphics could have been brighter and the sprites could have been darker so you'd have a light silhouette instead of a dark one. Or instead of just changing brightness, the colors could have been changed instead. It could have been a red silhouette appearing through a green pillar.

You can also put low priority sprites behind the background to 'cut out' irregular shapes into high priority sprites that are defined later in the sprite list, like this:

Image

The gray object in the middle is a high priority sprite that is a complete circle. There are two small black circles that are low-priority sprites defined earlier in the list which "cut out" circular chunks of the gray sprite.

But they are behind the background layer so you don't see them, you only see the missing parts of the high priority sprite.

Anyway hope that makes it clearer. :)

elusive
Very interested
Posts: 57
Joined: Fri Jan 27, 2012 12:03 am

Re: Opacity

Post by elusive » Tue Sep 25, 2012 7:20 pm

Thanks Charles! Just a couple of questions:

Does this require shadow/hilight to be enabled?

Also, the character sprites need to be a lower priority early in the list, and the bright pillars are high priority later in the list. Wouldn't that make the character sprites places behind the bright pillars by default, or did you place them in top just as an example?

Thanks!

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Tue Sep 25, 2012 8:04 pm

Charles Mc Donald explained you how to fake transparency by using complex sprite priorities but that has nothing to do with the hilight / shadow effect ;)
Hilight / Shadow permit to increase or decrease color intensity on specific part of plan or sprite.

You can find more infos about hilight / shadow here :
http://www.sega-16.com/forum/showthread ... and-Shadow
Last edited by Stef on Wed Sep 26, 2012 7:56 am, edited 1 time in total.

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Tue Sep 25, 2012 8:35 pm

Stef wrote:Chilly Willy explained you how to fake transparency by using complex sprite priorities but that has nothing to do with the hilight / shadow effect ;)
Hilight / Shadow permit to increase or decrease color intensity on specific part of plan or sprite.

You can find more infos about hilight / shadow here :
http://www.sega-16.com/forum/showthread ... and-Shadow
That wasn't me... :lol:

Charles MacDonald
Very interested
Posts: 292
Joined: Sat Apr 21, 2007 1:14 am

Re: Opacity

Post by Charles MacDonald » Wed Sep 26, 2012 12:49 am

Does this require shadow/hilight to be enabled?
No, but if you want to be creative you can combine shadow/highlight mode with this technique. :)
Also, the character sprites need to be a lower priority early in the list, and the bright pillars are high priority later in the list. Wouldn't that make the character sprites places behind the bright pillars by default, or did you place them in top just as an example?
One thing about the VDP is that it won't draw sprite pixels into a location where an earlier sprite was drawn. This effectively reverses the apparent drawing order for sprites. So early sprite entries in the list are the "topmost" sprites, and later entries are the "bottommost" sprites that will appear to be overlapped by earlier sprites.

In this case of the example, the character sprites are early in the last and drawn completely. The pillar sprites are defined later and are only partially drawn into the areas that the character sprites do not occupy.

Chilly, this was your chance to claim some credit! >_>

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Re: Opacity

Post by Chilly Willy » Wed Sep 26, 2012 4:52 am

Charles MacDonald wrote:Chilly, this was your chance to claim some credit! >_>
:lol:

I've got plenty I can claim... no need to be greedy. 8)

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Wed Sep 26, 2012 7:58 am

Chilly Willy wrote:
Stef wrote:Chilly Willy explained you how to fake transparency by using complex sprite priorities but that has nothing to do with the hilight / shadow effect ;)
Hilight / Shadow permit to increase or decrease color intensity on specific part of plan or sprite.

You can find more infos about hilight / shadow here :
http://www.sega-16.com/forum/showthread ... and-Shadow
That wasn't me... :lol:
Oh yeah sorry, it was Charles Mc Donald :oops:
I guess i did that mistake because your names starts with the same letters ;)

elusive
Very interested
Posts: 57
Joined: Fri Jan 27, 2012 12:03 am

Post by elusive » Wed Sep 26, 2012 6:26 pm

Alright. I got it to work :) I did have to make the the background layer tiles at a high priority as well, otherwise everything you explained was perfect.

What are some of the creative things that can be done with shadow/hilight?

Thanks!

djcouchycouch
Very interested
Posts: 710
Joined: Sat Feb 18, 2012 2:44 am

Post by djcouchycouch » Wed Sep 26, 2012 7:17 pm

elusive wrote: What are some of the creative things that can be done with shadow/hilight?

Thanks!
I thought the castlevania spinning blades trick was pretty nifty! You could create some interesting shapes.

Whenever I get to it, I'd like to pull off a silhouette effect for Goplanes when flying behind big patches of clouds.

Charles MacDonald
Very interested
Posts: 292
Joined: Sat Apr 21, 2007 1:14 am

Post by Charles MacDonald » Wed Sep 26, 2012 8:58 pm

elusive wrote:Alright. I got it to work :) I did have to make the the background layer tiles at a high priority as well, otherwise everything you explained was perfect.
Oops, the devil is in the details.
What are some of the creative things that can be done with shadow/hilight?
As you've probably seen, background tiles with low priority are shown at half brightness and tiles with high priority have normal brightness. This applies to blank tiles too. So you can fill plane A with blank tiles and then set the priority bits to make rectangular areas on plane B that are darker, such as if you wanted a text box printed on plane A to have semi-transparency against plane B.

Or, you can take that rectangular area and then skew it with line scrolling and column scrolling into other shapes. Castlevania does this in one of the later levels to make it look like light is coming in through windows into a hallway, and as you move left to right the angle of the beams tilt accordingly. They are just changing the line-scroll values to move the mix of blank low and high priority tiles around.

You don't have to scroll though. When you open up a skylight in Ranger-X's cave level, they set blank tiles underneath it to high priority so it looks like light is filtering in from above. It looks realistic since the sprites get lighter when they step into it too.

Since shadow and highlight pixels effectively double the number of on-screen colors, some games use a mix of background graphics and shadow/highlight sprites to show static images with more colors than normally possible. You can see this on the Sub-Terrania and Red Zone title screens, as well as the Traveller's Tales logo in Sonic 3D Blast. It's harder to apply this to moving graphics, but doable.

I think the more traditional uses are things like shadows underneath the characters, or highlights against the background like the light you'd get from shining a spotlight at something. Since you can mix shadow/highlight pixels with regular colors in a sprite, you could shade the cockpit glass of a plane or make a character's cape semi-translucent too. I suppose there are a lot of applications.

Personally I was always bummed more games didn't use this mode effectively. I guess homebrew developers can pick up where Sega left off and put it to good use. :D

Oerg866
Very interested
Posts: 211
Joined: Sat Apr 19, 2008 10:58 am
Location: Frankfurt, Germany
Contact:

Re: Opacity

Post by Oerg866 » Thu Sep 27, 2012 2:34 am

Charles MacDonald wrote:
How can this be achieved? I thought I saw something a while back about layers and sprite priorities and messing with that to get a silhouette type of opacity, but I haven't been able to do that.
Here's how it works. I'll use Jackie Chan's Action Kung Fu as it has a clear example:
Great post! Thank you for this explanation (I have to admit my mind was a little blown afterwards :P)

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Thu Sep 27, 2012 3:07 pm

Charles MacDonald wrote: Personally I was always bummed more games didn't use this mode effectively. I guess homebrew developers can pick up where Sega left off and put it to good use. :D
I agree :) The problem is that HS mode add some heavy constraints on priority, you cannot use them freely anymore. Still for almost games HS mode could be used. A good example is the fighter's shadow in mortal kombat 1 game. I really wonder why no more games used HS mode just for that very basic case.

Post Reply