News:

Welcome to World of Banished!

Main Menu

Looking for detailed info on adding citizen textures (long post)

Started by Verteiron, December 08, 2014, 08:39:59 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Verteiron

My Diversity mod changes the skin color of Citizens. It has some limitations, though, and I'd like to overcome them.

Ideally I'd like to have the Citizens pass their skin color to their children. Unfortunately, there doesn't seem to be a way to influence newly-created citizens, so I'd be happy with citizens having with a random skin color and keeping it through their lifespan.

Citizens are (randomly?) assigned one of 8 textures present in in either MaleCitizen.png or FemaleCitizen.png. This includes both skin and clothing, so if I just included different skin tones in that file, each race would always be wearing the same set of clothes. I need to find some way to get citizens using more than 8 textures, but this is turning out to be way harder than I imagined.

Citizens (and Nomads) use OpaqueCharacterMaterial.rsc to assign their textures, and they are the only models that do so. OpaqueCharacterMaterial extends the VertexProgram vs from OpaqueSkinMaterial.rsc with the following line:

outputTexcoord.x = (outputTexcoord.x + localToWorld[3][3]) / 8.0;

This is what divides the texture into 8 parts. If I double the width of (Fe)MaleCitizen.png, add 8 more textures to it, and increase this divisor to 16.0, the textures get applied properly, but only up to 8. Anything right of the halfway mark is completely ignored.  >:(

Since the "only use up to 8 textures" behavior seems immutable, I've tried any number of other increasingly desperate methods to get around it, all to no avail. These include:


  • Trying to turn the MaterialInstance for Citizens into an an array - This got the game to compile and place the additional texture files into the bin directory, but it would only use the first one in the array for citizens.
  • Adding a "Skins" entry to the CitizenMesh.rsc file - Again, the game compiled all the PNG files referenced, but only used the default filename. I'm guessing this is because the game engine doesn't expect skins for the Citizen mesh and so never calls for them.
  • Adding multiple GraphicMesh entries in Template/Citizen.rsc, similar to building with multiple models - This seems to do nothing. Only the first mesh gets used. Even if it were working, the texture is set in the FBX file, which of course isn't available.

I'm on the verge of giving up on this idea, really, but I want to make sure this is really as hard as it seems. I need to be able to do any one of the following:

  • Override the texture resource used by the Citizen.fbx mesh using an entry in a .rsc file.
  • Generate an arbitrary random number in a .rsc file, so I can use it as a switch or multiplier for the x offset in OpaqueCharacterMaterial.
  • Find another way to get OpaqueCharacterMaterial to randomly pick a texture.
  • Separate clothing and face textures into multiple files (easy) and get the game to apply one of each to each Citizen (apparently impossible).
  • Get a copy of Citizen.fbx.

If anyone can help me with any of this, or come up with some more creative (or simpler!) method of accomplishing this, please let me know, as this has been driving me mad for days!

ps - While I'm at it, I'd also like to know if it's possible to store arbitrary data (like, say, a race or skin color flag) in a Citizen. Oh, and a pony.

Verteiron

Just to save everyone else the headache: I actually got a response from the dev about this. He says that the game is hardcoded to only use 8 textures, so I guess that's pretty much that.

I thought I was making some headway by introducing random selections into the programmable shader, but I can still not get more than 8 total, so... guess I'll just release a version of Diversity with everyone's clothes and skin color-coded.