elishacloud / Silent-Hill-2-Enhancements

A project designed to enhance Silent Hill 2 (SH2) graphics and audio for the PC. It also includes scripts to build or modify SH2 audio files (SFX, BGM and Dialog).
http://www.enhanced.townofsilenthill.com/SH2/
zlib License
566 stars 41 forks source link

[Request] Texture Tool #400

Closed hgdagon closed 2 years ago

hgdagon commented 3 years ago

I don't know how else to contact you, guys, so here goes...

I love the work done on the project, and I would like take a look at the new images. The only tool I have is "SH2 Texture Explorer", which hasn't been updated in years, and can only process one file at a time. I wrote an autoit script for it, that would take a list of files, but even that took forever. Also, it doesn't support the images.

Now, I'm assuming you guys use a different tool, so I was wondering, if you'd be willing to share it with the rest of us?

P.S. Also, a question regarding contributing to the project; would you guys be interested in an installer/auto-updater?

Polymega commented 3 years ago

Hi there,

We unfortunately don't have a tool for this. Everything was done "by hand," so to speak. It was a rather long process. You can read some of my notes on it here: https://github.com/elishacloud/Silent-Hill-2-Enhancements/issues/339#issuecomment-720768282

P.S. Also, a question regarding contributing to the project; would you guys be interested in an installer/auto-updater?

Very much so. An installer and updater that updates all packages is something we've had on our to-do list for a while.

hgdagon commented 3 years ago

An installer and updater that updates all packages is something we've had on our to-do list for a while.

I messed around a bit. The problem is C/C++/C# is like Japanese to me. So, first I tried something with InnoSetup, which isn't exactly made for that type of thing, and then I gave it another try with FreePascal/Lazarus.

The tool could install SH2 (from a provided media), mess with the settings (like a GUI for d3d8.ini), and download/install Enhanced Edition zip files. Never implemented an actual version checking.

I can upload the sources, for you guys to use as a starting point or something, to write an actual one. Or, maybe finish it, if you guys don't mind Pascal.

hgdagon commented 3 years ago

You can read some of my notes on it here: #339 (comment)

Hm... Maybe I can write a tool myself

Polymega commented 3 years ago

I'm programming-impaired, so I can't comment on the finer details of this, so I'll leave this up to Elisha (our lead programmer) to respond. He may want to keep everything in the C family, I'm not sure. But I can comment and say thank you for reaching out and offering to help!

hgdagon commented 3 years ago

He may want to keep everything in the C family

Yeah, I did think about that.

Also, you have a version of SH Resource Editor, with the texture tab working?

Polymega commented 3 years ago

Also, you have a version of SH Resource Editor, with the texture tab working?

I do not. I only have version 3.1, and the texture tab is greyed out.

hgdagon commented 3 years ago

Then what did you mean here?

If you view the original textures in the SH Resource Editor, it'll tell you what DXT format they are. Although, DXT2 is actually DXT3, and DXT4 is actually DXT5.

Polymega commented 3 years ago

This is a different piece of software. You can get it here: http://alchemillahospital.net/how-to-use-sh-texture-explorer/

As noted in my post on that other thread, I wouldn't actually use this software to import/export textures; it messes up the alpha channels and introduces its own type of compression artifacts in the images.

Edit: I just realized I wrote "SH Resource Editor" and not "SH Texture Explorer" in my long post on the other thread. I'll fix that.

elishacloud commented 3 years ago

I'll leave this up to Elisha (our lead programmer) to respond. He may want to keep everything in the C family

If you are adding code to the sh2e module itself than it needs to be C++ code. However, if you are creating tools or even an installer for the project then it does not need to be in C++. I have even written a few tools for this project using batch files. I would rather use the right tool for the job than try and force one tool to fit every job.

Polymega commented 2 years ago

Hope those tools helped, hgdagon. I'll close this ticket out.

iOrange commented 9 months ago

Hi @Polymega , I know this thread is closed, but I wanted to let you guys know that I've made a fresh tool to View and Edit Silent Hill 2 textures that you might find useful. It can detect (to a certain degree) issues in existing textures (like those that were manually edited for sh2ee) and report on them, and even fix them on texture re-save. You can extract any of the inner textures and replace them as well. It can even create new textures from scratch, though benefit of this is questionable since the game won't be able to load them anyways (since everything is hardcoded there.)

I've decided to post it here to get some feedback. So far all *.tex* and .tbn2** textures supported (except some weird ones dated June 2001, but I'll crack them open as well). I also have code to view *.xbx textures, will be added to the tool with the next update.

Feel free to message me with any issues/suggestions.

The source code will be opened soon, need to make it pretty first. Since you don't know me, I've uploaded it to MODDB (I sometimes upload my other tools there). It should be available for download after moderators check it (in about 20 hours or even less). https://www.moddb.com/mods/silent-hill-2-born-from-a-wish-ai-upscale-mod/downloads/sh2tex-v097

screen_01 screen_02

Polymega commented 9 months ago

This is amazing, @iOrange !!! Thank you!! I'll get to playing with this in the near future and let you know if I run into any issues.

So far all .tex and .tbn2 textures supported (except some weird ones dated June 2001, but I'll crack them open as well). I also have code to view *.xbx textures, will be added to the tool with the next update.

This is especially useful as I still use the old SH Texture Explorer to view/edit textures for .mdl files. I just wish I had this back when I was doing the Image Enhancement Pack (for .tex files). I had to update those via manual hex data swapping... I would've killed for this back then... 😅

This is brilliant and I thank you dearly for making it and informing us about it! I'll let some of my other SH friends know who run websites about this tool in the hopes they can further share the news of its release/existence.

Thanks again!!

Polymega commented 9 months ago

It can detect (to a certain degree) issues in existing textures (like those that were manually edited for sh2ee) and report on them, and even fix them on texture re-save.

This looks to possibly cause errors. I tested this by opening \sh2e\etc\effect\footmark.tbn2. I received the size error message from your tool, re-saved it out to fix the error, but now the game won't launch when using our project files. Reverting the change has the game launch again.

iOrange commented 9 months ago

This looks to possibly cause errors. I tested this by opening \sh2e\etc\effect\footmark.tbn2. I received the size error message from your tool, re-saved it out to fix the error, but now the game won't launch when using our project files. Reverting the change has the game launch again.

Oh this is interesting. That field it fixes contains the actual texture's data size, now I wonder why it breaks the game, as in theory this should have the opposite effect. I'll try to dig deeper. Thanks!

Need to understand this behaviour better as my plan was to make my tool able to load and edit textures inside models and levels.

Polymega commented 9 months ago

Oh this is interesting. That field it fixes contains the actual texture's data size, now I wonder why it breaks the game, as in theory this should have the opposite effect. I'll try to dig deeper. Thanks!

It might be worth asking @elishacloud about this, as he's one of the people who helped make the game read higher res textures possible. It might be a "quirk" with the game that we had to work around.

Need to understand this behaviour better as my plan was to make my tool able to load and edit textures inside models and levels.

Yeah, sorry about that! I saw your image (re-posted below) and immediately assumed it was from a .mdl file. 😅 The .mdl and .map files are well RE'ed. If this helps in any way:

screen_02

iOrange commented 9 months ago

@Polymega yeah, that's my theory as well that SH2 has a lot of stuff hardcoded. I'll disable the "fix wrong sizes" code for you with the next update.

As for the .mdl and .map files - I've reverse-engineered them couple of years ago for my own project "open-source Silent Hill 2 reimplementation", just need to use that code (which is super ugly and chaotic atm.) in this tool.

elishacloud commented 9 months ago

It might be worth asking @elishacloud about this, as he's one of the people who helped make the game read higher res textures possible. It might be a "quirk" with the game that we had to work around.

The game uses a static memory location and size where it stores textures. I updated the memory pointer of this location so that we could make the size dynamic and grow it based on the size of the textures. The code we added reads the actual file size from the Windows file system, not the size in the texture.

I am not quite sure how the game uses the size in the texture.

iOrange commented 9 months ago

The game uses a static memory location and size where it stores textures.

interesting, will dig a bit today in IDA after work, as I was wondering why sh2ee's textures were working since the dimensions changed, while the data_size field of the sub-texture header left unchanged and was smaller now than it should (and I relied on it in my loader).

iOrange commented 9 months ago

@Polymega it took me a bit but I've made a new version for you - now it keeps the original data size field untouched, so you can use it to modify textures and the game should be happy now. The tool will now show that the texture data size is incorrect in red in it's properties, but won't touch that.

I also made my tool to load PS2 textures OMG what a quest! Had to dive into PS2 graphics chip specs, but now I can load any SH2 texture. Editing is disabled for them though. I'll upload the new version to MODDB soon, here's the compiled version for you. As always - feedbacks are welcome! sh2tex_v098.zip

screen_03 screen_04

Polymega commented 9 months ago

Nice work, iOrange!! And PS2 viewing support now as well? Right on! I've been playing with it and haven't encountered any issues. Great job with this!

iOrange commented 9 months ago

@Polymega yes, PS2 only viewing for now (not even sure if anyone needs editing for those tbh). Made it just out of the curiosity.

A already added viewing + editing of textures inside map files. Once I do the same for mdl files - I'll release the new version, and hope to open the source code as well so people can fix/add/improve stuff if they want.

iOrange commented 9 months ago

@Polymega I've made a new version - now you can load any map and model, view textures inside, extract any sub-texture and replace them. Then save your map/model with the new textures!

MODDB link - https://www.moddb.com/games/silent-hill-2-maria-quest/downloads/sh2tex-v099

screens: screen_06

screen_05

Polymega commented 9 months ago

chef's kiss

This... is... beautiful. 😭 Wonderful, wonderful work you're doing here. The only oddity I found was, when selecting a file to open, .mdl isn't on the list of options:

image

Maybe include another category that displays them all? Something like "All supported files (.tex, .tbn2, .map, .mdl)"?

Thanks!

iOrange commented 9 months ago

@Polymega thanks for reporting a bug! My bad, BTW - you can drag & drop files into the window, and it'll open it. Kinda a workaround for you right now. Or just select "All files (.)" as a filter.

iOrange commented 9 months ago

@Polymega I've released the final version, and also opened the source code - https://github.com/iOrange/sh2tex Thanks again for your feedbacks.

BTW - added zoom (Ctrl + +/-)

Polymega commented 9 months ago

CONGRATULATIONS!

I'm currently reaching out to my friends who run SH websites/accounts to make a news announcement about the 1.0 release of your tool. I'll follow up in this thread with links if/when they make announcements. I also made a Tweet (not calling it "X") about it as well: https://twitter.com/theRatiocinator/status/1736067302729122000

Thank you dearly and sincerely for doing this. ❤️

iOrange commented 9 months ago

Thanks. I'm in the process of developing the Model Viewer / Editor for the Silent Hill 2 as well. Might hit you up for your thoughts / suggestions if you don't mind @Polymega

Polymega commented 9 months ago

Thanks. I'm in the process of developing the Model Viewer / Editor for the Silent Hill 2 as well. Might hit you up for your thoughts / suggestions if you don't mind @Polymega

😱 😱 😱 There currently exists no version of a .mdl viewer/editor* in the SH2 modding scene so holy. crap.

Yes, please keep me posted!!

*Edit: Well, very old, beta versions of the SH Level Viewer tool could view the .mdl files, but the feature was dropped as that tool progressed.

Polymega commented 8 months ago

I got some friends to make posts about it. Thank you again!!

iOrange commented 8 months ago

@Polymega thanks :) I've found one bug, + added some minor features (including dark theme as requested by some users). Will post new version here soon.

Edit: here it is - https://github.com/iOrange/sh2tex/releases/tag/v1.1