PSX semitransparency to ARGB

Graphic based area of development (Graphics Processing Unit), including the Geometry Transform Engine (GTE), TIM, STR (MDEC), etc.
Post Reply
Yagotzirck
Verified
Extreme PSXDEV User
Extreme PSXDEV User
Posts: 131
Joined: Jul 17, 2013

PSX semitransparency to ARGB

Post by Yagotzirck » March 21st, 2016, 3:22 am

Hello, i'm trying to convert sprites from a PSX game(Disruptor) to a PC-friendlier ARGB TGA format.
No big issues, except for the way the PSX handles semitransparency.

The library reference describes these 4 methods in GetTPage():
Semitransparency rate
0: 0.5 x Back + 0.5 x Forward
1: 1.0 x Back + 1.0 x Forward
2: 1.0 x Back - 1.0 x Forward
3: 1.0 x Back + 0.25 x Forward
I understand the way each method works, what I can't figure out is how to convert each method to standard png-like ARGB format :?
Thanks in advance to whoever can help

User avatar
LameGuy64
Verified
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 388
Joined: Apr 10, 2013
I am a: Hobbyist Game Developer
Motto: Commercial or not, play it!
PlayStation Model: H2000/7000
Location: Philippines
Contact:

Post by LameGuy64 » March 21st, 2016, 6:18 pm

The way how the PlayStation handles semi-transparency is a bit tricky but it can be figured out. All graphical primitives that use textures have a flag that tells the GPU to do semi-transparent blending or not and another flag that tells which blending method should be used.

Each pixel (in a 16-bit texture) or CLUT color (in a 4-bit/8-bit texture) has a semi-transparency bit which is placed at the very end of a 16-bit color value because the RGB color values only take up the first 15 bits. This bit is used as a special flag for both non-blended and blended drawing of the texture image.


The logic as to how the semi-transparency bit affects the pixel is as follows (full-black means all RGB components are 0):

-- If Semi-Transparent mode is off --
Full-black without STP bit = Transparent (alpha = 0)
Full-black with STP bit = Opaque black (alpha = 255)
Non full-black without STP bit = Solid color (alpha = 255)
Non full-black with STP bit = Solid color (alpha = 255)

-- If Semi-Transparent is on --
Full-black without STP bit = Transparent (alpha = 0)
Full-black with STP bit = Semi-transparent black (alpha = 127)
Non full-black without STP bit = Solid color (alpha = 255)
Non full-black with STP bit = Semi-transparent color (alpha = 127)


I'm not sure how you can convert the colors to other blending modes (blend modes 1-3) as the only way to achieve that is to use a different blending algorithm used when your TGA image is drawn.
Please don't forget to include my name if you share my work around. Credit where it is due.

Dev. Console: SCPH-7000 with SCPH-7501 ROM, MM3, PAL color fix, Direct AV ports, DB-9 port for Serial I/O, and a Xplorer FX with Caetla 0.35.

DTL-H2000 PC: Dell Optiplex GX110, Windows 98SE & Windows XP, Pentium III 933MHz, 384MB SDRAM, ATI Radeon 7000 VE 64MB, Soundblaster Audigy, 40GB Seagate HDD, Hitachi Lite-on CD-RW Drive, ZIP 250 and 3.5" Floppy.

Yagotzirck
Verified
Extreme PSXDEV User
Extreme PSXDEV User
Posts: 131
Joined: Jul 17, 2013

Post by Yagotzirck » March 21st, 2016, 11:52 pm

Yeah, I came to the conclusion the modes 1-3 are just exotic simple arithmetic blending modes and it's impossible to have an exact conversion to ARGB... though I've used an approximation method as follows:

-Convert each 16-bit CLUT pixel to ARGB32, left-shifting each color component by 3 values
if STP bit is set:
-Use the highest color component as alpha value
-Multiply each color component by (255.0 / highestColorComponent).
Otherwise use 255 as alpha value.

Certainly not the most accurate method, but at least that way the sprites appear closer to they way they look like in-game :)
Any suggestions on how to make it even more accurate are welcome, but for now the result seems pretty acceptable to me

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests