Learning how to fix model scale and UVs with little experience. -- Owen Meyers

     Through the course of working on the asset pipeline and animation manager, I've had to deal with a fair few broken models and assets that need to be updated for the system built. This has lead to a few headaches, as with the current system for the engine, everything is done through code and cannot be tested without significant time investment. As a result, I've had to get better at looking at a model's attributes and discerning if it will work or not in our engine. This has included (but is not limited to) checking the scale of the model, and a particular example of this is pretty egregious. A teddy bear model used by the team as a placeholder for the enemy model had a scale that was in meters, while the engine we built utilizes centimeters. As a result, the teddy bear, when translated into our engine, was incredibly massive. Now, if it was a static mesh, this wouldn't be much of an issue -- just manually scale all of the verts in the mesh and move on as though nothing happened. But this was a skinned mesh with multiple animations tied to it, and as a result, couldn't be easily scaled with that method. Another problem that needs to be resolved in another part of the asset pipeline is a set of static meshes. In a previous class, I came across a set of models that work very well for our game (they're a set of clean sci-fi models that are royalty free and already in the scale we need!). However, they aren't made with textures, instead with a set of materials that are simply manually colored in Maya. Solving this problem lead to an interesting proposition for the game itself that would allow for the art style to come into its own relatively easily.

        Let's start with the easy problem to resolve -- the static meshes with no UVs. To resolve that, our gameplay programmer made a texture that was simply a color palette for every model in the set of models we had. I then imported all of the .obj files into Maya and manually added UVs to this. I had to relearn Maya to do so, but in doing so, I was able to ensure that the models were in the proper scale for our engine and in the proper format (FBX in this case) when re-exporting them. The cool thing that this allows for is that by having the entirety of the texture contained as a color palette, 2 interesting opportunities are opened up. 1) Generating a specular map that is universal and matches the original specular component of the original model becomes trivial as it can simply be a grayscale version of the same color palette texture. 2) Changing the entire color scheme for the game can be done with a single operation. One idea that had been floating around since the beginning of development was having each floor be the same meshes but different colors, thus allowing for each floor to feel somewhat unique without having much effort needed. Having the color palette means that each floor will simply utilize a texture of the same dimensions and layout as the original, but will have different colors, giving each floor a unique color scheme without having to create totally unique models for each floor.

    Next, let's tackle the annoying problem -- the busted teddy bear model. I tried multiple solutions that each ultimately failed. First, I tried loading the model into Blender (also tried this same strategy in Maya to no avail) and scaling it before reexporting. At first, it seemed to work, however when loading it, I found that the model was the same scale as before, and a scaling matrix was saved into the file. Instead of loading said scaling matrix I tried multiplying everything in the file by a hardcoded scale factor when exporting it from my tool. That caused incredibly broken results. Finally, after much head scratching and work with the team's mentor, I came up with the obvious solution that I didn't think of for a while -- add a scaling matrix to each entity and leave the original model unaltered. This worked perfectly, as now each enemy was able to have a different scale for the same model to differentiate each other, *and* the model was no longer around 1000x larger than it was supposed to be.

This is the color palette utilized for each model


A floor tile model that has been textured utilizing the above color palette. Notice the lack of specular reflection, as this model doesn't have specular built into it.



A few of the enemy teddy bear models. Notice the slight difference in sizes. Also notice that they aren't currently 1000 foot tall goliaths.

Comments

Popular posts from this blog

Adding assets to every enemy -- Owen Meyers

Sphere to AABB collision