Export model and textures from CityGML to UE4 through Blender In Blender Render I'm facing a problem with imported CityGML building models. I used the Rotterdam dataset available online and used this very good script from batFINGER to import XML files in Blender. The models are already textured.



This just works very well, the thing is that the way it use textures is quite messed up, and I can't figure out how to export that properly with textures to a game engine such as UE4.

The model use a bunch of texture images (around 300) that are all listed here:



When I select only one building and check its UV's, it is all over the place and the UV's are overlapping each other. For some reasons this seems wrong to me, but in view mode the model looks fine. I feel like each building from the model is using textures from different pictures.



I used ctrl+J to join everything, but when I look at the UV's it's even worse:



If I zoom I can see every single UV crossing each other:



Baking the textures seems very promising, but after few try outs my model turns white and the final picture stay black:



*note that I've tried that without unwrapping because I think the model is already "unwrapped" and anytime I try to unwrap it again it crashes.

I've tried many options, without any success:


Unwrapping model causes crash
Packing islands causes crash
Baking the textures makes the final image black, or the model turns white
Auto unwrap from texture atlas causes crash
Exporting glTF doesn't export the textures embedded


Even if the UVs and textures looks messy the model is fine in the 3D view but there is no way I can export this properly with one single texture that I can use in my game engine.

The best would be to find a way to combine all theses different texture images into one single image witout losing the texture application, that I can easily import to UE4 (proper baking?).
Or find a way to export the model as it is in the view mode, with embedded textures, without modifying anything in the UV editor. I guess there must be a way...

Any help would be much appreciated!
Ok I finally figured out this issue. The problem was that I didn't had any material in the material tabs, so there was nothing to bake. I had to go through other programs to convert properly the cityGML files before to bake them in blender. I had to use Autodesk Infraworks and FME cityGML importer to get there. It works at least for me with the models I got from Rotterdam.

Here is my workflow:


Download the model from the website in cityGML format, thematic classes: buildings, textures: RhinoCity texturing.
FME quick translator: run CityGML to IMX workspace and convert it to a .imx file.
Open Infraworks and import the .imx file, then export it to FBX (uncheck merge textures toggle and do not export the ground).


Then in Blender I can open the FBX that contains the materials and textures ready for baking. Clear parents and keep transformations with alt+P, group meshes with ctrl+J. Create a new UV map, a new texture image, unwrap (smart UV project) and finally bake the textures.
Use the baked image as a new material, and the texture is mapped on the UV map created. I exported the file in FBX and the import in UE4 is very smooth. It looks great!

It works very well this way, hope that it can help someone else!