Syomus / ProceduralToolkit

Procedural generation library for Unity
https://assetstore.unity.com/packages/tools/utilities/procedural-toolkit-16508
MIT License
2.62k stars 227 forks source link

MeshDraft Mesh Constructor #75

Closed iDevelopThings closed 7 months ago

iDevelopThings commented 1 year ago

Hey, first of all, thanks for the great toolkit!

I was looking around and I cannot find much information on this;

I was playing with the building generator, and was curious if I would be able to essentially use predefined meshes(models), from looking at the code it looks like it's possible to create a new instance of MeshDraft with the supplied mesh, but then I get these two errors: image

Mainly I'm trying to figure out if I can use a combo of custom building "segments"(made in Blender for ex) and the Polygon assets to construct buildings. I really like the system you made, it will work great for the problem I'm trying to solve... if I can figure out this one issue :D

To test it, I just replaced the calls to ProceduralFacadeElement.Wall with this: image

Is this supported or am I just missing something simple?

Thanks

BasmanovDaniil commented 1 year ago

Hello @iDevelopThings! The issue's most likely cause is that you are trying to combine procedural and hand-made segments in a single mesh. Procedural segments do not have uvs or tangents, while it seems like yours do have them. When meshes with and without uvs are combined, Unity outputs the errors like the ones you are seeing.

There are several solutions to this issue:

  1. Remove all uvs and tangents. You can do it either in the source meshes or in the combined mesh draft right before it is converted to mesh. This will normalize available channels across all meshes, but you will lose your uv-mapping, obviously.
  2. Use a separate mesh and renderer for uv-mapped segments like it is done for roofs. You will need to juggle two collections of segments in your code, but you will be able to have both hand-made uvs and procedural segments.
  3. Add uv/tangent channels to procedural segments. They can either be filled with zeros, or you can code actual uv-maps for all segments. That will also resolve the conflict between channels.