Author Topic: [Solved] OXCE+ Graphics Transparency Problem  (Read 11148 times)

Offline Admiral Naismith

  • Squaddie
  • *
  • Posts: 4
    • View Profile
[Solved] OXCE+ Graphics Transparency Problem
« on: February 26, 2018, 02:53:26 am »
I found a mod that adds a new weapon and tried loading it in OXCE+. Unfortunately, the transparency did not seem to work correctly, resulting in black boxes around all of the sprites, including handobs. I first assumed that this must be an issue with the images, though the only oddity with those is that they seem to be in gif format rather than png. I then tried loading the mod in vanilla OXC, and found that there it actually worked correctly.

Could it be that I have something misconfigured in OXCE+? Or is this purely a bug?
Does anyone have suggestions for fixing this, other than reformatting the images? I've attached screenshots of what it looks like in both OXC and OXCE+, as well as the mod itself.

Thanks!
« Last Edit: February 11, 2023, 04:50:37 pm by Meridian »

Offline BlackStaff

  • Colonel
  • ****
  • Posts: 336
    • View Profile
Re: OXCE+ Graphics Transparency Problem
« Reply #1 on: February 26, 2018, 11:17:12 am »
I had the same problem with an added Mod in OXCE+!
The only solution I found was to change the' HandOb' images.
https://openxcom.org/forum/index.php/topic,5982.0.html

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9084
    • View Profile
Re: OXCE+ Graphics Transparency Problem
« Reply #2 on: February 26, 2018, 11:35:12 am »
The images have a completely broken palette, see attached.

The fact that it works in OXC is either a lucky coincidence, or some additional guesswork that has been either not implemented or removed in OXCE.

Offline Admiral Naismith

  • Squaddie
  • *
  • Posts: 4
    • View Profile
Re: OXCE+ Graphics Transparency Problem
« Reply #3 on: March 02, 2018, 04:30:21 am »
I had the same problem with an added Mod in OXCE+!
The only solution I found was to change the' HandOb' images.
https://openxcom.org/forum/index.php/topic,5982.0.html
The images have a completely broken palette, see attached.

The fact that it works in OXC is either a lucky coincidence, or some additional guesswork that has been either not implemented or removed in OXCE.

Ahh, I see - I didn't know quite enough about image manipulation to recognize that, and messing around in Photoshop trying to convert the original images made it even worse, even though the files looked fine in Photoshop and as Windows thumbnails.

I did actually work out a fix though:
  • Open a PNG file of appropriate size from a different mod that is confirmed to work.
  • Open the corresponding broken GIF file.
  • Select all on the broken file and copy.
  • Select all on the working file and delete, then paste and adjust sprite location to match source.
  • If the background is not transparent, select background with magic wand: point sample, 0 tolerance, no anti-alias; then delete.
  • Save resulting file as a new PNG with the appropriate name.
  • Profit!

I used images from Nord's TWoTS mod as a base, and combined the broken handobs into one image with this tool before fixing them.

I'm thinking I should post the fixed mod, though I'm not entirely sure on the etiquette/procedure for editing someone else's mod or incorporating their work into a larger mod (other than, obviously, giving credit).
Since this would be a fix for an existing mod, I'm thinking I should just increment the version number, but then this might cause confusion if the original author updates their mod in some other way. Should I also change the mod ID then? Or something else?
Any advice on that?

Thanks!

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11721
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: OXCE+ Graphics Transparency Problem
« Reply #4 on: March 02, 2018, 11:45:38 am »
I think it would be perfectly fine to post your fixed files in the original mod thread.
As for using assets from other mods in general, I'm sure nobody would mind... But it's always best to ask.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9084
    • View Profile
Re: OXCE+ Graphics Transparency Problem
« Reply #5 on: March 02, 2018, 11:54:37 am »
  • If the background is not transparent, select background with magic wand: point sample, 0 tolerance, no anti-alias; then delete.

This just creates the same issue, but with PNGs.
Might work, might not.

The best way (and the only correct and official way) is NOT using transparency at all.
Instead whatever should be transparent in game should have color index 0... the game will interpret that as transparent.

Offline yrizoud

  • Commander
  • *****
  • Posts: 1014
    • View Profile
Re: OXCE+ Graphics Transparency Problem
« Reply #6 on: March 03, 2018, 12:10:57 am »
Photoshop is as likely to "break" an image as fix it, because you have no way of seeing what you're actually doing.

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11721
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: OXCE+ Graphics Transparency Problem
« Reply #7 on: March 03, 2018, 07:47:51 pm »
Photoshop is as likely to "break" an image as fix it, because you have no way of seeing what you're actually doing.

I've edited probably tens of thousands of pics with PS, and it has never failed me. Not even once. :)

niculinux

  • Guest
Re: OXCE+ Graphics Transparency Problem
« Reply #8 on: March 03, 2018, 10:14:25 pm »
I think it would be perfectly fine to post your fixed files in the original mod thread.
As for using assets from other mods in general, I'm sure nobody would mind... But it's always best to ask.

Sadly (or surprisingly?) the mod currently does not have a forum page, instead a [mod portal page which is broken, but is still downliadable from here.

Offline Amiga

  • Colonel
  • ****
  • Posts: 128
  • Amiga4ever....
    • View Profile
    • White Wolf Untold Story PL (my rpg game based on Witcher saga)
Re: OXCE+ Graphics Transparency Problem
« Reply #9 on: March 06, 2018, 02:34:31 am »
Today I've tried OXCE+ and indeed I lost all my transparency on items. OXC has no problem with it....So far my main graphic program was PS CC and I've just removed background. Unfortunatelly it doesn't work with OXCE+.
Strange thing is that crafts in base has correct transparency -  only items has issues. Any workaround for PS to make it work again?

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1933
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: OXCE+ Graphics Transparency Problem
« Reply #10 on: March 06, 2018, 04:05:22 am »
Today I've tried OXCE+ and indeed I lost all my transparency on items. OXC has no problem with it....So far my main graphic program was PS CC and I've just removed background. Unfortunatelly it doesn't work with OXCE+.
Strange thing is that crafts in base has correct transparency -  only items has issues. Any workaround for PS to make it work again?

It's not all that strange that only items have broken transparency in OXCE+ - the reason has to do with the scripts Yankes added to be able to recolor/select item sprites based on pretty much anything you want - for example I use them to recolor energy weapons based on the type of ammo they have loaded.  As for how to fix this, Meridian already answered above:

The best way (and the only correct and official way) is NOT using transparency at all.
Instead whatever should be transparent in game should have color index 0... the game will interpret that as transparent.

Take all your images and replace the transparent portions with color index 0 from the palette.  An easy way to do this would be to add a layer below your sprite filled with color index 0 and then exporting both layers as visible.  The fact that OXC allows for transparency via other methods should not be treated as the correct way of doing things, it's more a side effect of not enforcing proper formatting for your images to be read by the engine.
« Last Edit: March 06, 2018, 04:07:01 am by ohartenstein23 »

Offline Amiga

  • Colonel
  • ****
  • Posts: 128
  • Amiga4ever....
    • View Profile
    • White Wolf Untold Story PL (my rpg game based on Witcher saga)
Re: OXCE+ Graphics Transparency Problem
« Reply #11 on: March 06, 2018, 09:37:52 am »
Thanks for reply.  I was aware that Meridian gave an answer but my color index 0 isn't white. I think my pallette in little mixed up. 
Anybody has correct set of swatch colors to PS which I can import?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9084
    • View Profile
Re: OXCE+ Graphics Transparency Problem
« Reply #12 on: March 06, 2018, 10:40:58 am »
Thanks for reply.  I was aware that Meridian gave an answer but my color index 0 isn't white. I think my pallette in little mixed up. 
Anybody has correct set of swatch colors to PS which I can import?

It doesn't matter what color you have on index 0... it can be black, white, yellow, green... whatever.
The game will ALWAYS ignore this color and interpret it as "transparent".

PS: btw. same goes for every other color... the game doesn't care what color you put in your palette... when the images are loaded, your palettes are ripped off from the images, discarded and replaced by the palettes that the game wants. The GIF transparency is more or less the only exception... but it is definitely not a feature, it is a side-effect, and should not be used.
« Last Edit: March 06, 2018, 10:47:09 am by Meridian »

Offline Amiga

  • Colonel
  • ****
  • Posts: 128
  • Amiga4ever....
    • View Profile
    • White Wolf Untold Story PL (my rpg game based on Witcher saga)
Re: OXCE+ Graphics Transparency Problem
« Reply #13 on: March 06, 2018, 11:14:35 am »
It doesn't matter what color you have on index 0... it can be black, white, yellow, green... whatever.
The game will ALWAYS ignore this color and interpret it as "transparent".

PS: btw. same goes for every other color... the game doesn't care what color you put in your palette... when the images are loaded, your palettes are ripped off from the images, discarded and replaced by the palettes that the game wants. The GIF transparency is more or less the only exception... but it is definitely not a feature, it is a side-effect, and should not be used.

I was thinking about it that index 0 could be anything. Thank you for confirmation. So now what is the limitation of items/weapons color? 256, 8 bit?

Offline Bloax

  • Colonel
  • ****
  • Posts: 322
  • do you want to be any of those things
    • View Profile
Re: OXCE+ Graphics Transparency Problem
« Reply #14 on: March 06, 2018, 12:10:04 pm »
Anything that isn't ufopaedia images are limited to index 1-255 (0 being transparent) of the defined battlescape palette.