The New API¶
This is a very quick introduction to the use of the new API to give a sense of the basic feel.
There are three main parts to the new API for plugin writers. The first is a new math and common-function library, the second is the API which wraps USD, and the third is for shared geometry functionality. These reside in five new libraries, libFdkBase(fdk), libFnUsdAbstraction(usg), libFnUsdEngine(usg), libFnUsdShim(usg) and libNdk(ndk). You will need to link against all these libraries (except libFnUsdShim) as well as DDImage. Each library has different namespaces and top include paths to separate conceptually different code subsections rather than sharing a single folder like DDImage. Include files for the new libs are included like so:
#include “fdk/math/Vec3.h”
The Math Library¶
The math classes in DDImage are all single precision, and this often isn’t good
enough for large scenes or operations like raytracing. The NDK contains a set
of math classes which are templated for float, double, half and (sometimes)
int. These include vectors (Vec2
, Vec3
, Vec4
), matrices (Mat4
),
quaternions (Quat
) and boxes (Box2
, Box3
). These are suffixed by
f
, d
, h
or i
. Thus fdk::Vec3f
is a 3-vector of floats and
fdk::Quath
is a quaternion of half-floats. You should use these classes in
preference to the DDImage classes such as Vector4
.
The USD Wrapper¶
The NDK has a set of classes which act as thin wrappers around USD classes. The intention of the wrappers is to insulate Nuke from dependence on a particular version of USD.
This is achieved through the use of an interface library (libFnUsdAbstraction) and a shim library (libFnUsdShim). What happens is that the USD libs are loaded by libFnUsdShim. libFnUsdShim is loaded as a plugin at runtime by libFnUsdAbstraction. This provides a separation between the symbols in the USD libs and the ones in Nuke.
The wrapper classes include:
Token (
TfToken
)Path (
SdfPath
)Attribute (
UsdAttr
/SdfAttributeSpec
)Prim (
UsdPrim
/SdfPrimSpec
)BoundablePrim, XformablePrim, PointBasedPrim, MeshPrim (
UsdGeomBoundable
etc.)Layer (
SdfLayer
)Stage (
UsdStage
)
Note that some of these, such as usg::Attribute, can wrap either a USD or SDF class. This simplifies the API while keeping it efficient - we can use the same code to set an attribute whether we’re defining a prim in a layer or changing a prim from a USD stage.
Using a Custom USD Version¶
In order to use a custom USD version with Nuke, it is now required to build the libFnUsdShim library against your custom USD version.
The source code for libFnUsdShim is provided with Nuke in the source/FnUsdShim
directory next to the Nuke executable. There is a Readme file with this source
that explains all the steps that must be taken to build libFnUsdShim. It also
explains steps how this and your custom USD version can be used with Nuke.
libFnUsdShim can be placed in any arbitrary location and the path to that lib configured arbitrarily at runtime.