I would appreciate to hear your opinion on how you would solve the following problem in the most efficient way, maybe someone here had some experience with something similar.
So the situation is like this: I have a classic jigsaw puzzle board made of many puzzle pieces. Each piece is a textured 3D model, if you put all of them together they form some 2D image. There is a fixed number of possible variations of pieces, so I can reuse the meshes for several pieces. The number of pieces may be very large, hopefully 1000-2000 if it is feasible.
I could do all this in 2D with sprites, but this is exactly the point - I want to try and make all the pieces real 3D models that look like they are made of cardboard, with some volume, reflections, maybe bump mapping if performance allows it.
One way to implement this is by assigning a separate material to each piece. All the materials will have the same texture, but different offset, so each piece shows a part of picture and together they form one big picture. Obviously this creates a performance problem, since as I said there could be many puzzle pieces, so we have really many materials.
Second way is to use UV mapping. Now all the pieces will have one shared material, but each piece will have a separate clone of mesh, each with different UV mapping. This way I am using only one material, but now it creates huge duplication of geometry - I cannot share the meshes between puzzle pieces, instead I have to hold a clone of a mesh for each piece with only one difference - UV mapping.
So what do you think would be the best solution for maximum performance? Maybe there is a third way that I don’t see? Maybe it is possible to duplicate just the UV mapping for each mesh, and not the whole mesh in some way that I don’t know?
The problem could be solved if I could pass somehow to the shader information of which piece it is currently rendering, but that seems to be possible only via either materials or geometry, same as I described above.
Please share your opinion, thank you.