libretro / beetle-psx-libretro

Standalone port/fork of Mednafen PSX to the Libretro API.
GNU General Public License v2.0
309 stars 130 forks source link

[Feature Request] Add custom texture dumping/injection support to Beetle PSX core. #492

Open saftle opened 5 years ago

saftle commented 5 years ago

Bounty Requirements:

https://www.bountysource.com/issues/70820889-feature-request-add-custom-texture-dumping-injection-support-to-beetle-psx-core

InfiniteT8 commented 4 years ago

My mistake, I kind of glossed over the information presented without getting down to the nitty-gritty. But that makes sense of why attempting to resize the textures(.bmp I believe) in photoshop and re-importing them back through uMod gave off a sort of blurred representation of the image.

I'm excited to see the interest in this taking off as I've wanted something like this for a long time. I most certainly will be donating in the not too distant future.

Meetem commented 4 years ago

Feature request noting to upload truecolor images with any size, so just uploading to vram is not an option unfortunately. And it actually makes no sense, cause even with vram scaled twice textures will get double resolution, but very small anyway (MGS textures for instance have a size of 30x30 average)

coccofresco commented 4 years ago

Any news? It was looking so promising....

Meetem commented 4 years ago

@coccofresco yes, I'am working on editor time to time, there only few core features left :)

MathRick9 commented 4 years ago

There is anyone working on it still? I'm struggling with Umod to retexture Silent Hill 1, a proper texture dump/import method would be awesome, you can see my progress here: https://www.silenthillcommunity.com/viewtopic.php?f=3335&t=438705 I had to stop because the game was way too instable. This quarantine time would be perfect for me to make this HD texture mod to SH1.

Meetem commented 4 years ago

@MathRick9 yeah, I'am still working (was in break for time), texture replacement will not be like replacing .tim files, it's nearly impossible, as well as because of color palettes, this would be VRAM patching and uploading images to virtual VRAM, true color with unlimited resolution.

charmandercha commented 4 years ago

The same logical can implemented in PS2 core?

Em seg., 13 de abr. de 2020 às 12:33, Alex Bakanov notifications@github.com escreveu:

@MathRick9 https://github.com/MathRick9 yeah, I'am still working, texture replacement will not be like replacing .tim files, it's nearly impossible, as well as because of color palettes, this would be VRAM patching and uploading images to virtual VRAM, true color with unlimited resolution.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/libretro/beetle-psx-libretro/issues/492#issuecomment-612950437, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAY5IJ2WMWIDMMPIICFRFHTRMMWEJANCNFSM4G3JOUMA .

-- Marcos Gabriel - Web Designer - Estudante em Humanidades pela Universidade Federal da Bahia Telefone: 3342-7338

InfiniteT8 commented 4 years ago

@MathRick9 yeah, I'm still working (was in break for time), texture replacement will not be like replacing .tim files, it's nearly impossible, as well as because of color palettes, this would be VRAM patching and uploading images to virtual VRAM, true-color with unlimited resolution.

Similar to Project 64's texture replacement method? I feel like it's possibly the best of best worlds as you could always go back to playing the original game if the textures are permanent/hard modded.

I'd definitely like to show my support and donate more in the future (when times are better). I feel like the bounty should be a bit higher for the work that has to be done.

Meetem commented 4 years ago

Yes, but no. Yes, because you can replace textures with any resolution and truecolor versions. No, because replacement method is not that easy on psx :c it's not like "just replace texture file". Anyways, thanks for you support, I'am appreciate it

On Tue, Apr 14, 2020, 00:29 TJ8 notifications@github.com wrote:

@MathRick9 https://github.com/MathRick9 yeah, I'm still working (was in break for time), texture replacement will not be like replacing .tim files, it's nearly impossible, as well as because of color palettes, this would be VRAM patching and uploading images to virtual VRAM, true-color with unlimited resolution.

Similar to Project 64's texture replacement method? I feel like it's possibly the best of best worlds as you could always go back to playing the original game if the textures are permanent/hard modded.

I'd definitely like to show my support and donate more in the future (when times are better). I feel like the bounty should be a bit higher for the work that has to be done.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/libretro/beetle-psx-libretro/issues/492#issuecomment-613107198, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2AF4SNZJPHTGYES6XGJKTRMN72NANCNFSM4G3JOUMA .

Mohsen865 commented 4 years ago

Hey everyone...

I asked a question about this issue from the creator of the ClassicRebirth mods for Resident Evil and Dino Crisis games, and this is his answer:

i would add some xml files with palette and textures for quick replacements in caches that's how i do it on dino crisis which does emulate the psx vram hashes + coordinates would be a good resolution

@REBehindtheMask

His Twitter account: https://twitter.com/REBehindtheMask

Hope this helps... 👍

Meetem commented 4 years ago

Thanks, it's close to the method I'am using

On Wed, Apr 22, 2020, 13:59 Mohsen notifications@github.com wrote:

Hey everyone...

I asked a question about this issue from the creator of the ClassicRebirth mods for Resident Evil and Dino Crisis games, and this is his answer:

i would add some xml files with palette and textures for quick replacements in caches that's how i do it on dino crisis which does emulate the psx vram hashes + coordinates would be a good resolution

[image: @REBehindtheMask] https://user-images.githubusercontent.com/12261908/79972858-d5d4f980-84ab-11ea-8ea3-8c4417ca09a8.png

His Twitter account: https://twitter.com/REBehindtheMask

Hope this helps... 👍

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/libretro/beetle-psx-libretro/issues/492#issuecomment-617707025, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2AF4UAZKUT2XL4Y2JEBN3RN3EY7ANCNFSM4G3JOUMA .

ryuubu commented 4 years ago

You have my support! Could this be used to replace backgrounds like Final Fantasy or Legend of Dragoon?

Meetem commented 4 years ago

I suppose it will. I haven't checked it, but my method will be quite universal

I hope I'll show something in a week On Sun, Apr 26, 2020, 03:41 ryuubu notifications@github.com wrote:

You have my support! Could this be used to replace backgrounds like Final Fantasy or Legend of Dragoon?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/libretro/beetle-psx-libretro/issues/492#issuecomment-619460546, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2AF4UOO7UBB6IBRTS2BMDRON7NHANCNFSM4G3JOUMA .

charmandercha commented 4 years ago

My ESRGAN is ready!

Meetem commented 4 years ago

Heyyo, I have something there. It's VRAM preview with CLUTs! Also there are some other screens for texture editing, but they're pointless to show for now. From this screen shown on video you will be able to export textures to normal image formats and also copy used CLUT hashes (will be used for texture replacement). There are no buttons yet, but preview is working

https://youtu.be/7DX3r0FjWiQ

lyonhrt commented 4 years ago

thats awesome stuff meetem, when your ready for testers i'll certainly see what it can do

lyonhrt commented 4 years ago

Heyyo, I have something there. It's VRAM preview with CLUTs! Also there are some other screens for texture editing, but they're pointless to show for now. From this screen shown on video you will be able to export textures to normal image formats and also copy used CLUT hashes (will be used for texture replacement). There are no buttons yet, but preview is working

https://youtu.be/7DX3r0FjWiQ

whats the fps like, i see it uses unity, i know someone has done a wrapper for custom graphics for an emulator for custom assets using unity, but my only issue was with everything going on, it did start to struggle, but if you have optimisations, im guessing you can go beyond just basic texture replacement, and add materials similar to something like dolphin ishiiruka or anything that unity can use... hdrp would be a dream (a slide show but a dream to see)

Meetem commented 4 years ago

@lyonhrt Unity is used only for editor application (cause I want it both crossplatform, and have nice UI), to make texture packs. Of course all replacement stuff will work within core's code written with C++ (I already have some tested techniques). But even this editor application required some optimizations with Burst to maintain good performance because emulator sending tons of data.

Once you've made texture pack, editor application have no use any more. So game performance will be almost like normal emulated game.

P.S I've thought about shaders for rendering like normal mapping e.t.c, dunno if it possible to implement at least for most games. I don't have enough info about PSX polygon lighting

coccofresco commented 4 years ago

Good work!

For the shader: if i'm not wrong, psx has not actual light, only per-vertex color added to the texture.

lyonhrt commented 4 years ago

@lyonhrt Unity is used only for editor application (cause I want it both crossplatform, and have nice UI), to make texture packs. Of course all replacement stuff will work within core's code written with C++ (I already have some tested techniques). But even this editor application required some optimizations with Burst to maintain good performance because emulator sending tons of data.

Once you've made texture pack, editor application have no use any more. So game performance will be almost like normal emulated game.

P.S I've thought about shaders for rendering like normal mapping e.t.c, dunno if it possible to implement at least for most games. I don't have enough info about PSX polygon lighting

ahh ok, sorry for the confusion, that makes sense glad it won't have a performance drop

simias commented 4 years ago

Good work!

For the shader: if i'm not wrong, psx has not actual light, only per-vertex color added to the texture.

There is a concept of light source... in the GTE on the CPU. Getting that info to the GPU in a usable way is left as an exercise for the reader.

inactive123 commented 4 years ago

Cool stuff @lyonhrt, awaiting this eagerly.

stoofin commented 4 years ago

@Meetem I'm willing to help make sure texture replacement works with chrono cross, if you want. The game's mostly well behaved, but it blits over eyes during battle for blinking, saves sections of vram when entering menus then reuploads them when exiting, and uploads all spell effect textures in small 2048 byte chunks.

Meetem commented 4 years ago

@stoofin thanks! Will see later, hope spells wouldn't even be a problem, but copying vram and reupload... That's not easy to handle. Where does it takes memory for storing vram copy btw? Can I contact you for details somehow?

simias commented 4 years ago

I've seen a few games that do that (swap texture pages in and out of VRAM). I noticed it because I hadn't implemented VRAM loads in my emu and obviously those games weren't working right.

intra32 commented 4 years ago

Great work! Do you think mipmap support is possible? I really want to add textures with custom mips for some cool distance based effects.

stoofin commented 4 years ago

@Meetem I'm not sure on the details of how vram is read back. Command_FBRead is called, if the software framebuffer is disabled it in turn calls rsx_intf_read_vram and then if vulkan is used rsx_vulkan_read_vram. I guess if the software framebuffer is enabled then that vram is already up to date, but otherwise these pass along a requested rect and a vram pointer to write the results through. Afterwards I assume it then does some kind of emulated copy from that vram to normal ram.

I do know that for the specific case mentioned in chrono cross, if vulkan is used and software framebuffer disabled, that the rect requested and pixels returned by rsx_vulkan_read_vram are identical to those later provided in a call to rsx_vulkan_load_image.

If you've got a discord I'm slerp#0545

InfiniteT8 commented 4 years ago

@lyonhrt Unity is used only for editor application (cause I want it both crossplatform, and have nice UI), to make texture packs. Of course all replacement stuff will work within core's code written with C++ (I already have some tested techniques). But even this editor application required some optimizations with Burst to maintain good performance because emulator sending tons of data.

Once you've made texture pack, editor application have no use any more. So game performance will be almost like normal emulated game.

P.S I've thought about shaders for rendering like normal mapping e.t.c, dunno if it possible to implement at least for most games. I don't have enough info about PSX polygon lighting

With texture packs would it be possible to do full retextures of some games without crashes, glitches, etc? With the other external tools available (texmod & uMod) the number of active textures uploaded had its limits and of course was met with crashes, glitching, etc.

I'm happy to see progress on this project and more so that I was able to contribute. I'm looking forward to seeing future progress. Thanks for sharing!

Meetem commented 4 years ago

@InfiniteT8 number of textures will be limited to your RAM, and will dynamically change according to game currently used textures. There is treadeoff between memory usage and lagless experience. I can't guarantee it will bugfree, but I have some concepts in mind, may be async texture loading e.t.c Texmod AFAIK using completely different techniques to replace textures

Meetem commented 4 years ago

@lyonhrt hey! I have something you can test, I'am done with texture exporting. So I can provide you new core and build to test. There is just exporting for now. If you are interested, please contact me at Discord: Meetem#1565

lyonhrt commented 4 years ago

@lyonhrt hey! I have something you can test, I'am done with texture exporting. So I can provide you new core and build to test. There is just exporting for now. If you are interested, please contact me at Discord: Meetem#1565

yeah i've got the weekend to test things, i'll go on discord now!

charmandercha commented 4 years ago

can use VRAM instead RAM? (i'm dumbess in this discussion, it's a legit doubt)

Meetem commented 4 years ago

@gamaghostmagus what do you mean by this? Using RAM to store textures and then upload them to GPU for responsive rendering and less VRAM consumption? Probably yes :)

charmandercha commented 4 years ago

there is a way to test it out? (today)

i'm in quarentine like others and i do not have other things to do lol

:o

Meetem commented 4 years ago

@gamaghostmagus for now I made texture exporting from my editor, that's the only done thing, you can contact me in discord if interested (contact seen above)

SirFancyBacon commented 4 years ago

I'm interested in testing as well if you need additional help. I shot you a friend request on Discord @Meetem

I've got a windows machine, as well as a Linux machine for cross platform.

RecklesFlam1ngo commented 4 years ago

I'm here because I've been searching for a way to replace textures, no luck with gpubladesoft as he seems to have abandoned the plugin, will eagerly be waiting for hopefully when beetle has texture replacement ;)

InfiniteT8 commented 4 years ago

I'd love for this bounty to have more attention, more so for the PSX gaming/modding community. Check out the bounty and donate if you're able to. I'm sure this would help any developer's motivation to work on this.

inactive123 commented 4 years ago

So just as a headsup - this bounty should be safe from BountySource's recent decision to pocket the money if a bounty is exactly two years old and has no solutions yet. That being said, in the short term this sudden and swift change in policy probably suggests we probably want to start protecting ourselves here and maybe finding some alternatives (and protecting the money along the way so that it doesn't go 'poof'). I'd like to hear some ideas on moving forward.

Second - @stoofin's current WIP is currently in master, so people can test the Chrono Cross pack already that is circulating. Now it's important to know where to go from here. Can somebody write a tutorial explaining how the current system works and how one would go about making a pack like this? Does the current method only support a few games? How do we expand things from here, and can we come up with more PoCs for other games?

I have absolutely no qualms about the texture replacement code design changing later on as we realise certain things need to change, as long as we get some momentum going and other people participating in the custom asset creation process, as @InfiniteT8 suggests.

Let's try to pick a couple of tentpole games like Resident Evil, FF7, MGS and so on and then figure out if the current system is sufficient for texture replacement in those games, or whether we need extensions.

But most importantly - people that might want to get involved in doing these packs themselves need to know how it all works. Preferably in whatever tutorial gets written, it gets explained too how to do this by hand without external looks like custom editors if at all possible. But of course, the tutorial can also explain how to do things with the editors that people wrote in this thread.

lyonhrt commented 4 years ago

i've done a ton of tests on this @twinaphex and i'm actually surprised how well it does work, 2D games is off the table (so far all the tests i've done is crash), and it has all the original issues with vram dumping so some corrupt textures, or multiple images with different palettes etc, which makes it tricky (so possibly possible?) some games are easier than others and dump without issues (resident evil directors cut actually does dump usable textures). i can see why @Meetem went the direction he went with his method of texture injecting and dumping for more control. I have done the "simple" method of chucking all the dumped textures in an ai upscaler, then throw the processed textures back in to see what happens, and did turn out better than expected (driver the wheelman) but i can't tell you exactly why it worked at this stage.

you can catch me on discord LyonHrt#1856 if i have any extra findings, or methods that would work for general use

InfiniteT8 commented 4 years ago

I'm currently testing out @stoofin 's wip but have found that there's no option to turn on replace textures at the quick menu.

I also noticed that outside of Chrono Cross, it's all left to be figured out how we could replicate @stoofin methods with upscaling rather than giving an idea of how to accomplish this with other games. So I 2nd @twinaphex's call for a tutorial haha.

@twinaphex Perhaps if a stable enough project that meets the requirements for a good number of games (3d and 2d) I could see the bounty being safe enough. Perhaps there could be a discord room for testing, bug reports, updates, etc where the developers, testers, and contributors could correspond in real-time.

I was also able to test @Meetem early WIP of his tool. I like the concept of being able to see the textures populate real-time in the tool but I believe that being able to turn the feature on and off while the tool is still open in the background would allow users to focus on the exact textures they're looking to extract at any given moment.

What I liked about @Meetem tool was the easy setup. Though it's not quite fully functional I feel like it has a lot of potentials.

inactive123 commented 4 years ago

I have setup a Discord room on RetroArch's Discord - it's called #texture-replacements.

@lyonhrt is already in there so we could use it for further discussion and research/development.

https://discord.com/invite/27Xxm2h

saeedAlshaikh commented 4 years ago

Hi folks , I have done some testing on the new core update ( the official one)

https://forums.libretro.com/t/beetle-psx-hw-texture-replacement-testing-feedback/28954

According to the Chrono Cross pack creator Tiriosaurus reddit , he used external tools to dump the textures which probably give better & bigger texture chunks of background games instead of the tiny ones dumped by the core

https://www.reddit.com/user/Tiriosaurus

Bloguis3 commented 4 years ago

@twinaphex Check the Resident Evil Seamless HD Project from @MoArtis: https://www.reshdp.com https://github.com/MoArtis/ResidentEvilSeamlessHdProject

They're aiming to restore the first 3 original resident evil games with AI upscaled textures. They have already completed Resident Evil 2 and 3, using a custom dolphin emulator (for the gamecube versions of the games).

From their discord channel, they appear to be looking for a resident evil 1 engine\emulator that allows for texture replacement.

You're looking for a game to showcase beetle's texture replacement capabilities, they're looking for an emulator\engine that allows to replace RES1 textures, if both your teams could work together to accomplish this, it would be great.

inactive123 commented 4 years ago

Sure they can stop by in the Discord chat and talk with the real guys that are doing all this texture replacement work like @Meetem, @lyonhrt and @stoofin . I think it's important to emphasize that Libretro as a team is not necessarily doing the coding on this project.

Anyway, sounds great. I quite like the Seamless HD projects myself, would be great if they did packs like that for the PS1 games too.

MoArtis commented 4 years ago

Thanks for pinging me! We heard about that feature. It's a great news for us and we will definitely look into it as soon as possible. If we can get a good proof of concept running, we will share it here and on that dedicated libretro discord channel. :)

eGax commented 4 years ago

It's really not. This is an open issue created requesting a feature, nothing to do with texture replacement bugs. It's in your best interest to please make your own issue instead of trying to hijack someone else's.

saftle commented 3 years ago

theflyingzamboni, Kupo and @lyonhrt, and anyone else that are working on projects or have tested this extensively, could you possibly list the current issues that would need to be fixed to get the ball rolling? Thanks!

InfiniteT8 commented 3 years ago

Hi guys, I'm finding with the current implementation of Beetle PSX HW's texture replacement feature, I experience crashes when tracking is activated before the game starts. It doesn't exactly get pass the Now Loading screen and it fails to grab some background textures, and loading screens (duckstation's latest unofficial release covers those bases). I expereince these crashes with Smackdown 2 specificially. I can't be sure if this happens to other games.

saftle commented 3 years ago

Here are a few issues opened by theflyingzamboni and Zychronix:

[Feature Request] Dump paletted textures as a single image #772 Some textures not dumping/replacing in The Legend of Dragoon #773 Track Textures reducing gameplay performance #778

theflyingzamboni also mentioned the following in the libretro discord:

Regarding palettes, certain types of textures not dumping or replacing, and certain performance hits from just having track textures turned on. An issue should probably be filed for transparency calculation too, as I think that's slightly incorrect currently

Edit: I also found the following issues:

Texture dump issue if palette is not 4bpp nor 8bpp #715 Texture replacement causes textbugs #692 Semi-Transparent texture replacement issues #686