Baking mesh wireframe to texture

I’m trying to bake a texture of the mesh lines for use in Unity.
Approaches that don’t quite work for me:

  • Exporting UV layout: no control of line thickness. Requires additional Photoshop work.

  • Wireframe shader node: triangulates the quads, which ends up looking messy.

  • This approach (bevel with separate material): Works well in many cases, except for flat surfaces, as they don’t get beveled.

Any other methods?

Have you tried the wireframe modifier? It makes a polygonal wireframe with a thickness that can be adjusted.

2 Likes

Based on that method, a little Geometry Node solution maybe? (it’s not exactly refined though)

1 Like

Thanks a lot for the suggestions!
I tried both methods, but get some issues with both approaches. Maybe there are ways around it that I’m not able to figure out.

The wireframe modifier looks promising, but the baked texture (using “selected to active”) becomes uneven.

This comes close, but similar to the other method, the lines get uneven thicknesses. Below is a subdivided plane for illustration. I’m not good enough at Geometry Nodes to figure out how to solve it.

Yeah, this is where the “unrefined” part comes in :sweat_smile: It would work on something like Suzanne, but it’s not precise and breaks under scrutiny :person_shrugging:

Would it still be uneven if you increase image resolution? Some kind of precision error perhaps?

Increasing resolution to 4k didn’t help.
I also tried different UV unwraps. The default unwrap of a torus gets pinched in the middle, so I thought/hoped that was causing the issue. So I used “follow active quads” (as shown in my previous post), but the baking was still irregular.

That’s weird, I just tried it with the wireframe modifier and I didn’t get this uneven result.

Does the mesh produced by the wireframe modifier look like this too? Are there other modifiers that are still present but disabled in the viewport (they would be visible in a bake)?

I got it to work easily by applying the wireframe modifier and baking everything using pure, modifier-less geometry.

So when baking with the Wireframe modifier method, I used “Selected To Active” and didn’t apply the modifier, because when I applied the modifier it deleted my UV. And unwrapping the new mesh creates a mismatch of UVs with my original model.

I just tried it again and got the same result.

Are you saying that your UVs still matched up after applying?

When doing selected to active, I used 2 meshes.

  • The first contains the original object with the wireframe applied to it.
  • The second, which receives the bake, is a copy without the wireframe.

I then add a little bit of the bake’s extrusion setting to make sure the bake catches the extra geometry from the wireframe.

2 Likes

Ah of course. Works fine now! =) Thanks!

1 Like