Author Topic: Paletted 8bit -> 24bit shading.  (Read 49283 times)

Offline pmprog

  • Commander
  • *****
  • Posts: 647
  • Contributor
    • View Profile
    • Polymath Programming
Re: Paletted 8bit -> 24bit shading.
« Reply #30 on: January 24, 2013, 11:41:18 am »
You could also do this on a reverse scale

So as your "brightness" decreases from 255 to 0, your blue tint increases

A scale like this should look pretty reasonable

Light LevelBlue Tint
2550
2200
1920
1280
9616
6432
3248
1664
096

Offline darkestaxe

  • Colonel
  • ****
  • Posts: 254
  • Emissary of the Brain
    • View Profile
Re: Paletted 8bit -> 24bit shading.
« Reply #31 on: January 25, 2013, 07:10:49 am »
I would like to point out that UFO:TTS battlescape art is all 24/32bit and was drawn specifically for TTS, not converted from X-COM. TTS art could be used to test how shading algorithms work on 24bit or 32bit art but is not a good comparison of what 6-8bit index based art looks like in a 24bit renderer.
« Last Edit: January 25, 2013, 07:12:57 am by darkestaxe »

Volutar

  • Guest
Re: Paletted 8bit -> 24bit shading.
« Reply #32 on: January 25, 2013, 07:27:30 am »
darkestaxe, original graphics will do fine for 24bit testing... just convert them on the fly into 24bit (with certain light level), and then use it with 24bit lighting/shading applied.

Offline darkestaxe

  • Colonel
  • ****
  • Posts: 254
  • Emissary of the Brain
    • View Profile
Re: Paletted 8bit -> 24bit shading.
« Reply #33 on: January 28, 2013, 12:38:30 am »
As long as new 24bit textures only ever see normal 24 bit rendering there wouldn't be an execution problem, but two objects may appear to react very differently to lighting if the two objects have different systems for calculating lighting.

I was talking about testing what would be used in both cases to see what happens when both are on the screen at the same time. If you're new tree texture uses full 24bit and the grass is still the original 8bit index texture, then will the two textures look weird next too each-other in different lighting conditions? Another-words if they look fine at first, will they look weird after you drop an electro-flare by the tree?

The other reason I pointed out TTS as being 24bit was a comment by SupSuper that 24bit lighting in TTS looks fine without any special rendering. I didn't think he realized TTS textures were originals drawn in 24bit with Illustrator or PaintShop.

I think I see a problem with converting 8bit to 24 bit at a given light level at the start of a mission: I'm not sure how many different possible light levels a tile can be at on a given mission but even if it's only 32 and a ground texture is only 64x64px that's 4mb per texture tile at 24bit color and 8bit alpha. I'm not sure what the actual texture resolutions are or how many are loaded per battlescape, but I'm estimating well over 200 in my head for a terror site including unit animations. That would be about 800mb, which seems like a lot to me.

Volutar

  • Guest
Re: Paletted 8bit -> 24bit shading.
« Reply #34 on: January 28, 2013, 04:08:05 am »
I don't know what math do you use, but texture of resolution 64x64 with 32bit (RGBA) will be 16kbytes only. Texture atlas with 256 of those will be 8Mbyte only. If you make those pre-rendered for different light levels (there's only 16 of them) - it will be 128Mbytes, not 800. And that would work only for original, paletted graphics. If you try to use same technique with "TTS set" you'll fail, because there's no "colorgroup" info in those sprites.
« Last Edit: January 28, 2013, 04:12:19 am by Volutar »

Offline pmprog

  • Commander
  • *****
  • Posts: 647
  • Contributor
    • View Profile
    • Polymath Programming
Re: Paletted 8bit -> 24bit shading.
« Reply #35 on: January 28, 2013, 09:44:11 am »
I don't know what math do you use, but texture of resolution 64x64 with 32bit (RGBA) will be 16kbytes only.
Darkestaxe is then talking about 32 versions of the 64x64 for lighting; Though this will still only be 0.5MB (512KB)

Offline karvanit

  • Captain
  • ***
  • Posts: 94
    • View Profile
Re: Paletted 8bit -> 24bit shading.
« Reply #36 on: January 28, 2013, 01:14:19 pm »
Having every shaded version in memory at the same time is very expensive because we may have (by definition) 256 different tiles. And 256 different NW and 256 different NE and 256 different center objects. Which adds fast to huge amounts of memory.

Going to 32 bits of colour (RGBA), with premultiplied Alpha, allows us to do tinting and lighting as a simple shader (I think) or alpha blending (I know). We may lose some of the original colours, but we are talking about a visual overhaul anyway. And we get room / possibilities of many more effects, like properly transparent smoke,  translucent flames, grayscale-as-fog-of-war and depth bluring at almost no extra cost.

Volutar

  • Guest
Re: Paletted 8bit -> 24bit shading.
« Reply #37 on: January 28, 2013, 01:34:43 pm »
pmprog,
1. 64x64x32bit = 16kbytes, 256 of them is 4mbytes.
2. there are only 16 light levels in xcom1, so it would be 64 mbytes. even 32 levels would be only 128mbytes.

karvanit,
why 256 nw and 256 ne? there's only ONE tile set per map. and there's a limit of 256 tiles per map. though it may have animated tiles (but there are only few of them), which _slightly_ increase overall sprites count.
but the thing is - units also need to be "shaded" properly, though they could be flat shaded.

and still, that would work only for 8bit original graphics. still no way of such "oldschool" shading for 32bit "HD" sprites from TTS.

Offline pmprog

  • Commander
  • *****
  • Posts: 647
  • Contributor
    • View Profile
    • Polymath Programming
Re: Paletted 8bit -> 24bit shading.
« Reply #38 on: January 28, 2013, 02:08:48 pm »
pmprog,
1. 64x64x32bit = 16kbytes, 256 of them is 4mbytes.
2. there are only 16 light levels in xcom1, so it would be 64 mbytes. even 32 levels would be only 128mbytes.

I read this (my highlights):
I'm not sure how many different possible light levels a tile can be at on a given mission but even if it's only 32 and a ground texture is only 64x64px that's 4mb per texture tile
I was only talking about a single tile; but it doesn't really matter

Offline karvanit

  • Captain
  • ***
  • Posts: 94
    • View Profile
Re: Paletted 8bit -> 24bit shading.
« Reply #39 on: January 28, 2013, 04:44:48 pm »
why 256 nw and 256 ne? there's only ONE tile set per map. and there's a limit of 256 tiles per map. though it may have animated tiles (but there are only few of them), which _slightly_ increase overall sprites count.
but the thing is - units also need to be "shaded" properly, though they could be flat shaded.

and still, that would work only for 8bit original graphics. still no way of such "oldschool" shading for 32bit "HD" sprites from TTS.
Don't we keep the images for NW/NE/floor and central object as separate sprites? If we don't, then it's true that we only have 256 sprites max (for terrain). Although I think the 256 tile limit can be lifted easily enough and become 2^16 (a few typedef changes and a small change when reading from the original data).

Offline darkestaxe

  • Colonel
  • ****
  • Posts: 254
  • Emissary of the Brain
    • View Profile
Re: Paletted 8bit -> 24bit shading.
« Reply #40 on: February 02, 2013, 05:08:49 am »
My math was wrong in two ways. I assumed 32 light levels minimum in a night mission, according to Volutar there's 16. Also I forgot to account for there being multiple bits in a byte, it's 32bit RGBA, not 32byte RGBA which would be an extreme and unnecessary color resolution.

However the x-com map is not a static image, it changes throughout the battlescape turn. If there were a maximum of 256 tiles, like maybe a base mission, it wouldn't matter. (an X-COM base should have 3,600 tiles if a small facility is 10x10) All of this is irrelevent however as it would not make sense to load the pic for the basic hangar floor tile at 16 light levels  ~900-1000 times for each and every tile. That would be silly.

But lets suppose we go on a sectiod terror mission in our avenger. We brought at least 1 of each weapon, armor type, and 4 different tanks. Also a male and female soldier are wearing each armor type. Finally the sectiods brought a leader, at least 5 different types of weapons, reapers, etc.

I'm pretty sure we don't need separate sprites for each type of unit holding each type of weapon, however we need at least 6 sprites for each unit type, for each position they would be animated in. (death excluded-everyone faces the same direction to die) We also need sprites for each type of corpse,  and the death animations. Next we need sprites for every candy-shelf in the store, door in the apartments, sink in the little houses, roof tiles, etc. Keep in mind many of these things are larger then the tile too. Also there's still all the pavement, grass, dirt, scorched pavement, scorched grass ... I think you can use your imagination at this point.

Basically I find it hard to believe that 256 sprites is even half of it it. Am I off about the 64x64? If so, then that makes a huge difference and would explain how some of this as doable on a 80-286 in 1992.

Offline karvanit

  • Captain
  • ***
  • Posts: 94
    • View Profile
Re: Paletted 8bit -> 24bit shading.
« Reply #41 on: February 02, 2013, 06:58:35 am »
The number of tiles we count is NOT the number of grid positions in the battlescape. It is the different contents that can appear. e.g. All alien UFO floors are the same tile. Right now this is hardcoded at 256 (one byte index), same as in the original game.

Offline volutar

  • Colonel
  • ****
  • Posts: 351
  • Vanilla digger & Quality assistant
    • View Profile
Re: Paletted 8bit -> 24bit shading.
« Reply #42 on: March 12, 2015, 02:02:56 pm »
Ok, I made a test with hybrid solution, when artists gotta make two different shaded 32 sprites for each battlescape sprite - full light, and half-light (It makes light shades being interpolated between these two, and dark shades are going towards "black" by static curve). For vanilla it will simply generate all "intermediate light" sprite pairs, for custom - it should be done manually.

For XCOM-1 it works perfectly. The difference is barely noticeable, so there's no need even to show it.

But for TFTD underwater blue, or deep black is really off. Right now I can't figure how to make it possible with just 2 images.
Obviously there should be "ambient color" parameter, but not only that, because in xcom2 all colors all colors are gaining blue tint, even before going black in deep palette. I hate TFTD colors.
« Last Edit: March 12, 2015, 02:12:34 pm by volutar »

Offline volutar

  • Colonel
  • ****
  • Posts: 351
  • Vanilla digger & Quality assistant
    • View Profile
Re: Paletted 8bit -> 24bit shading.
« Reply #43 on: March 12, 2015, 05:19:44 pm »
vanilla:

hybrid lighting:


I need more savegames (night missions from batlescape) from vanilla to make more test shots. If anyone has - would you mind sharing with me (specially crashed plane mission). Thanks.
« Last Edit: March 12, 2015, 05:41:25 pm by volutar »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8597
    • View Profile
Re: Paletted 8bit -> 24bit shading.
« Reply #44 on: March 12, 2015, 07:50:09 pm »
Hello Volutar,

I have quite a lot of saves from my LP.
The spreadsheet with overview, which terrain can be found in which mission/episode/save can be found here:
- https://docs.google.com/spreadsheets/d/1jkgLpvA7Q_x0fMW4T-E74uyNh5MOPIFinIDLrR1H8Ts/edit?usp=sharing

The saves themselves are here:
- link broken

Enjoy!

PS: The Crashed plane mission during the night as you asked are approx. saves #23 #24 and #25
PS2: The LP was about showing everything, so you should see all types of terrains, all types of UFOs and all types of aliens, just find the correct save based on the spreadsheet
« Last Edit: October 12, 2019, 10:45:35 pm by Meridian »