Avocado icon indicating copy to clipboard operation
Avocado copied to clipboard

Support Model Export

Open LukeSchoen opened this issue 2 years ago • 22 comments

Hi,

I'm the poster of this short article:

https://old.reddit.com/r/PlaystationClassic/comments/tjxxpw/today_i_found_out_how_to_rip_3d_models_from_all/

I've been hacking around in the avocado project and ive found a way to reliably export 3D models from any game.

The system ive jerried together dumps raw data from avocado then processes it in my own code base, i would love to discuss implementing the whole process within avocado and adding a simple 'save 3D scene frame as OBJ' button.

Also my current technique needs some texture handing improvement, i would like to process the texture pages into actual output RGB before i do the OBJ export, the idea is to make rhe process as simple as possible.

I really love the code base of avocado and appreciate how things are organised i would like to communicate with the dev/devs and maybe offer and also request help with this feature.

Imo this would make Avocado a very powerful alternative PSX emulator for hackers / devs who want to easily extract 3D game resources.

Nice work guys, look forward to hearing from you

LukeSchoen avatar Mar 22 '22 11:03 LukeSchoen

Hey, thanks for reaching out! We had another attempt of doing 3d dumps made by @rickomax (source is here https://github.com/JaCzekanski/Avocado/tree/feature/3d-screenshot and binaries can be found here: https://avocado-builds.czekanski.info/?branch=feature/3d-screenshot)

I never merged that feature into Avocado due to the massive amount of changes and hacks around the "psx core emulation". If your solution doesn't heavily modify the core code itself and doesn't impact performance when the feature is not used, then I'll be happy to review the code and merge it into develop.

JaCzekanski avatar Mar 22 '22 16:03 JaCzekanski

Please consider GLTF or DAE instead of OBJ! OBJ is arguably the easiest to parse but vertex color support is hit or miss.

vervalkon avatar Mar 22 '22 17:03 vervalkon

Oh boy! I'm quite excited to see this new 3D Export feature!

R7CrazyCanucks avatar Mar 23 '22 00:03 R7CrazyCanucks

Hi Jakub,

Thanks for responding!

The 3D screenshot technique in Rikomaxs branch works in a remarkably similar way to my technique (he also intercepts the verts passing thru the GTE rtps function) his code is great and has excellent support for texture and OBJ export but his 3D verts seems to be slightly confused: https://imgur.com/a/Gs5CUe1

My code is significantly simpler (just touching two files at the moment) but his branch has alot more options (like free camera control etc)

It seems to me that a hybrid of both of our model extraction branches would be the ultimate solution.

For the moment Ill keep developing both branches and ill try to merge them once I have a good handle on their exact implementation differences.

I like all his options but i agree his branch is painful to merge since it adds code everywhere, as for not modifying the core, i don't know if that's going to be possible (given the raw low level nature of the data extraction technique) but I'm sure we can use some c++ coding techniques (#ifdefs, name spaces or something along those lines) to keep the changes minimal and out of the way (performance impact on the unused path should be extremely minimal, but it may not be possible to make it exactly zero without some kind of self modifying code or a similar idea)

Again i really appreciate Avocado it's an awesome project and it makes hacking around in the PS1 super easy! I tried to push some branches this morning but it got stuck / hung on the push command, may i ask is this likely caused by a setting on my end ? or is there a protected group of contributors etc? please let me know the best way to push work for your review, thank you!

@vervalkon Thanks that's an important point! I'll keep that in mind, both DAE and GLTF should be easy enough to add! ill start with OBJ for its read-ability and simplicity but after im sure it all works well (its just textures need more attention right now) then ill include those format options.

LukeSchoen avatar Mar 23 '22 02:03 LukeSchoen

@LukeSchoen

For the moment Ill keep developing both branches and ill try to merge them once I have a good handle on their exact implementation differences. We don't have to do everything in one go, feel free to add the changes gradually. Starting with the export function is a good idea.

I tried to push some branches this morning but it got stuck / hung on the push command, may i ask is this likely caused by a setting on my end ? or is there a protected group of contributors etc? please let me know the best way to push work for your review, thank you!

You have to do it the "Github way" - that is fork the project, push the branch to your fork and open a Pull Request from there.

JaCzekanski avatar Mar 23 '22 11:03 JaCzekanski

Following this

paperjack93 avatar Mar 26 '22 08:03 paperjack93

I just had an Idea you might think about adding for the second release. The first release can be base functionality, then add this later, because I'm dying to try this new implementation ASAP lol. I noticed the 3D screenshot feature by rickomax doesn't work when emulation is paused. It seems to run in the same thread (is that the right term?) as the emulation itself and not in it's own sub routine. It would be super useful to have a way to advance frame by frame then 3D screenshot the frame you want while it's paused.

rubixcube6 avatar Mar 27 '22 16:03 rubixcube6

@LukeSchoen Could I be able to get my hands on this version of Avocado to test out how good it rips models?

R7CrazyCanucks avatar Apr 05 '22 14:04 R7CrazyCanucks

tested the rickomax branch and i did capture the scene just as it was displayed on the game and there was some depth but the 3d and textures were only displaying parts that were visible to the camera. @LukeSchoen will your version also display the hidden parts that the camera will not see ?

front_view

side_view

msmalik681 avatar Apr 07 '22 17:04 msmalik681

tested the rickomax branch and i did capture the scene just as it was displayed on the game and there was some depth but the 3d and textures were only displaying parts that were visible to the camera. @LukeSchoen will your version also display the hidden parts that the camera will not see ?

@LukeSchoen Could I be able to get my hands on this version of Avocado to test out how good it rips models?

I was informed through reddit that it turns out rickomax's build produces the same results if you use the right settings.

I believe this is what you get with the best settings. Looks like there's no way around manual work but I've come to expect that from ripping. Capture Capture2

alesan99 avatar Apr 23 '22 19:04 alesan99

@alesan99 What settings are the correct ones? I've been unable to get anything but flat, screen-projected vertices, most of the time textures aren't even saved, seems like it only works once then I have to restart the whole emulator to get another capture.

ryantrawick avatar Apr 26 '22 06:04 ryantrawick

@alesan99 What settings are the correct ones? I've been unable to get anything but flat, screen-projected vertices, most of the time textures aren't even saved, seems like it only works once then I have to restart the whole emulator to get another capture.

He didn't say, but these are what I used. Capture

I've really only messed around with one game though. You can try asking in the reddit thread linked above to see if the game you're trying doesn't work with the other implementation either .

alesan99 avatar Apr 27 '22 17:04 alesan99

Hey thanks for responding, i gave a detailed step by step on reddit yesterday you might want to check out.

Best luck

LukeSchoen avatar Apr 27 '22 21:04 LukeSchoen

Hello everyone. Thanks a lot for highlighting the topic. I noticed that when exporting a texture, the palette is not selected correctly. It may happen that the first part of the polygon is in one palette, and the second part is in another.

Oreguru avatar May 18 '22 12:05 Oreguru

Is there any way to get the assets on their t-pose?

MrTroodonTheOG avatar Jun 11 '22 04:06 MrTroodonTheOG

@MrTroodonTheOG Yeah sure is, I've been using mixamo.com.

Basically you upload your model and it will discover the hands / arms / feet / legs / heads etc etc and automatically rig your model (using some kind of machine learning / Mesh Processing AI)

Then you just download your model using any of their built-in animations and load it up in your favourite modeler.

Best part by far is the automatic vertex weighting which in amazingly effective!

The site suggests uploading your model already in a T pose but it actually works with almost anything human-like.

Be sure to post some screenshots if it works out for you, good stuff!

LukeSchoen avatar Jun 11 '22 09:06 LukeSchoen

Yeah that would be helpful, the main issue is the models aint exactly human like. Been extracting the assets of a couple of Jurassic Park games

MrTroodonTheOG avatar Jun 11 '22 19:06 MrTroodonTheOG

Ahh! that's an interesting one!

There is probably some advanced automatic technique possible where you give it lots of examples and it estimates the bones.

For now i suggest importing into blender, placing bones manually and posing it back to the default position for that dino.

Best regards, can't wait to see what your making :D

LukeSchoen avatar Jun 11 '22 23:06 LukeSchoen

Yeah I guess is what I can do, well anyways thanks for the help!

MrTroodonTheOG avatar Jun 12 '22 22:06 MrTroodonTheOG