gdkchan / SPICA

Experimental H3D tool
The Unlicense
95 stars 46 forks source link

ORAS Modding #41

Open ILoveToDie opened 6 years ago

ILoveToDie commented 6 years ago

I'm trying to use a model I've exported as BCH as a battle background, but every time the game tries to load the edited Battle Background it either soft locks or crashes. I've compressed and repacked everything correctly.

Any ideas why? Original and Edited files https://mega.nz/#!F9gEXLTS!HnKj-06xEE2AWNdcsJW7nSUHnx8Luj4Juz3XwZXpMnA

ILoveToDie commented 6 years ago

So, I think I found out why, It's seems it looks for a specific name, as when I replaced the first route's battle background with it, it would softlock, but now after changing the name of the model inside the BCH from "Model" to "btl_G" it doesn't softlock the game anymore and the battle plays out without the ground, but still won't load the model. The name is limited to the amount of characters in "Model" would it be possible to make it so we can rename the model to something longer? as it seems going past 5 characters breaks the BCH.

Edit: Edited the source to change the name of an imported SMD, looks like it's some other issue. Odd that changing the name stopped it from soft locking tho.

gdkchan commented 6 years ago

well, if the original model name was "btl_G", its possible that the game is looking for this specific name and will hang with anything else. One of the complications of writing a generic bch creator, is that games will expect specific version of the format, specific names, specific shader references and meta data values, and crash if they are different/not present.

About the model not showing up -- its possible that it uses a specific bone node on the model to place it at the correct position (assuming this model has any bone to begin with -- since it's a background model is pretty likely that it doesn't).

ILoveToDie commented 6 years ago

Ah, I see, also It seems it just doesn't work with anything that's packed inside a mini-pack, I tried to replace a secret base object and had the same issues. And I've made sure to give the model the same bone. vertex group, mesh name, and origin as the model I was replacing.

ILoveToDie commented 6 years ago

I got the secret base object to work https://i.imgur.com/palbC5V.png I suspect it's either the encoding the textures were in "RGBA8" and now it's in "ETC1" I had to use Ohana3ds Rebirth to replace the texture of the other model so it would be the correct encoding which also meant I had to downscale them so they wouldn't break, It seems they just need to be around the same file-size as the model they're replacing the chikorita doll is 40KB, and the amiibo I replaced it with is 51KB, when I tried none downscaled textures converted to etc1 it was at 91KB and froze when trying to load it.

gdkchan commented 6 years ago

I dont remember Ohana3ds Rebirth supporting writing etc1/a4 textures, I think you meant some other version? Could you elaborate more on the steps you used to create the working model? As far I understood, you converted some model (a *.obj model I guess) to bch using SPICA, then used Ohana3DS to replace the texture with a etc1 texture, is this correct?

Do you know if it works correctly with non packed models (not inside those "mini packs")? It's possible that the problem is related to the model size but I find this possibility unlikely. I remember having problems with etc1 textures before (on ssb models), but it didn't made the game crash.

ILoveToDie commented 6 years ago

It does work with non packed models, and you don't need to convert the texture to the same same format RGBA8 is fine, you also don't have to change the name of the model, and from what I can tell it doesn't need to be a similar file size, as one of the mods I made is 27 KB, and another is 831 KB. This seems to apply to any non packed models as well, as I was able to replace the "Choose Your Starter" Background with the model I was trying to replace the battle background with. https://imgur.com/a/DMIkr I was also able to replace the pokeball with a wii u model, It only worked in the "Choose Your Starter" scene but it froze when trying to load in-battle(https://cdn.discordapp.com/attachments/287988332145934346/390400727778066432/IMG_20171213_020814.jpg) this model is rigged with a mouth, so it I exported it SMD to see if it would actually open and close in-game with the rig edits below, so I replaced it with an OBJ exported Torchic instead https://media.discordapp.net/attachments/189804994210430976/391278161234624512/top_0007.png

I took both the Chikorita Doll Model and the Mario amiibo into Blender, Scaled the amiibo to roughly the same size as the doll, gave it the same origin laying down instead of the usual standing up and parented the amiibo mesh to the doll's armature, renamed the mesh, and changed the vertex group of the amiibo to the same as the doll, and exported SMD. And I used Ohana's BCH Texture Replacer tool to get the textures converted to ETC1 by replacing the doll's textures, then used SPICA to export those textures to a GFTexture and hex edited the texture name with the same name as the material in the SMD, Edited SPICA's source to change the SMD model name to the doll's internal name, imported them all, and finally exported BCH.

gdkchan commented 6 years ago

Ok, thanks for the explanation. I think the easiest fix here is supporting the etc1/a texture formats, and adding dialogs allowing the user to select the desired texture format when the user open a file with a non encoded texture (formats like obj and smd), and also when a png texture is imported.

We also need to remove the hardcoded the "Model" name on SMD, I think that using the file name instead will be good enough.

KekMcGee commented 6 years ago

Sounds good, but would it be easier to just add support for importing raw versions of these special formats? I found a tool to convert them to raw 3DS texture formats https://github.com/Cruel/3dstex

Great job figuring this out btw.

ILoveToDie commented 6 years ago

@KekMcGee I wouldn't know

For those who want to know, after a Haitus from modding, I've discovered it's just as easy to replace Battle Effect models as it is full trainer models. https://imgur.com/a/ycLfo the one limitation I've noticed so far is any texture can't be exactly or over 1024x1024. 512x512 seems to work perfectly fine.

ILoveToDie commented 6 years ago

@gdkchan I was messing around with some of the options for texturecoords/filters(which aren't accessible unless you edit the source code to those who aren't sure what I'm talking about), and poking around in the hex after to see what changed, and it seems there is a mag filter missing whatever hex "00" is called, the Pokemon games use this to give the texture a pixelated appearance, I can't find where to change this to make the BCH exporter use this filter. The majority of the XY/ORAS models use 02 02 00 02. https://imgur.com/a/W8rD1 example with one of my mod characters.

gdkchan commented 6 years ago

This is Nearest Neighbor filtering. Called Nearest inside H3DTextureMagFilter and NearestMipmapNearest on H3DTextureMinFilter.

ILoveToDie commented 6 years ago

I guess my visual studio isn't compiling my changes, as I've tried that and it still exported the same.

Also want to let you know that these BCH's also work with Moco Moco Friends which uses backward 22 forward 22. https://gamebanana.com/games/6334

Still can't get these to work with games that use 22 23 however.