UV Map node

Two rendered Emo heads
Using UV pass to add a new texture in composite.

Mesh objects with UV 'texture face' co-ordinates can be saved in a render pass, and used in the Compositor as input to remap textures.

 

Unfortunately UV values can't be simply filtered or antialiased as for colors. It is also important to retrieve from the UV image information to correctly and map a new image without aliasing. In Blender that's solved as follows:

  • While rendering, the UV values are combined using a simple (1 pixel wide) box filter. Additionally, an alpha value also gets stored, to retrieve object edges correctly.
  • The Composite "UV Map" node reads this pass buffer, and applies a 3x3 pixel differential filter on the UV values. This gives the information of the sample area size in the to-be mapped image.
  • If this sample area size is above a certain threshold ("Alpha" button in UV Mask node), it adds an extra alpha value to the output image.
  • By using this alpha in the composite, you can mask out the errors caused by anti-aliasing, overlapping faces or adjacent faces with different UV values.
Detail of two cubes
The UV values
Creating an Alpha mask
UV Mapped tile texture

Demo files for the examples can be loaded here: Cubes UV map and Emo head (without textures)

 

 

Dilate/Erode

Dilate/erode grows and shrinks masks by comparing pixels to their surroundings and taking the maximum or minimum values. This can be very useful for cleaning up a key after a matte node. Negative values shrink the mask and positive values grow.

 

Z-Combine node

Using the same masking trick as for ID Mask, Z-Combine now offers anti-aliased results as well. Note that Z values are still aliased, only 1 sample per pixel for Z is delivered to the compositor, so the masks can have small artefacts.

Z-Combine without AA mask
Z-Combine with AA mask

Displace Node

Greyscale displacement node setup

The displace node displaces an image's pixels based on an input vector mask. This can be useful for a lot of things, like hot air distortion, quick-and-dirty composited refraction, compositing live footage behind refracting objects, and more!

Greyscale input, displacing in one direction (video, h.264)
2D vector input (normal map), independent, more accurate, X and Y displacement (video, h.264)

The amount of displacement for each pixel in the X and Y directions is determined by:
 

  • The value of the mask's channels (red/channel 1 displaces pixels along the positive or negative X axis, green/channel 2 displaces in the Y axis). If both the channels' values are equal, (i.e. a greyscale image), the input will be displaced equally in both X and Y directions
  • The X scale and Y scale buttons - these act as multipliers to increase or decrease the strength of the displacement along their respective axes. They need to be set to non-zero values for the node to have any effect. 

You can use the displace node in two ways, with a greyscale mask (easy to paint or take from a procedural texture), or with a vector channel or RGB image, such as a normal pass, which will displace the pixels based on the normal direction.

Hot air distortion demo video by Matt Ebb (.blend file)

 

 

 

 

ID Mask node

This node will convert a number from an Object Index pass to an anti-aliased alpha mask. (Set Object pass indices in Object buttons, the "Object and Links" panel.)

 

Since indices cannot be filtered or anti-aliased, a post-process function is used which fills in the jaggies with interpolated values. Here it uses the same function as used for creating masks for Vector Blur.

 

Demo .blend file for masking

Raw output from ID pass
Antialiasing routine
Mask applied to colorize