3
\$\begingroup\$

I've created a model in MagicaVoxel (A) and I want to use it in Godot. I imported the model into Blender, but then realized that it's using a very high polygon count for such a simple model. I found that using MagicaVoxel's OBJ export yields interesting results in that voxels of the same colour share polygons (B), but when many different coloured voxels are next to each other, it still creates a high polygon count.

voxel polygon count

Ideally, I'd like to have a model that is the lowest polygon count possible (C) with an accurate texture map to mimic the voxel colours. Is there an existing tool to achieve this? I really like how MagicaVoxel works and I'm not interested in using Blender to model or manually texture the mesh, but maybe there's a plugin for Blender? I'm open to suggestions.

As a side note, it's possible that I could just use the OBJ file as is, but I wonder about performance. Mesh B has 216 polygons, while mesh C uses 140. This is just one asset in a medieval adventure game and I'd like to have a very cluttered world. ;-)

Edit For clarification: MagicaVoxel exports an OBJ file with accurate texture mapping, but isolates different colours of voxels to their own polygons, creating more polygons than are required. Mesh B is the result (I imagine this removes the need for any anisotropic filtering). Mesh C was also exported from MagicaVoxel, but with the colour information removed. Thus, without the desired material information. I just wanted to avoid any confusion with what MagicaVoxel can do on it's own. Maybe there's a solution within MagicaVoxel that I'm not aware of?


Update: I believe Blender can do what I need, but it's going to require a lot more research to get it right. I was able to get a texture map to bake by diffusing colour with some success (some faces got the wrong colour, see the yellow near the bottom of the blade), but I couldn't quite figure out how to do it with vertex colour emissions to see if the result would be better. Then (as you can see in the sword handle) I need to setup up a pixel perfect UV and texture map, prior to baking. I'm kind of leaning away from doing it manually in Blender, to be honest. I may have to do this for a thousand or more models, and every time a model is edited.

blender baking attempt

I'm going to let this question sit for now in the hope that there's an easier solution. Maybe a script exists to do this? Maybe I should learn how to write my own? In the meantime, I can still proceed with the higher polygon counts in the OBJ exports from MagicaVoxel. The neat thing about the native MagicaVoxel OBJ exports is that the texture map is a simple 1px tall by 256px wide palette PNG file (every colour is a single square pixel) that all meshes can share. Everything can use the same texture file. Maybe that offsets the higher polygon count performance hit? Anyway, I'm taking a break from Blender. ;-)

\$\endgroup\$
7
  • 1
    \$\begingroup\$ I have a couple search results: 1. Bake vertex colors to texture from mesh. 2. Converting Vertex Color to a Texture With Blender. \$\endgroup\$
    – Theraot
    Jul 15, 2021 at 15:45
  • \$\begingroup\$ @Theraot : I'm not very familiar with Blender, but I'm not sure those 2 links do what I need them to do. If we back up a bit, I can bring in a PLY file into Blender where every voxel is a coloured cube. How do those two links allow me to simplify (combine and reconfigure) the geometry and still recognize the placement of colours based on the voxel information (the cubes that have been eliminated) to generate the appropriate UV and texture maps? \$\endgroup\$
    – HAL 9000
    Jul 15, 2021 at 19:21
  • 1
    \$\begingroup\$ Blender isn't my area of expertise either. However, I think remeshing would do, hopefully? - Something else that I have seen that comes to mind is this: Easily Clean Your 3D Scans (blender), I know it is not a 3D scan, but I believe the same approach could be useful, in particular the unwrap and bake textures part. Anyway, look, the site of the first link I gave you in the prior comment is a sister site dedicated to blender, if you want to make sure somebody who knows blender looks at your question, I suggest you ask there. \$\endgroup\$
    – Theraot
    Jul 15, 2021 at 19:35
  • \$\begingroup\$ @Theraot : I feel like a dolt. I was not familiar with the term "bake", but that would technically do what I'm trying to accomplish. I should be able to use the OBJ mesh B file for reference (with its accurate texture) and lay the mesh C geometry on top and bake it in. I'm trying with all my might NOT to learn Blender though. That software is a beast. ;-) I'll give it a shot and report my findings later. \$\endgroup\$
    – HAL 9000
    Jul 15, 2021 at 20:13
  • \$\begingroup\$ @HAL9000 : it takes a while to learn, yes, but it's fun and really worth knowing. There is a ton of stuff you can do with that program. Good luck on your project. \$\endgroup\$
    – Millard
    Jul 16, 2021 at 15:14

1 Answer 1

1
\$\begingroup\$

There exists an addon on the asset store that can import .vox files directly, no exporting needed: https://godotengine.org/asset-library/asset/162

Regarding the high poly count, I'd say that you can always optimize later if it becomes an issue.

\$\endgroup\$
1
  • \$\begingroup\$ Unfortunately, that does not answer my question. I currently use Blender to export the OBJ (216 polygons) as a glTF and it works with Godot just fine. Bringing the VOX file directly into Godot makes a mesh with 560 polygons (each voxel having its own geometry); the exact opposite of what I'm trying to achieve. I'm just trying to find a way to use the mesh with 140 polygons (diagram C) with an accurate texture map. That is the result I'm seeking. \$\endgroup\$
    – HAL 9000
    Jul 19, 2021 at 4:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .