3
$\begingroup$

I want a texture to have the outlines of the mesh (not using the "Export Layout" feature in the UV editor). The outlines must be in the texture only (maintaining the the Original mesh).

enter image description here

In the picture above I duplicated the model and applied the "Wireframe" modifier to the duplicate. Now I'm trying to bake the "Shadows" of the Wireframe mesh into the original's texture, but I couldn't make it work (I'm very new to blender).

How can I achieve this (using this or any other method)?

P.S. I'm aware of the "Freestyle" feature, but it can't be baked into the texture (to my knowledge).

$\endgroup$
2
$\begingroup$

The basic idea for generating outline effect comes from Cycles Wireframe Shader from agus at BlendSwap.

General Step:

  1. Create a UV layer (which is used for generating "procedural" wires), then unwrap the mesh by the "Reset" method in U menu.
  2. Create another UV layer (used for baking), which should contain the expected UV.
  3. Create an Image Texture node and keep it disconnected to any socket. then bake Diffuse color onto the target image.

enter image description here

NOTE: Before baking, make sure the target UV layer is activated.

More guidelines about baking.


EDIT:

There should be more than one way to do so. Another way is to use Texture Paint mode to paint it manually: Select all Faces then hit I twice to Inset individual faces, then invert selection for masking in paint mode. It does work, but you can hardly get smooth result in this way.

A third way is using Export UV Layout. Though you've mentioned that "Export UV Layout" should not be an option here, I still recommend you to try Paul Gonet's solution again. Just plus one more tip —— use Dilate/Erode node to get proper outline width. Then you can use File Output node to output the outlined texture while rendering again. Finally you can reuse it back to the model.

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ Can you elaborate how this shader works? Because that link is behind a registration wall. Its not a best practice as an answer $\endgroup$ – AdamTM May 4 '16 at 10:27
  • $\begingroup$ @AdamTM Oh, the link is just showing respect to the agus, from whom I get this idea. :) You can check my attached file. The idea is not so hard to understand, but will need quite a few words to explain. I recommend enabling the Node Wrangler addon to see what's going on on each output socket. $\endgroup$ – Leon Cheung May 4 '16 at 14:39
  • $\begingroup$ This is nice but the line thickness of the wire frame is dependent on the polygon size. That is a big downside. Because of this I have to give the upvote to PaulGonet. $\endgroup$ – Jaroslav Jerryno Novotny May 4 '16 at 15:06
  • $\begingroup$ @Jerryno Yes, since the OP did mention a few not-usings. That's why I updated with two more options. $\endgroup$ – Leon Cheung May 4 '16 at 15:07
2
$\begingroup$

You may create this kind of texture using Export UV Layout option. enter image description here

Mark seams on your mesh and unwrap it (U). enter image description here

In UV Editor go to UV's-->Export UV Layout and set the resolution as you like. Rmember to set the Fill Opacity factor to 0.00.
enter image description here enter image description here

Now you may prepare the wireframe texture in GIMP or PHOTOSHOP, but I'll show you how to do it entirely in Blender. Go to Compositing Nodes in UV Editor window and set the nodes as pictured below (add an Image node, upload the newly exported UV Layout and use Alpha Over node to invert the colors).
enter image description here

Now render the image. Set the render resolution to the same resolution as your exported UV Layout was. After that save the image. enter image description here

Enable Shader/Material nodes and set them up as pictured below, to use the newly created texture. In Compositing Nodes reset them to their original arrangement and render again. enter image description here enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ I don't know how it happened, but I've overlooked the line where you say you don't want to use the Export UV Layout option. Although I won't delete my answer as it could be useful for those, who don't know how to do it. $\endgroup$ – Paul Gonet May 2 '16 at 14:02
  • $\begingroup$ This answer deserves my vote. Please consider to update with the tip in my updated answer, to make this solution more useful. :) $\endgroup$ – Leon Cheung May 4 '16 at 14:32
0
$\begingroup$

Use the wireframe node:

enter image description here

For non-shaded lines/color use the emission node instead of diffuse

| improve this answer | |
$\endgroup$
  • $\begingroup$ This method "triangulates" the mesh, which is not what I want. I could erase the extra lines in a image editor, but since there are several models I want a "better way" to do it. $\endgroup$ – Cássio Eudardo May 2 '16 at 13:07
  • $\begingroup$ Ok so just bake the wireframe material into the underlaying mesh in cycles. What you need to do: -Set up your wire material to complete black. -Your underlying mesh material needs to be diffuse white. Add an image texture node - but do not connect it to anything -In the UV editor create a new texture, use a high resolution, like 4k -select that texture in your underlying materials image texture node -go to render settings > bake $\endgroup$ – AdamTM May 2 '16 at 13:38
0
$\begingroup$

You are right in starting with a duplicate object with a Wireframe Modifier on it.

Baking emission in Cycles is one way, although areas with dense geometry may emit more light than you want and actually cause a glow effect like a gradient instead of a solid boundary.

You could also do this with Dynamic Paint and use the wireframe object as the "brush" and textured mesh as the "canvas". Works well, and this is documented in many places (including the Blender Manual and questions on this site).

There's another interesting method that's easy to learn, although not as obvious...

Vertex Paint + Bake Vertex Colors

Here's a cube with a Wireframe Modifier on it. Its vertices have been painted:

ecube with a Wireframe Modifier on it and vertices painted

In case you've never experimented with this before, it's done in Vertex Paint Mode.

Selecting Vertex Paint Mode

You can paint all vertices a single color like white, or in multiple colors as I have done in this example. You can also bake onto any color - in this example the starting texture was solid black.

Here's a UV-unwrapped cube of the same size. Its texture was created by baking the vertex colors of the wireframe cube above:

A cube with a texture made by baking the vertex colors of the wireframe cube

These two objects occupy the same location and overlap each other, but the screen shots were taken with only one at a time visible for the sake of showing each by itself.

This bake was done in Blender Internal with the Bake Mode set to Vertex Colors, and the 'Selected to Active' option enabled so that when you first select the wireframe object and then Shift-select the bake target object the color data gets transferred from the vertex colors of the former to the texture of the latter.

Blender Internal bake settings - Vertex Colors, Selected to Active

| improve this answer | |
$\endgroup$
  • $\begingroup$ This works fine for a cube, but for any other shape it does not work. The lines "ignores" the mesh and draws on the other side. $\endgroup$ – Cássio Eudardo May 2 '16 at 15:20
  • $\begingroup$ Oops! Sorry I didn't catch this. You're right. Thank you for the correction! Seems there are some complications with the Distance and Bias settings. I suppose it's grabbing color data from geometry that it shouldn't (because it's too far away), as well as ignoring some color data from geometry that it shouldn't (because it's too close). $\endgroup$ – Mentalist May 2 '16 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.