Greythorne color

Controls

10150

Dafuq is this?

A Greythorne model viewer. Greythornes are the cute mascot animals in the old Gamecube JRPG Baten Kaitos: but the game is pretty low-res and the things tiny on-screen, so here they are in full high-res glory. Will likely be used for plush-making shenanigans.

Might evolve into a full-blown picture maker if I find the time. Will get animations added if I manage to reverse-engineer the game's file formats.

How does it work?

I ran the game on emulator and extracted the relevant data: see the next section for excruciating technical details. This page uses a framework called ThreeJS, which makes it really easy to make 3D scenes in a webpage. All the Javascript is directly readable in this page's source code if you're curious.

The 3D model and textures are in the resources subfolder, if you want to yank that out and use them elsewhere. You need the OBJ file, the MTL file, and the textures. There's also an OBJ 3D model without textures.

Where does the data come from?

I run the game in the Dolphin emulator, which lets me attach a graphics debugger called RenderDoc to it. That, in turn, lets me see all the data that the graphics card receives and how it uses it.

Due to how Dolphin works, the 3D model data that is visible in RenderDoc already has the animations applied. So to get a good Greythorne model, I had to find one that wasn't jumping around too much, and catch it at the right moment. That let me export the data directly from RenderDoc, as a bunch of CSV files. Specifically, I exported the vertex shader input data, meaning the 3D positions before they get projected onto the screen, along with the texture coordinates and the normals (for lighting).

Greythornes are rendered in four parts: the body, the arms, the claws and the eyes. I took those four CSV files and wrote a horrible ad-hoc converter to turn them into an OBJ file. The OBJ file format is an ancient standard for 3D models that is simple and human-readable, meaning I could easily check if things looked correct.

For my fellow graphics coders: the meshes are originally rendered as triangle strips using primitive restart, and the winding order seems to be the opposite of what's typically expected. OBJ wants triangles, so the trickier part of conversion was outputting the right indices and flipping winding order until things looked right. Plus I initially tried to process vertices in batches of 4 and that didn't play nice with primitive restart.

Next were the textures. Dolphin has a built-in texture dumping functionality: you can find information about that by looking for tutorials about making HD texture packs. Thanks to RenderDoc I already knew what the textures looked like, and what to look for among the hundreds of dumped images. So it was only a matter of turning the option on (under Graphics > Advanced) and running around looking at Greythornes. That puts all the textures in a folder under the Dolphin installation. I found 8 color variations, there might be more.

Connecting the textures to the OBJ 3D model is done through a material definition in a MTL file. Each material has a bunch of numbers describing how the surface reacts to light, and optional textures. In this case, there's one material per Greythorne part and per color, resulting in 24+1 materials total. The claws material is shared by all color variations.

Finally, the textures needed to be flipped vertically for some reason.

All that to say: none of this is magic, a lot of it was trial and error, and you could do it too with some graphics programming knowledge ;)

Licencing info

See page source for details. The informal version is that you can do whatever with the code but need to make your modified version available in some way. The textures and 3D models are not licenced under those same terms since they're ripped from the game, duh.