5
$\begingroup$

This question came up in the irc channel yesterday. The fellow had a model he was turning into a sprite for a 2D game. He wanted it to be aliased inside, but have a hard (aliased) edge.

Getting transparent images is easy. Go to the Render Properties panel and set your Alpha to Transparent and make sure the file format is saving RGBA channels.

enter image description here

Getting a hard (aliased) edge is easy. Turn off Anti-Aliasing in the Render Properties. This gives your model hard edges, even in the internal pixels.

turn off Anti-Aliasing in the Render Properties

Now if turn on anti-aliasing you get soft edges, both inside, and outside.

turn on Anti-Aliasing in the Render Properties

How do you get hard edges on the outside, but soft edges inside?

$\endgroup$
5

1 Answer 1

4
$\begingroup$

This answer was composed based on help from several individuals in the #blender IRC channel (you know who you are).

The first step is to use blender's Compositor. Start out by clicking the Use Nodes checkbox. That should create the two-node pipeline that does nothing exciting. Route the alpha channel through Math node (available through the Converter submenu of the shift-A menu) configured to do a Greater Than operation against 0.001. This means that an alpha of 0 will remain zero, but an alpha of 0.001 or higher (and 0.001 < 1/255) will be converted to 1.

Compositor with Greater Than applied to alpha channel

The problem that remains is that the edges that otherwise would have been translucent are now kind of dark. That's because the Image channel coming out of the Render Layers node is premultiplied. To correct for this, add an Alpha Convert node (available under the Converter submenu) and route the image channel through that on its way to the Composite node.

Compositor with Alpha Convert from premultiplied to straight

Now your edges are hard and they match the thresholded alpha channel.

$\endgroup$

You must log in to answer this question.

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