Jump to content

Photo

What percent opacity are transparent layers drawn at?


  • Please log in to reply
6 replies to this topic

#1 Lüt

Lüt

    Germanize

  • Members
  • Real Name:Steve
  • Gender:Male
  • Location:Chicago

Posted 29 September 2018 - 10:04 AM

Here's one for somebody familiar with the ZC code:

 

When I mark a layer as transparent in ZQ's layer menu, then load the quest in ZC, what transparency percentage does the game attempt to render the layer at?

 

I'd assume 50% opacity, but it's really impossible to gauge anything with 8-bit color.

 

Additionally, is it simply a standard transparency, or does it use any special blend methods like multiply, screen, linear light, etc.?


  • Anthus likes this

#2 Avataro

Avataro

    Quest maker

  • Members
  • Real Name:Robin
  • Gender:Male
  • Location:Germany

Posted 29 September 2018 - 10:44 AM

50%. And it just gets the closed fitting colours it can find.



#3 ZoriaRPG

ZoriaRPG

    The Timelord

  • ZC Developers
  • Gender:Unspecified
  • Location:Prydon Academy

Posted 29 September 2018 - 12:54 PM

Allegro has its own internal 8-bit blender. It uses a table of best matching colours from the existing 256-colour palette--no new colours are created by layering. 

 

If you lay red over blue, and you have no violet shades anywhere in your palette, then you'll probably end up with black or grey. 

 

I'm not entirely certain at what opacity it tries to blend. I'd like to say 50%, but I'm not sure. It's rather hard to tell unless you have a suitably ramped palette. In Allegro, with 8bbp graphics, the translucent effect is simply an output option of blitting bitmaps. There's no specified opacity argument.



#4 NoeL

NoeL

    Remilia looks better with grey/green hair.

  • Members
  • Real Name:Jerram
  • Gender:Male

Posted 01 October 2018 - 12:15 AM

Something I'm not sure if anyone has done (but I've always considered doing it myself) is allocate palette space purely for accurate blending. If you limit your transparency use to shadows only, as a single shade of black, you could fairly comfortably find space in the palette for every (important) colour that would be drawn beneath it (csets 10-11 could be reserved purely for the darker sprite colours, and either csets 4 and or 9 for handling level colours). Once you had all the blended colours you could then start to optimise things by removing duplicates or near-duplicates, or potentially even having the blended primary colours form part of the colour ramp itself (for example, if your cset has a light red, a middle red, and a dark red, that dark red could potentially be the same as the middle red blended with the shadow black, so you wouldn't need to use a slot in your "shadow csets" to cover that colour).

 

It's a lot of extra work, and you're sacrificing a fair chunk of your palette just for one-colour transparency, but if you're not using that space anyway you may as well have nice-looking shadows!


  • Sheik likes this

#5 ZoriaRPG

ZoriaRPG

    The Timelord

  • ZC Developers
  • Gender:Unspecified
  • Location:Prydon Academy

Posted 05 October 2018 - 07:39 AM



Something I'm not sure if anyone has done (but I've always considered doing it myself) is allocate palette space purely for accurate blending. If you limit your transparency use to shadows only, as a single shade of black, you could fairly comfortably find space in the palette for every (important) colour that would be drawn beneath it (csets 10-11 could be reserved purely for the darker sprite colours, and either csets 4 and or 9 for handling level colours). Once you had all the blended colours you could then start to optimise things by removing duplicates or near-duplicates, or potentially even having the blended primary colours form part of the colour ramp itself (for example, if your cset has a light red, a middle red, and a dark red, that dark red could potentially be the same as the middle red blended with the shadow black, so you wouldn't need to use a slot in your "shadow csets" to cover that colour).

 

It's a lot of extra work, and you're sacrificing a fair chunk of your palette just for one-colour transparency, but if you're not using that space anyway you may as well have nice-looking shadows!

 

 

I'm adding the ability to set up custom palettes by script, and to script-modify palette values. There's really no way to add additional palette ramps -- ZC uses all 256 indices of the 8b palette -- for transparency. Your best bet is to build a custom ramped palette with varying levels of colour, if you need extremely precise graphics, but then you'll ne using 8b tiles for everything.

 

Allegro automatically selects the transparency colour values. User-definition of the allegro trans_table would require far more in-depth comprehension of the Allegro 4.x library than I'd expect any user to need to, or to want  to know. 

 

I set up palettes like this, and use 8b tiles, when I need this kind of colour precision.

 

c:ramped_pal.png

 

Note that this palette is incomplete. I only added ramps to it that I needed at the time.



#6 NoeL

NoeL

    Remilia looks better with grey/green hair.

  • Members
  • Real Name:Jerram
  • Gender:Male

Posted 06 October 2018 - 03:42 AM

snip

I'm not sure you really understood what I was saying. I'm not suggesting adding more rows to the palette, just using some of the existing rows for "blended" colours. Rows 10-11 for example can be directly edited within ZQ. They're usually used as additional sprite palettes, but if you're sticking with just csets 6-9 for your sprites then you've got 16 free colour slots going unused in just those two rows.

 

Now correct me if I'm wrong, but ZC handles transparency by scanning the 256 colour palette and finding the colour that's closest to a 50/50 blend of the "upper" and "lower" colours (assuming it builds the colour table with 128 for the rgb values), yeah? If so, then you should be able to manually calculate the "perfect" blend of any two colours, and if that blend colour exists in the palette it'll be displayed whenever those two colours are blended.

 

As an example, let's say you're working in the classic set (fewer colours, makes it easier) and you make some solid black shadows for a transparent layer 6. You want Link to look perfect when he's under the shadow (no weird colours or anything), so you take Link's three colour values and average them with the black shadow, giving you a dark green, a dark tan and a dark brown. Take these colours and stick them into cset 10, which isn't being used (though it could also be) but is still part of the 256 colour palette. Now when ZC scans the palette for the most appropriate colours whenever Link's under the shadow it finds these three "perfect" fits in cset 10 and uses them rather than some "close enough" grey or whatever.

 

The classic tileset has so much empty palette space it'd be trivial to set up two, three, maybe even four "blend maps". For most other sets just finding the space for one would be hard enough, and I can't imagine having any more than two unless you really optimise things.


  • Anthus likes this

#7 ZoriaRPG

ZoriaRPG

    The Timelord

  • ZC Developers
  • Gender:Unspecified
  • Location:Prydon Academy

Posted 09 October 2018 - 10:12 PM

I'm not sure you really understood what I was saying. I'm not suggesting adding more rows to the palette, just using some of the existing rows for "blended" colours. Rows 10-11 for example can be directly edited within ZQ. They're usually used as additional sprite palettes, but if you're sticking with just csets 6-9 for your sprites then you've got 16 free colour slots going unused in just those two rows.

 

Now correct me if I'm wrong, but ZC handles transparency by scanning the 256 colour palette and finding the colour that's closest to a 50/50 blend of the "upper" and "lower" colours (assuming it builds the colour table with 128 for the rgb values), yeah? If so, then you should be able to manually calculate the "perfect" blend of any two colours, and if that blend colour exists in the palette it'll be displayed whenever those two colours are blended.

 

As an example, let's say you're working in the classic set (fewer colours, makes it easier) and you make some solid black shadows for a transparent layer 6. You want Link to look perfect when he's under the shadow (no weird colours or anything), so you take Link's three colour values and average them with the black shadow, giving you a dark green, a dark tan and a dark brown. Take these colours and stick them into cset 10, which isn't being used (though it could also be) but is still part of the 256 colour palette. Now when ZC scans the palette for the most appropriate colours whenever Link's under the shadow it finds these three "perfect" fits in cset 10 and uses them rather than some "close enough" grey or whatever.

 

The classic tileset has so much empty palette space it'd be trivial to set up two, three, maybe even four "blend maps". For most other sets just finding the space for one would be hard enough, and I can't imagine having any more than two unless you really optimise things.

 

Ah yes, well, we've been doing that for years. :D




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users