RosaryMala / armok-vision

A 3d realtime visualizer for Dwarf Fortress
MIT License
321 stars 27 forks source link

Secrets of the Beehive #41

Open clickworkorange opened 7 years ago

clickworkorange commented 7 years ago

I've made a beehive for Armok, single mesh, 470 tris, 261 verts - could this be a suitable object for inclusion?

beehive_mapped

If so, can you explain how texturing works in Armok - I expect the texture changes depending on the material the item is made from? Does that mean the object only has a single texture, or can this somehow be specified in the UV/other maps?

RosaryMala commented 7 years ago

It looks good!

Regarding textures, refer to the wiki here: https://github.com/JapaMala/armok-vision/wiki/MeshContent

TLDR: if you want something parts to have their own texture, while other parts to have the material texture, they need to be separate objects within the same obj file.

What program did you use?

clickworkorange commented 7 years ago

Thanks! I'm not sure I understand the texturing instructions, feel like I'm diving in at the deep end here. Would you care to give me a sample XML snippet for the beehive obj, where only the main body ("hive") inherits the material's texture, and the other three meshes ("roof", "handles", "stand") have their own textures?

I would also appreciate your thoughts wrt scale, alignment, mesh complexity and general style - anything I should be doing differently? If you're happy with it I'll give "nest box" a stab...

clickworkorange commented 7 years ago

I've made a nest box as well, in the same scale as the beehive, 448 tris, 244 verts.

nestbox_mapped

The software used is Blender.

clickworkorange commented 7 years ago

Archery target, 424 tris, 220 verts.

archery_target_mapped

RosaryMala commented 7 years ago

Regarding scale, import some of the models that come with Armok Vision and see how they look together. Particularly the wall and floor models.

The best sample to look at is the bed model and textures. It uses all available texture maps, so if you import that model, you can see how it should look.

All the building files are under Armok Vision_Data/StreamingAssets/BuildingMeshes

clickworkorange commented 7 years ago

Thanks, I've been using FLOOR.obj in TileMeshes as a guide, thinking that e.g. a bed would take up nearly the full width/length? I don't actually have Amrok Vision installed yet!

RosaryMala commented 7 years ago

Correct.

Regarding complexity, there's a hard vertex limit, where every 16x16 block of tiles cannot have more than an average of 255 vertices each.

clickworkorange commented 7 years ago

Ok, so I'm pushing it a little then; the nest box for example has 244 verts. I gather the 255 average includes floor/wall meshes? Anything else?

RosaryMala commented 7 years ago

If you open the bed model at https://github.com/JapaMala/armok-vision/blob/master/Assets/StreamingAssets/BuildingMeshes/Bed_Sheet.obj you can see how different parts of the buildings work.

RosaryMala commented 7 years ago

It's 255 including floor, but opaque, transparent, and cutout geometry is each counted separately

clickworkorange commented 7 years ago

I think I'm getting the hang of this. I combine the meshes in Blender based on what type of material they will be using, e.g. BuildingMaterial and NoMaterialBuilding, so I have only one mesh per type. In the nest box example above, the main body of the coop is a mesh named BuildingMaterial, the roof, the door frame and door latch are in a single mesh called NoMaterialBuilding, while all the netting is a mesh called NoMaterialBuildingCutout. But here I'm stuck again - how do I unwrap these three meshes into a single UV map? Or can I have different UVs for each mesh in one .obj? Looking at your Bed_Sheets example, I can see that some maps only affect the sheet (NoMaterialBuilding), while others only affect the bed frame (BuildingMaterial) - but if I try to unwrap the three meshes for the nest box I end up with three sets of UV coordinates and I can see no obvious way to combine them.

Edit: Maybe the way to do this is to delete my existing UVs, combine the three meshes into one, unwrap it, and then split things back into three meshes? I'm assuming here that a mesh will keep its UV coordinates when separating it.

RosaryMala commented 7 years ago

What I would do is combine them all into a single object, then do the UV mapping, normal/ao baking, etc, and only split them into separate object when you're finally exporting to Armok Vision, since they all share the same UV space, more or less.

If you're not using baked AO and normal maps, then you can get away with having a separate UV map for meshes that take the material texture, and meshes that use their own.

clickworkorange commented 7 years ago

Thanks, that all makes perfect sense now :) It felt a bit ridiculous squeezing this much detail onto 256x256 maps, even though I only included faces which need some texturing, and stacked most islands which share appearance:

nestbox_pnestbox_nnestbox_anestbox_s

But it does work, and provided you don't look too closely it doesn't look too bad. I also managed to get the vertex count down to 182, which is hopefully efficient enough?

nestbox_final

I will create the XML and send you a pull request for the finished item - unless you can see something I need to change?

RosaryMala commented 7 years ago

I'm re-opening this issue, because the way buildings are done has changed, and this is relevant.

Buildings are now made using the unity editor, as prefabs, and don't have any of the limits that were there before. The only requirement is using a custom shader for parts that should get the material from DF.