Texture replacement issue - Printable Version

+- (
+-- Forum: PPSSPP - Playstation Portable Simulator Suitable for Playing Portably (/forumdisplay.php?fid=1)
+--- Forum: Development (/forumdisplay.php?fid=3)
+--- Thread: Texture replacement issue (/showthread.php?tid=20725)

Texture replacement issue - Danikk04 - 09-13-2016 07:34 AM

I have tried out the texture replacement feature in SD Gundam G Generation Overworld in order to use higher resolution sprites ripped from earlier games (PS2) in the series.
The issue I'm having is that most sprites in the game are 384*384 or 192*192 in size, and PPSSPP dumps them as 512*512 or 256*256 with random junk filling out the rest of the image. This is an issue, because if the random part of the sprite is different, the image will have a different hash for its data, and since the address changes every time the sprite is loaded as well, it means I can't "lock on" onto a given sprite for replacement. (since the only thing staying constant is the CLUT)
Is there any way for the emulator to detect the real size of the sprite and output it in that size (or at least clear the rest so it will always be the same)?

RE: Texture replacement issue - YukiHerz - 09-13-2016 02:28 PM

Yes, i assume you created a text file to replace textures, you need to add a [hashranges] section, like so:
0000000094ec50084e45c94c = Pokke/Tree2.png

0x0419c200,256,256 = 160,160
0x091bf4d0,512,512 = 480,272
0x091df700,512,512 = 480,272

0x = No reason to change this.
XXXX... = The first 8 digits of dumped texture's filename (The address)
YYY = The Width of the dumped texture (With garbage data)
ZZZ = The Height of the dumped texture (Again, with garbage data)
AAA = The real width of the dumped texture (without the garbage, horizontally the textures tend to repeat rather than generate garbage)
BBB = The height of the texture (without the garbage)

After that the texture will be dumped again with the width specified in A and the height in B, and the correct hash.

RE: Texture replacement issue - Danikk04 - 09-13-2016 02:39 PM

Yes, I have created the text file.
The problem with this solution, is that these textures get stored at a different address every time they are loaded, so the first 8 digits of dumped texture's filename is different each time as well.

RE: Texture replacement issue - [Unknown] - 09-15-2016 03:13 AM

Unfortunately, this is a problem that PPSSPP itself faces when emulating this game. It cannot tell that it's the same texture.

I mean, theroetically, we could hash the top left 384x384 and the top left 192x192 of EVERY texture, etc. etc. etc. Unfortunately, this would really hurt performance. Hashing texture data isn't fast, and we have to do it often to see if it was changed by the game.

The other option might be if the game consistently uses the top left 384x384 in a very recognizable way for us. But that isn't implemented yet and it's more complicated than it sounds. It can still hurt performance but as long as we're sure the game is using a subset of the texture, we can hash a subset of it.

The PSP hardware was only capable of using textures a power of two in size on each side. So 384 wasn't an option. It has to size the texture as 512 or 256 - there are no options in between.


RE: Texture replacement issue - Hobby3D - 09-17-2016 04:15 PM

What's this about a text file? I just found about the texture replacement feature today and am trying to find any sort of faq explaining how to use it...

RE: Texture replacement issue - [Unknown] - 09-17-2016 06:56 PM

See here: