C44Matrix

C44Matrix is an extended version of ColorMatrix that allows to use 4x4 matrices to transform color data. Additionally, it provides an optional Camera input to automatically get a transformation or a projection matrix from it.

Updated: 13 December 2013

Author: iva.busquets

Compatible Nuke versions: 8.0 or later

Compatibility: Linux 64, Mac 64, Windows 64, Source

1. Description

C44Matrix is basically an extended version of Nuke's ColorMatrix, but instead of using a 3x3 matrix, it allows to use a 4x4 matrix to transform color data.
Additionally, it provides an optional Camera input to automatically get a transformation or a projection matrix from it.

The main goal of C44Matrix is to make it easier for users to perform transformations on pixels containing position data, such as a world position pass. From arbitrary transformations, to converting between different coordinate systems (world space, camera space, NDC, etc), C44Matrix should make things a little easier by not having to resort to complex expressions and multiple nodes to apply a 4x4 matrix to pixels.

 


 

2. Workflow

C44Matrix will apply its transformation to pixels in the RGBA channels. R,G,B and A will be used respectively as the X, Y, Z and W components of a vector to which we want to apply the transformation. Most of the times, you'll want to make sure you have a solid alpha channel (A=1) to make sure you get the right results.

There's 2 modes of operation:

- Manual input:

This works the same way as the ColorMatrix node, but with a 4x4 grid instead. With this mode, you would manually enter (or expression-link) the values of a 4x4 matrix you might have obtained from a Python script, or from the metadata of a render, etc.

- From Camera input:

In this mode, the 4x4 grid is automatically filled in with a transformation matrix taken from the connected camera.

You can choose between the following matrices:

  • Transform: Takes the full transformation matrix from the camera. This includes translations, rotations, and scaling. You can use this matrix to go from WORLD SPACE to CAMERA SPACE and viceversa
  • Translation: Like transform, but only taking the translation component
  • Rotation: Like transform, but only taking the rotation component
  • Scale: Like transform, but only taking the scaling component
  • Projection: takes the projection matrix from the camera. This accounts for all the parameters in the projection tab (aperture, focal, win_translate, win_scale, roll). You can use this matrix to go from CAMERA SPACE to NDC and viceversa.
  • Format: uses the current format to build a matrix that goes from NDC (-1 to 1) to pixel coordinates for the current format.

 


For either one of the above methods, there are the following additional options:

 

  • invert: apply the inverse of the matrix that's in the 'matrix' knob.
  • transpose: apply the transpose of the matrix that's in the 'matrix' knob. (replace rows with columns)
  • w_divide: divide the resulting vector by its W component. You'll usually want to do that when applying a projection matrix.

3. Screenshots

 

c44matrix_snapshot01

c44matrix_snapshot02

c44matrix_snapshot03

 


 

4. Note

This node is mostly intended to make it easier to build gizmos that want to deal with these sort of transformations.

It might be a little bit too cumbersome for direct use (without wrapping it into a more user-friendly gizmo), so if anyone wants to share ideas on how to improve the user experience or the documentation above, all feedback is very welcome.

 


Sign in or register to download or rate.