Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial texture replacement support #8715

Merged
merged 34 commits into from
May 1, 2016

Conversation

unknownbrackets
Copy link
Collaborator

@unknownbrackets unknownbrackets commented May 1, 2016

See #4630 for more info.

This is already fairly usable, but we may want to not merge it until "stable". I did add a version so we can maintain compatibility if we want to.

Not tested on Android, only on Windows.

Supports an ini with this syntax (ini file is optional, and all sections are optional):

[options]
version = 1
hash = quick

# By default, a file with .png at the end of the hash is used.
# Override below to share filenames or use custom filenames.
# To skip a texture (like videos) use a blank filename on the right side.
# Syntax: hash = filename.png
[hashes]
# Ignore the intro video textures.
099bf1c000000909 =
0993698000000909 =
09a47a0000000909 =
09ad024000000909 =
# Water animation.
099c0db096c0500ecd2f3e6e = water/frame1.png
099c2db0d26dc9a7966195cf = water/frame2.png
099c4db0fa2cbcfec0bd3e0f = water/frame3.png
099c6db0d17d9a67c7591d4f = water/frame4.png
# This texture is loaded at two addresses.  The content is the same.
094b89907dcca1a5ee284131 = 094b5a707dcca1a5ee284131.png
# Alias the extra mip level too.
094b89907dcca1a5ee284131_1 = 094b5a707dcca1a5ee284131_1.png

# This allows customizing the range of a texture that is hashed.
# Careful: sometimes the same address is reused later for a texture that needs more hashing.
# Syntax: address,w,h = w,h
[hashranges]
# Force the intro video to hash 480x272.
0x09936980,512,512 = 480,272
0x099bf1c0,512,512 = 480,272
0x09a47a00,512,512 = 480,272
0x09ad0240,512,512 = 480,272
# Clip logos to actual texture size.
0x090056d0,256,256 = 176,160
0x0900c4d0,256,64 = 208,56

-[Unknown]

@hrydgard
Copy link
Owner

hrydgard commented May 1, 2016

Cool!

Some ideas for further improvements (of course not required for merge):

  • I may have missed this in the code (just skimmed it), but an idea to ignore videos for replacement: In 99% of cases (well, every case except LBP) we know where the video decoder wrote a texture. So we could automatically mark it as not needing replacement, by just adding the addresses into aliases_ directly, for example.
  • As for mip levels, it may make sense to allow DXT or KTX texture files, both of which can store mipmaps directly.
  • If a user only provides the top mipmap, we could autogenerate the rest, if the game expects a mip chain.

@unknownbrackets
Copy link
Collaborator Author

Well, skipping videos was just an example. Theretically, you could upscale each frame of the video as a separate png and it'd probably be fine. But, yes, we could automatically skip videos.

Yeah, not against auto-generating mipmaps. I'm assuming we would likely want more mip levels when using replaced upscaled textures, if anything (which is why this supports adding more miplevels.)

-[Unknown]

@hrydgard
Copy link
Owner

hrydgard commented May 1, 2016

Well, ignoring videos automatically will be very useful to avoid having the SaveNewTextures mode writing hundreds of megabytes of PNGs in many games...

For video replacement it would be better to replace with a video file than a series of PNGs anyway (though, fan-producing upscaled video is not an easy task, heh), though that's a wholly different project (as we'd need to do things rather differently).

@i30817
Copy link

i30817 commented May 1, 2016

Another thought is that if there existed a multi emulator extensible rom container format - like in a certain closed issue for maxcso ;) - for reversible_translations/manuals/hacks/compression, another header could very well be texture replacement with the textures and mapping built in.

We want to return a reference here, so let's always return.
@unknownbrackets
Copy link
Collaborator Author

This still doesn't build on Qt, and I don't have a Qt environment set up to debug the linking problem. It links fine elsewhere.

It doesn't even work on Qt so I'm halfway inclined to just ifdef it off on Qt.

-[Unknown]

@unknownbrackets
Copy link
Collaborator Author

I've implemented video replacement skipping now, and also removed the "g_iNumVideos" hack.

-[Unknown]

This is a bit of a hack, but it resolves the linking issue that only
seems to happen in the Qt build system.
@hrydgard
Copy link
Owner

hrydgard commented May 1, 2016

Very nice!

@unknownbrackets
Copy link
Collaborator Author

I've also hacked the Qt linking issue away. It's not perfect, though, but maybe it can be improved later by someone maintaining the Qt build.

-[Unknown]

@hrydgard
Copy link
Owner

hrydgard commented May 1, 2016

Good enough for me :)

@hrydgard
Copy link
Owner

hrydgard commented May 1, 2016

LGTM, merge at will

@unknownbrackets
Copy link
Collaborator Author

BTW, those games have problems with texture replacement and the fast texture cache showing outdated 'replacements' when you use stuff in the inventory. I dunno if PPSSPP has a equivalent problem, just a thought.

This could happen here too, but I think in general our hash is strong enough that this should be rare. Using lazy texture hashing will affect replacements the same as regular textures, too.

-[Unknown]

@unknownbrackets unknownbrackets merged commit 9280bb3 into hrydgard:master May 1, 2016
@unknownbrackets unknownbrackets deleted the tex-replace branch May 1, 2016 17:11
@fuhuan416
Copy link

Excuse me, now can only save the textures please? I've already enabled the replacetexture and savetexture in ppsspp.ini. Also found a lot of textures appears in titleID folder. But i don't know what to do next? How to replace texture?

@unknownbrackets
Copy link
Collaborator Author

Modify the images and move them from ULUS12345/new/ to ULUS12345/. Then it will use the modified versions.

It places them in new/ by default so you can tell which ones you haven't modified yet.

-[Unknown]

@fuhuan416
Copy link

It's worked! It's awesome! Thank you guys, i love you all :)

@unknownbrackets
Copy link
Collaborator Author

unknownbrackets commented May 8, 2016

In general, KTX support looks fairly desirable - people could use various tools like the "Mali Texture Compression Tool" to generate compressed textures with that too, which would work at least on any GLES3 device.

Potentially this could even be used to improve performance, as a "compressed texture pack" rather than a "HD texture pack". Warning: there is some overhead added by texture replacement, though. I also think a compressed HD texture pack may usually be visually superior to regular textures, but work better on memory/bus-constrained devices.

I noticed the Khronos loader can even decompress if ETC is unsupported:
https://github.com/KhronosGroup/KTX/blob/master/lib/loader.c

Unfortunately, it goes direct to GL, though. Would be nice to support Vulkan and etc.

-[Unknown]

@johannes21j
Copy link

See #4630 for more info.

This is already fairly usable, but we may want to not merge it until "stable". I did add a version so we can maintain compatibility if we want to.

Not tested on Android, only on Windows.

Supports an ini with this syntax (ini file is optional, and all sections are optional):

[options]
version = 1
hash = quick

# By default, a file with .png at the end of the hash is used.
# Override below to share filenames or use custom filenames.
# To skip a texture (like videos) use a blank filename on the right side.
# Syntax: hash = filename.png
[hashes]
# Ignore the intro video textures.
099bf1c000000909 =
0993698000000909 =
09a47a0000000909 =
09ad024000000909 =
# Water animation.
099c0db096c0500ecd2f3e6e = water/frame1.png
099c2db0d26dc9a7966195cf = water/frame2.png
099c4db0fa2cbcfec0bd3e0f = water/frame3.png
099c6db0d17d9a67c7591d4f = water/frame4.png
# This texture is loaded at two addresses.  The content is the same.
094b89907dcca1a5ee284131 = 094b5a707dcca1a5ee284131.png
# Alias the extra mip level too.
094b89907dcca1a5ee284131_1 = 094b5a707dcca1a5ee284131_1.png

# This allows customizing the range of a texture that is hashed.
# Careful: sometimes the same address is reused later for a texture that needs more hashing.
# Syntax: address,w,h = w,h
[hashranges]
# Force the intro video to hash 480x272.
0x09936980,512,512 = 480,272
0x099bf1c0,512,512 = 480,272
0x09a47a00,512,512 = 480,272
0x09ad0240,512,512 = 480,272
# Clip logos to actual texture size.
0x090056d0,256,256 = 176,160
0x0900c4d0,256,64 = 208,56

-[Unknown]

when i open the game it is normal when i paly it kick me out then i delete Textures configuration setting then it stop kick me out please help

@hrydgard
Copy link
Owner

hrydgard commented Apr 8, 2022

@johannes21j Please file a new issue instead of posting in old pull requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants