wipeout-phantom-edition / wipeout-phantom-edition

An enhanced PC source port of the original WipeOut.
610 stars 14 forks source link

Enhancement: Upscale textures #48

Open ncflagg opened 6 months ago

ncflagg commented 6 months ago

It would be nice to convert the textures to something we could modify. Say, when the textures are extracted from the .BINs, save them as PNG (instead of .TIM / .CMP) so they could be upscaled/replaced as desired.

Lukesleftleg commented 2 months ago

Hi @ncflagg. That's a good question.

Actually, this is something I've been trying to do, so far without all that much success.

I've actually managed to convert to and from TIM files, and I've upscaled the weapon icons and the title screen (remembering to leave colour index 0 for transparency). Unfortunately, my weapon icons don't seen to display; even though I've replaced the ones in the texture folder, the game just shows the low-rez versions. (I've put them all together for this image, just for brevity. The ones I've used are 512x512).

Weapon Icons

I'm afraid my upscaled title screen just crashes the program at startup, although it's quite possible that I've gone overboard with the upscaling at 2560x1440 (or maybe I shouldn't have tried to make it widescreen).

PALTITLE

As for the CMP files, I've been reading up on these, and they appear to be compressed archives that use the LZ77 format, but neither 7zip or winrar want to deal with it, and so I asked ChatGPT to write me some code to compress/decompress those files.

My Java is pretty good, if rusty, and my C# isn't bad, but I'm afraid I can barely speak C++. It's getting late here though, and so I'll try and test it tomorrow.

I suspect that replacing the weapon icons requires the CMP files to be edited in order for the game to display them, rather than just bunging the TIM files into the textures folder. Not sure though.

I also want to try to understand the 3D model format, although this is less important, so I haven't really started with this yet.

Ideally, I'd like to write a utility that can convert to and from all these formats, which I'd make publicly available.

@wipeout-phantom-edition I hope it's not bad etiquette to tag you directly (I'm a bit of a Github noob, and I apologise if it is), but I have a technical question.

Is there a hard limit in the code for the resolutions of the various graphics that make up the HUD and the model textures of the game, or can they theoretically be any size (as long as the proportions are preserved) and the program will just deal with resizing them correctly? I assume that memory becomes an issue at some point.

And while I've (hopefully) got your attention, am I barking up the right tree with the rest of what I've written here?

If I can understand what I'm doing here, I'd like to upscale as much as possible to contribute to the project; get the game looking as good as it possibly can. It already plays beautifully.

I wonder if normal-maps (advanced bumpmaps) would be possible at some point? Sorry, just blue-sky-thinking out loud.

Anyway, I'll try and update with the results of the code that ChatGPT gave me, if there are any.

(I don't suppose anyone know of an app that'll do it?)

wipeout-phantom-edition commented 2 months ago

There are some problems with using much larger textures currently.

Recently texture atlasing was implemented, and there is only one 2048x2048 texture atlas which drastically limits how large textures can be. There is no hard limit on texture sizes but all loaded textures would need to fit in that atlas. It would be feasible to add an option to disable texture atlasing, which I'll probably do. Disabling it would make rendering slower, but remove this restriction.

Currently all UI textures have texture filtering disabled, which is not ideal for high res textures. Also, textures do not use mipmapping currently. Mipmapping complicates or makes texture atlasing non-viable as well.

The PlayStation GPU treats black colors as transparent and does not use the type of alpha channel that is common today. This means that currently there is no support for a smooth alpha gradient, which would make high resolution filtered UI textures with transparency look bad. The best solution for this is probably to flag triangles that use textures with full alpha (loaded from a .png for example) so that they can use a different alpha blending technique in psx.frag.glsl.

I think the best approach to allow for texture mods is to look for .png files in a specific directory that override what would normally be loaded from the .tim and .cmp files. Then also have some kind of config file where specific texture settings could be configured, for example using an 8-bit alpha channel instead of treating black as transparent, and weather to use mipmapping and texture filtering.

Lukesleftleg commented 2 months ago

@wipeout-phantom-edition Well thank you very much for an extremely prompt reply.

I have to confess that although I have a degree in IT, my programming is far more rusty than my graphic skills, which seems to be where my talents lie, and so I'm not so familiar with texture atlasing, but I think I've a rough idea what it is.

It would be a shame to do something that slows rendering, but with the 3D rendering tech being so advanced these days, maybe it won't present too much of a hit, especially if it opens up more options. I guess, as with any programming, it's a trade-off. See how much it slows it down, I guess.

If I'm understanding what you mean by texture filtering, wouldn't this only apply to textures that are upscaled at runtime?

If I can get my head around all the formats, what I'm proposing is to offer to do all the upscaling myself, including any texture I can get my hands on.

Sure, I'd use AI for something photographic, like the title screen, but even this was upscaled using several methods, and what you see above is a patchwork of the best bits from each upscale.

As for the weapon icons, these were done in AutoCAD for precision, then Illustrator, and finished in Photoshop. I'd use a similar method for all the 'icon like' or 'text like' graphics I could work on.

Depending on how complex they are, I may also try to do the car textures in this way as well, rather than just AI upscaling.

Of course, I'd want to consult you on appropriate image sizes when the time comes, rather than just going "I like 512x512 so I'll use that".

I'm even thinking about doing the speedometer (and maybe a couple of other things) in 3D Studio, for that really flash look. :)

Of course, this is all 'pie-in-the-sky' right now, but if the texture limits are something you're planning to address soonish, then I'd be very enthusiastic about providing improved graphics.

I remember reading about Wipeout in Edge magazine, back when it was first in development, and that was when I fell in love with it. Finally playing it only deepened my passion. I liked the others, but the first one has a special place in my heart, so I'm very motivated.

So if you can, then please use my skills. I'd be happy to flash my credentials in a PM or something. I can be patient though, and wait until you're ready. :)

Just to reply to your other points:

I noticed that the .TIM files needed me to not touch pallette index zero, but I assumed it was an 8-bit index thing. Thanks for enlightening me that it's actually black that it looks for for transparency.

You can see I've left a non-black border (index one) most clearly on this one. NEG

But if you're considering ripping out all the .TIM code and replacing it with .PNG functionality, then I've got to say that that would make my job a whole lot easier (if you decide to use me, that is).

I've been able to convert to and from TIM files. It's a fiddle but not too bad, but as I said above, the .CMP files remain impenetrable to me. I'll keep trying though. (Any hints would be most appreciated. ChatGPT was just plain wrong).

Oh, and what you said about mipmapping. To be honest, I didn't even notice they weren't enabled, and that's even after reading Dominic Szablewski's page, where he talks about it, so the game's already looking impressive without it.

Wow! That would be something to look forward to though! (As would normal and specular mapping one day - hint hint). :)

Anyway, please keep me in mind, and please let me know if and when you get around to adding the appropriate functionality.

And sorry if my enthusiasm comes across as pushiness. I don't mean it that way.