Author Topic: Terror from the Deep support  (Read 37814 times)

Offline AndO3131

  • Colonel
  • ****
  • Posts: 137
    • View Profile
Terror from the Deep support
« on: June 15, 2013, 10:48:51 am »
Hi. With recent @Warboy1982 activity - new sprites, sounds, etc. I thought it's time to talk about Terror support. I'm a big fan of hybrid game, so I made some efforts to get this started. My first though was that we need more complex folder support, so I' ve implemented this @Daiky's idea. It's available on Github. This branch is quite complete, so it can be pulled to the main code, if developers want it.

Based on it, I tried to pull in some Terror images (ufopedia). It works, however colors are bad, since Terror used different palettes. My second thought was trying to add 32bit surface support - this would allow drawing all necesary colours as needed. What do you think about this? Is this something we want or not?

For now I managed to get both globes drawn, but shading doesn't work. I don't get these template shader functions. They don't work with 32bit globe surface, and I don't have a clue how to get it fixed. I'm hoping for some help, ideas, thoughts from you guys.

If someone wants to check out how this works, get the code from this branch and compile it. Here's the settings.cfg entry I use (your folder structure might be different)

==========
games:
  xcom1:
    vanilla: UFO1/
    openxcom: UFO1_openxcom/
    rulesets:
      - name: Pathfinding
        folder: ""
      - name: Xcom1Ruleset
        folder: UFO1/
  xcom2:
    vanilla: Terror from the Deep/
    openxcom: UFO2_openxcom/
    rulesets:
      - name: TFTD
        folder: Terror from the Deep/
==========

And some screenshots of the globe.

Offline Yankes

  • Commander
  • *****
  • Posts: 2213
    • View Profile
Re: Terror from the Deep support
« Reply #1 on: June 15, 2013, 12:59:58 pm »
Quote
For now I managed to get both globes drawn, but shading doesn't work. I don't get these template shader functions. They don't work with 32bit globe surface, and I don't have a clue how to get it fixed. I'm hoping for some help, ideas, thoughts from you guys.
This template functions work on palette graphics. They change one palette index to another using logic form class in template parameter.  Right now its expect 8bit palette but this will still work if palette was 16bit aka both palettes merged together but this will not be supported by SDL (its only allow 8bit palette).
Another approach is that to allow this template functions to accept RGB colors but this will have some drawbacks like it will be slower than now and shading will have different hue than original. But this will have some positive sides too. Without 8bit limitations shades will be more smooth than now.

Offline 54x

  • Colonel
  • ****
  • Posts: 208
    • View Profile
Re: Terror from the Deep support
« Reply #2 on: June 15, 2013, 01:46:03 pm »
This template functions work on palette graphics. They change one palette index to another using logic form class in template parameter.  Right now its expect 8bit palette but this will still work if palette was 16bit aka both palettes merged together but this will not be supported by SDL (its only allow 8bit palette).
Another approach is that to allow this template functions to accept RGB colors but this will have some drawbacks like it will be slower than now and shading will have different hue than original. But this will have some positive sides too. Without 8bit limitations shades will be more smooth than now.

Is it possible to have 16bit colours available but still be able to load, and shade/colour replace palletted images? That would be the ideal...




Offline Yankes

  • Commander
  • *****
  • Posts: 2213
    • View Profile
Re: Terror from the Deep support
« Reply #3 on: June 15, 2013, 04:45:46 pm »
ups... I made small mistake, it only require 9bit (514 different colors) to have both palettes. 16bit is still require because its next possible storage size.

Quote
Is it possible to have 16bit colours available but still be able to load, and shade/colour replace palletted images? That would be the ideal...
you mean RGB colors? it will be tricky because conversion RGB <-> Palette lose information. If you want have some graphic that have both XC1 and XC2 it require to be RGB graphic and after that you cant use current shading method that use palette index. great example of that situation is if you want create unit from XC1 that using weapon form XC2, this require RGB to store it in one graphic. Next thing that engine do with that unit is applying correct shading when is drawing it on battlescape map, but we now lost data required to do it.

Because SDL dont support palettes bigger than 256 (8bit) maybe we should scrap `SDL_Surface` as data format? It can be replaces by plain `std::vector<Uint16>` with some additional fields. With 65535 different colors in palette, we could use couple palettes in one graphic (0-255 XC1 globe palette, 256-513 XC1 battlescape palette, 514-767 XC1 graph palette, 768-1023 XC2 globe palette etc.). Every pixel will have information form what palette he is from. `SDL_Surface` will be still used but only as main display surface.


Volutar

  • Guest
Re: Terror from the Deep support
« Reply #4 on: June 15, 2013, 07:07:30 pm »
It's not about SDL.  SDL can support what hardware supports. There are no graphics modes and never been on planet Earth where more than 256 colored palette was used. There's no such technique. There is 15 bit RGB (5 bit per component), 16 bit (5-6-5),24 bit (8 bits per component , true color, and possibly aligned to 32 bit) and recently introduced 30 bit(10 bits per component +2 to align).
It is possible to use 8bit paletted sprites and convert them into truecolor during drawing pricedure, but (1) I dont know amount of performance drop it causes (maybe noticeable), (2) how to mak pixel processing methods work, if they are expecting for color index, not RGB value.

Offline 54x

  • Colonel
  • ****
  • Posts: 208
    • View Profile
Re: Terror from the Deep support
« Reply #5 on: June 16, 2013, 03:45:54 am »
Hmmm. I know Diablo 2 used palleted images that it converted into higher depth, but I don't know what the performance hit on that was like.

Well, the simplest solution for TFTD support as a seperate game is to simply switch out the palletes through data, but you'll probably need to have a higher bit depth if you want to use UFO and TFTD sprites at the same time, which would probably mean your best option is interfacing palletted images with true colour, to preserve the ability to shade the sprites via pallette shift. (And also, if we want to recolour sprites, palletted images are ideal for that)

Offline AndO3131

  • Colonel
  • ****
  • Posts: 137
    • View Profile
Re: Terror from the Deep support
« Reply #6 on: June 16, 2013, 12:56:19 pm »
While using 32 bit surface, we could use alpha channel to get increasing opacity - wouldn't it be a good form of shading?

I would need help with that -> here's a Github branch, it doesn't use any folder changes mentioned in earlier posts.

Offline 54x

  • Colonel
  • ****
  • Posts: 208
    • View Profile
Re: Terror from the Deep support
« Reply #7 on: June 16, 2013, 01:56:09 pm »
While using 32 bit surface, we could use alpha channel to get increasing opacity - wouldn't it be a good form of shading?

I would need help with that -> here's a Github branch, it doesn't use any folder changes mentioned in earlier posts.

The issue with shading is that both UFO and TFTD change the colour as it darkens- UFO reddens it slighly, and TFTD makes it bluer. (to give a visual impression of being underwater) They achieve this by using custom palleted colours, which means some colours are more affected by this tint than others. You can't really preserve the shading technique while dumping palleted images entirely, and for that matter, opacity channels work best by allowing us to anti-alias the sprite's edges. You're thinking of post-processing sprites, which is a slightly different thing again.

Offline AndO3131

  • Colonel
  • ****
  • Posts: 137
    • View Profile
Re: Terror from the Deep support
« Reply #8 on: June 21, 2013, 08:47:59 pm »
Ok. After much struggle I've made the globe shading without/with/only water working here. It presented another problem - globe tends to 'dissapear' during rotation - any help on that would be appreciated.

I'll try to do something about battlescape, no promises though.

P.S. Overlook x-com base on yellow land :)

Offline Yankes

  • Commander
  • *****
  • Posts: 2213
    • View Profile
Re: Terror from the Deep support
« Reply #9 on: June 21, 2013, 09:12:13 pm »
[OT]
you have probably bugged version of SDL, you should not see black dots between triangles. SupSuper spot this long ago and he find outs that was caused by bug in (IIRC) SDL_GFX

Offline pmprog

  • Commander
  • *****
  • Posts: 652
  • Contributor
    • View Profile
    • Polymath Programming
Re: Terror from the Deep support
« Reply #10 on: June 21, 2013, 09:46:43 pm »
[OT]
you have probably bugged version of SDL, you should not see black dots between triangles. SupSuper spot this long ago and he find outs that was caused by bug in (IIRC) SDL_GFX
Actually, this was me. I even submitted the patch to SDL_gfx, but that's by-the-by :)

Offline Yankes

  • Commander
  • *****
  • Posts: 2213
    • View Profile
Re: Terror from the Deep support
« Reply #11 on: June 22, 2013, 01:29:33 am »
[note to myself]
check who did what exactly :>

Offline AndO3131

  • Colonel
  • ****
  • Posts: 137
    • View Profile
Re: Terror from the Deep support
« Reply #12 on: July 01, 2013, 12:01:38 am »
Good news  :)

I've managed to combine two palettes in battlescape. Will work on supporting terror maps now. Geoscape dissapear problem seems to be fixed, too.

Volutar

  • Guest
Re: Terror from the Deep support
« Reply #13 on: July 01, 2013, 04:46:49 am »
Why this craft has underwater "bluish" tint for shades AT terrain level?

Offline luke83

  • Commander
  • *****
  • Posts: 1568
    • View Profile
    • openxcommods
Re: Terror from the Deep support
« Reply #14 on: July 01, 2013, 01:06:50 pm »
Good news  :)

I've managed to combine two palettes in battlescape. Will work on supporting terror maps now. Geoscape dissapear problem seems to be fixed, too.

Nice work mate , keep it up and we will be playing TFTD in no time :P