iOrange / sh2tex

Silent Hill 2 Textures Explorer
MIT License
14 stars 3 forks source link

Hidden Replace Options #3

Closed IvNergal closed 8 months ago

IvNergal commented 9 months ago

Hello, your tool is very welcome in the community, but I think I don't understand how it works, or something isn't working for me, I can't replace the textures, the options are inaccessible, I'm trying to replace it from the GH version of PS2, and when save the .tex, in the save tab, it creates a file with very few KB... can you help me understand?

fail

iOrange commented 9 months ago

Hi @IvNergal ! Yes, replacing textures for PS2 is not implemented, as well as saving them sorry. The PS2 format is quite complicated and still contains some dark spots for me, as well as I don't have means to test the output.

If you provide me with test files and instructions on how to test that the output texture is working in the game - I'll try to implement it.

IvNergal commented 9 months ago

Hi @iOrange ! Yes! I can test it for you, many people have been looking for a functional tool for this game in its PS2 version for years, especially translators. Here below is a ".zip" with two texture samples from the PS2 version "Greatest Hits (SLUS_202.28)". You can make it and send it right here, and I can test it for you! You can follow the upload format that I sent here, and with each new version (attempt), you can edit your message and replace the upload (with a warning for new testing) then I will test it in the game.

Information I know about the texture "scenario01.tex" in the zip package below, I don't know if this information applies to another sample. But I hope this information helps something:

The SH2 PS2 textures, are similar to .tm2(PS2 TIM 2) but with a custom texture header. In this case, .TEX files have 1 more extra header, so it has 2 headers. It is something like this:

0x00: Extra header or main header 0x40 (Decimal = 64): Texture header 0xC0 (Decimal = 192): Image data 0x400C0 (Decimal = 262336): Palette header 0x400F0 (Decimal = 262384): Palette data.

Now, palette data is separated by a block of zeros so you can see a block of palette data(size 40) and a block of zeros(size C0) these 2 blocks x 16 times.

I hope you get it! Thanks!

SH2GH_PS2_SAMPLES.zip

iOrange commented 9 months ago

Hi @IvNergal !

Thanks for the info. I'll try my best and get back to you.

iOrange commented 9 months ago

@IvNergal please test this one. This should be the hardest one - paletted swizzled with bloated palette (omg PS2 gives me headaches).

If it works - I'll release the new version that allows PS2 textures replacements and full PS2-compatible save.

test_texture_ps2.zip

should look like so image

IvNergal commented 9 months ago

@iOrange Yes!! You did it, congratulations!! And thanks for trying this! Very good, congratulations, you're a good guy!!! Yesss!!

iOrange commented 9 months ago

Love it! Thanks a lot for testing it for me! I'll release a new version with all the changes asap.

IvNergal commented 9 months ago

Thank you very much!!

iOrange commented 9 months ago

@IvNergal you can now download from https://github.com/iOrange/sh2tex/releases/tag/v1.2

IvNergal commented 9 months ago

Thank you very much!!

Polymega commented 9 months ago

You're awesome, iOrange!

IvNergal commented 9 months ago

Hi @iOrange , sorry to bother you again, but how do I get a PNG with this format? I tried with several editing programs, but none of them create a valid PNG, so that it can be reimported in the tool... It always gives this error... What tool should I use to save my edited PNG, so that it is valid for reimport? (this format visible in HEX is the way the tool extracts the PNG, which I cannot reproduce)

error

iOrange commented 9 months ago

Hi @IvNergal. Sorry for the confusing error, I have it backwards unfortunately. As you can see in the properties table on the right - it say "Format : Paletted".

So to replace it you need to give the tool the PNG that is also paletted. I've used Photoshop to produce such image, but I guess most image editors should be able to do the same ?

I was thinking on allowing any PNG as an input and quantizing for palette myself, but that way the user has no control over that process, and you better off using image editors for that job.

IvNergal commented 9 months ago

@iOrange I also used Photoshop and other image editors, but I couldn't... maybe I don't know the correct setting?

iOrange commented 9 months ago

Okay I see, the transparency. The PS2 paletted images require full-array transparency for palette (tRNS chunk) but Photoshop doesn't do that. Lemme research a bit.

IvNergal commented 9 months ago

Okay, of course.

iOrange commented 9 months ago

@IvNergal okay, sorry about that, didn't expect Photoshop to be that stupid. TBH other editors are quite the same - they can't save paletted PNG with full-range transparency. But I've found a way to achieve it I believe.

So you export the texture with my tool, open it in Photoshop (or any other editor), edit to your needs, save as normal 32bit PNG with transparency.

Next - you open that PNG in this tool (http://x128.ho.ua/color-quantizer.html, download latest version 0.7.4.4 ะพั‚ 06/04/2018) Select 256 colors image

Now save it to PNG. You can now use this paletted PNG to replace an image using my tool. You might want to grab the new version with small fix from here btw - https://github.com/iOrange/sh2tex/releases/tag/v1.2.1

Please let me know if you still have issues.

IvNergal commented 9 months ago

@iOrange , thank you very much! Problem solved thanks to you, you helped me a lot!! I searched a lot and hadn't found a solution. Thanks again and forgive me for keeping you busy. Your tool will help a lot of people.

iOrange commented 9 months ago

@IvNergal awesome, glad I could help! Feel free to report any issues you find, or questions you have.

IvNergal commented 9 months ago

Hi @iOrange , sorry to bother you again, but I saw a lot of potential here, could you adapt the tool for the Xbox versions? There is no tool that works for this, and just like for the PS2 version, many projects die because they don't have a way to do this, I know I've already occupied you too much, but this support would transform your complete tool for all versions of the game, the ultimate tool, and I can test it for you, like what we did for the PS2. And I even think the format is similar. The current version of the tool even opens and extracts the textures, but does not re-import correctly, so below are the sample files, I sincerely hope that you want it and can also, your tool is wonderful:

SH2_XBOX_SAMPLES.zip

bellilite commented 9 months ago

Please, I have an Xbox project that has been on hold for a while, can you adapt the tool for the Xbox version too? Please... ๐Ÿ˜ฟ๐Ÿ™

iOrange commented 9 months ago

@IvNergal sorry it took so long, was busy at work. Try these ones, if they work will release a new version.

xbox_test.zip

IvNergal commented 9 months ago

@iOrange Congratulations! You did it again, Xbox it worked perfectly! Thank you again! You're really good at this man! Work

iOrange commented 9 months ago

Thanks, will release the new version today.

iOrange commented 8 months ago

@IvNergal @bellilite you can download the new version from https://github.com/iOrange/sh2tex/releases/tag/v1.2.2

IvNergal commented 8 months ago

Incredible! Thank you for everything!

IvNergal commented 8 months ago

Hi @iOrange sorry to bother you... but there is something wrong with the texture of the Xbox version. Sorry I didn't notice before, but when you replace the texture and put it in the game, everything seems normal, the game starts normally, you can play etc. But if you, from the initial screen (the texture in question), go to the menu of loading the saves and coming back... the game crashes. I tested with different types of palettes when replacing them, and the error persists. It's actually the texture, because when the original is placed, the error doesn't happen... This is only in the Xbox version. I apologize for bothering you again, and for having gone unnoticed in the tests...

In this file: start01.zip

iOrange commented 8 months ago

Interesting. Thanks for the feedback, I'll try to investigate.

bellilite commented 8 months ago

I also had the same problem.

iOrange commented 8 months ago

@IvNergal try this one. If it works - then I have a fix and will release fixed version.

start01_replaced.zip

IvNergal commented 8 months ago

Hello @iOrange , test done! Problem solved, it's working perfectly now. Thanks. Congratulations!

iOrange commented 8 months ago

@IvNergal again thanks a lot for testing! The new version is here -> https://github.com/iOrange/sh2tex/releases/tag/v1.2.3

IvNergal commented 8 months ago

I thank you for your attention and dedication! Thank you very much, your work is incredible.