Sunday, July 6, 2008

Compositing a wireframe overlay onto your render.

One feature I'm waiting for is a decent wireframe overlay (or solid wireframe) for materials. So far the only decent method has been to duplicate the object and give it a 'Wire' material and fiddle with the Zoffset. Even then you'd get some iffy results; either the back would show though around the edges or there would be Z fighting. Or both.

I was thinking the material nodes held answers, but the Wire button is a global material option, and effects all materials attached to the node.

But wait, Blender DOES have a wireframe overlay. For the 3D viewport, however. If you goto the Objects buttons and look under the 'Draw Extra' section you'll see a little button labeled 'wire'. This does, in the 3D viewport, what we want in the final render.

Blender has a nice button in the bottom right corner of the 3Dview window that renders the viewport. We can use this to create a wireframe pass.

First things first; render your scene like you normally would, then save the image.

Now for the wireframe pass. One drawback is that there isn't any anti-aliasing by default, but if your video driver can force AA, then you're in luck.

Select the objects that are going to have a wireframe (and join them if you want, everything is going to have the same material now) and goto the Objects buttons (F7) and select the wire button. Repeat for each object.

Sometimes Blender optimizes the display by hiding some edges. Unless this is what you want, you can goto editing buttons (in edit mode) and locate the 'All Edges' button.

After you've activated it, you may have to tab in and out of edit mode on the other objects to apply it to them.

Now for the material. Give everything a black material with no diffuse or specular, enter solid draw mode, and you should have a shadeless black material. Once everything is selected you should have a white wireframe. Now its just a matter of going to camera view and hit the 'Render this window' button. (if you want black wires, you can just invert the image, or give it a white material with emit of 2, then go into shaded draw mode with everything deselected) The wire colour is dependent on your theme, so if its not black and white you might want to change it.

Don't forget to save the image.



To combine the 2 passes I used photoshop, but Blenders compositing nodes would work fine too.
If you're going to use white wires, then blend them with the Screen blend mode. If you're going for black, use Multiply. Then just play with the opacity until you get what you like.

And there you go! There's a lot of things you can play around with, like isolating seperate objects, or if you're using a subsurf modifier you can render another pass with the 'Optimal draw' button enabled to emphasize the original geometry.


Now go forth and experiment!

2 comments:

Dread Knight said...

Ah, i was thinking you made something straight out of blender; i know about this method, anyway, a very neat tutorial.

Perhaps I'll try to make one straight out of blender, I'm thinking of using compositing nodes and rendering layers.

Dread Knight said...

Damn I'm tired
"but Blenders compositing nodes would work fine too."
hehe

/me goes to sleep

Cheers!