So I’m coming up with ideas of how a character should be put together, and I hear that combining meshes is an important part of optimization. Effectively what I want to do is make a character who can have various clothing textures ‘painted’ onto his body (the popular spray-paint tuxedo…), as well as various clothing attachments that can go on as well.
I had written out a few ideas I had, but it got a bit too complicated for my feeble mortal brain-bran.
How should one go about this sort of setup? Layering the textures somehow? Using separate materials? Using one uber-shader material? And would any such method create complications in a texture atlas? I would likely want a texture atlas, considering how all the worn objects should probably be combed with the main character mesh as well…
Is all this even necessary, considering how I’m working with crazy-optimized character meshes?
Well, thanks for reading and considering this most abstract of queries. I hope someone has some suggestions.
Using one uber shader is a bad idea because it will tax the gpu. Batching only makes sense if you will see a lot of them on screen at the same time.
If its just one character you don’t need to optimise it at all. Batching and optimisation makes sense for loads of them on screen and visible… are you sure it is worth optimising at this stage in the project?
I want to optimize early on, because all characters and character-related things will use this same setup.
Perhaps I’ll do it this way… I’ll keep a list of all the character’s parts, and the textures on those parts. Each part will have a layered set of textures, which are also kept in a list. At run-time, I will make a new texture, which is a combination of all the other textures, and apply that single, combined texture onto my character.
Any additional parts will follow the same process. The parts’ materials will all be combined into a texture atlas, and then the meshes will be strung together.
Does that sound like a proper thing to do?
If so, that’ll mean I need to learn how to actually -create- new textures at run-time. It’ll also mean that the shaders for the characters’ bodies will be limited… I suppose such an obstacle is unavoidable.
From what little I have learned so far, I suspect I would first write a script that draws all my layered textures onto one new texture. Each layer would be drawn on top of the texture, until I’m left with one nice-and-neat texture for each mesh. (That is to say, one diffuse, and one normal texture.)
Then I would combine the meshes together with Mesh.CombineMeshes, and create a texture atlas, combining each attachment’s texture into one. (Not sure if that’s the right order, or if stringing the mesh comes last.)
Then I would apply the single diffuse texture and the single normal texture to the character’s now-single mesh.
For other non-character models, I’d probably do things a bit differently.