Houdini 19.0 Solaris

Using MaterialX with Karma

Houdini has VOP node equivalents of the MaterialX shader nodes. You can build a shader network using these nodes, or import an existing MaterialX shader, and use them with Karma (Houdini’s USD renderer).

On this page

Overview

MaterialX is an open source standard for describing shading networks. MaterialX shading networks are designed to be portable between applications and renderers.

Because Karma XPU will never support the traditional VEX-based shaders used by Mantra and Karma CPU, MaterialX is probably the future of writing shaders for the Karma renderer.

A MaterialX material can be defined by a .mtlx file on disk (this is an XML format that describes the network using elements), or encoded as a UsdShade prim in a USD stage. Houdini lets you build MaterialX materials in VOPs and translate it into a UsdShade prim automatically.

Tip

Referencing specific materials out of a MaterialX definition file helps to keep scenes cleaner and easier to navigate.

The official MaterialX specification and documentation used in Houdini are in the following documents:

Tip

Houdini’s MaterialX support includes the MtlX Standard Surface node, a physically-based uber-shader, similar to the Principled shader. You can use this node for most needs rather than defining your own shaders.

Limitations

  • Currently, Karma does not support MaterialX light shaders.

  • MaterialX nodes have Color Space parameters, but this is actually metadata which USD’s Hydra interface currently doesn’t pass on to the render delegate.

  • MaterialX defines a few tokens (for example {frame} for time) for use in file paths, but these are currently not used by Karma or Houdini. You can use the <UDIM> token, however.

  • Karma only supports Volume materials on volume primitives (VDBs).

  • Karma does not currently support Surface and Volume materials on the same prim.

  • The Compositing nodes are not supported by Karma.

Material types

The two primary types of materials created with MaterialX are Surface and Volume materials.

Materials can contain different shader types:

BSDF

Describes how surfaces absorb, reflect, and refract light. Used in Surface materials.

VDF

Describes shading specific to volumes. Used in Volume materials.

EDF

Adds emission/illumination properties. Can be used in both Surface and Volume materials.

Surface materials

  • The MtlX Surface Material node defines a Surface material. You can wire a network of MaterialX surface shading nodes into it to define the surface shader. It also lets you wire in a displacement shader network if you want displacement. This is similar to the Collect VOP in Houdini-native materials, and in fact you can use a Collect VOP in place of a MtlX Surface Material VOP when building a network.

    (Similarly to Houdini-native materials, you can use most MaterialX surface-shading nodes as a stand-along material. However, if you want to add a displacement shader to the surface shader, you need to use a MtlX Surface Material or Collect to have a place you can wire the displacement network in.)

  • You define surface shading by wiring BSDF, EDF, and/or Opacity nodes into a MtlX Surface node.

    You can use the MtlX Thin Surface node to create the look of a thin, two-sided geometry, where eash side can have a different BSDF and EDF.

  • You can combine BSDFs using MtlX Layer, MtlX Add, MtlX Multiply, or MtlX Mix.

  • You define displacement using the MtlX Displacement node.

  • You can use the Uniform EDF node to add emissive properties to a MtlX Surface.

Volume materials

Textures and patterns

MaterialX includes many nodes for working with textures.

  • MtlX Image, MtlX Tiled Image, and MtlX Triplaner import texture images. You can use the <UDIM> token in texture filenames. (See limitations above.)

  • The MtlX Normalmap node can transform a normal map texture to a world-space normal, for use as input to the MtlX Standard Surface node's normal input.

    MtlX Normalmap’s in input expects a typical normal map, with a tangent-space normal vector from 0 to 1 range (that is, centered on 0.5). The node’s normal and tangent must be vectors from 0 to 1.

    Note

    When reading any normal maps with a MaterialX node, set the Signature to Vector3 to make sure a color space is not applied to the incoming data.

  • The MaterialX specification does not currently include ready-made procedural patterns. However, the low-level math nodes are fairly complete. For an example of how to use them to make a procedural pattern, see the how to section below.

Primvars and geometry attributes

MaterialX shaders can read arbitrary primvars from USD prims. You should set the Signature to the primvar’s data type. The nodes will automatically detect the primvar’s interpolation.

  • The MtlX Geompropvalue node can read any primvar. (You do not need to include the primvars: prefix).

    • This node is very similar to the USD Primvar Reader node, but as MaterialX doesn’t currently support string inputs, we can’t wire up the primvar name to a material’s public interface. Karma lets you mix the USD Preview nodes with MaterialX nodes, so that is a current workaround until MaterialX supports string inputs.

    • In Karma CPU only, you can also use the Geompropvalue node to import global VEX variables.

  • MtlX Geometry Color reads the primvars:displayColor primvar.

  • MtlX Normal reads normals (vector3).

  • MtlX Texcoord reads primvars:st or primvars:uv (vector2 or vector3).

How To

To...Do this

Reference a material from an external .mtlx file

  1. Create a Reference LOP.

  2. Set the Reference file to the file path of the MaterialX .mtlx file on disk.

  3. Use the Reference primitive pop-up menu to select the specific material to load in.

  4. Add an Assign Material node and set up its parameters to assign the referenced material to a USD prim.

Houdini includes some example materials in $HFS/houdini/materialx/resources/Materials/Examples/StandardSurface/

Create a Standard Surface material

The MtlX Standard Surface node is a physically-based uber-shader, similar to the Principled shader. You can use this node for most needs rather than defining your own shaders.

  1. Create a Material Library LOP.

  2. Double-click the Material Library node to dive into the VOP network inside.

  3. Inside, create a MtlX Standard Surface VOP.

  4. Set up the parameters of the node. You can also load and wire textures into the Standard Surface node’s texture inputs (see below).

  5. Give the material VOP a menaingful name (for example, red_car_paint).

  6. Go back up to the parent LOP network.

  7. Use the parameters on the Material Library to import the material and assign it to USD geometry.

Use textures with the Standard Surface material

  1. See above for how to create a Standard Surface material.

  2. Go inside the Material Library LOP containing the Standard Surface node.

  3. Create a MtlX Texcoord VOP. Change the Signature to Vector2.

  4. Create a MtlX Image VOP.

    • Change the Signature to Color.

    • Set the Filename to the file path of the texture image file.

    • Wire the MtlX Texcoord node’s output to the MtlX Image node’s texcoord input.

    • Wire the MtlX Image node’s output to a texture input (for example, base_color) on the Standard Surface node.

Create a surface shader from scratch using a BSDF

  1. Create a Material Library LOP. Double-click the Material Library node to dive into the VOP network inside.

  2. Create a MtlX Surface Material VOP.

    (You can also use a Collect VOP as the material output. This is necessary if you want to connect multiple shaders for different renderers, or author a USD Preview shader manually.)

  3. Create a MtlX Surface. Wire its output to the MtlX Surface Material node’s surfaceshader input.

  4. Create a MaterialX BSDF node (for example, the MtlX Conductor BSDF). Wire its output into the MtlX Surface node’s bsdf input.

  5. Set up the parameters on the BSDF node.

  6. Give the MtlX Surface node a meaningful name (for example, red_metallic).

Create a procedural pattern

MaterialX includes very low-level nodes for manipulating values. With enough patience, you can use them to build procedural patterns such as stripes or checkerboards.

The following example shows how to use math nodes to make a procedural stripe texture.

  1. Create a Material Library LOP. Double-click the Material Library node to dive into the VOP network inside.

  2. Create a MtlX Standard Surface VOP.

  3. Create a MtlX Texcoord VOP. Change the Signature to Vector2.

  4. Wire the MtlX Texcoord node’s output to a MtlX Separate2.

    This splits the texture coordinates vector2 output into separate wires.

  5. Create a MtlX Multiply. Wire the Separate2 node’s outx to this node’s in1.

    This node’s in2 parameter will control the stripe frequency. Set it to 5 for now.

  6. Create a MtlX Sin node and a MtlX Ceil node. Wire the MtlX Multiply’s output to the MtlX Sin’s input, and the MtlX Sin’s output to the MtlX Ceil’s input.

  7. Create a MtlX Mix node.

    • Change the Signature to Color.

    • Set the fg and bg colors to the alternating colors for the stripes.

    • Wire the MtlX Ceil’s output to the MtlX Mix’s mix input.

    • Wire the MtlX Mix’s output into the Standard Surface node’s base_color input.

List of MaterialX VOP nodes

Solaris

USD

Geometry

  • Importing SOP geometry into USD

    Details of how Houdini converts SOP geometry to USD, and how you can control the process.

  • Component Builder

    The Component Builder tool puts down a network snippet for creating a USD model from SOPs, with support for materials, variants, payloads, and layering.

Layout

  • Edit node

    Interactively transforms prims in the viewer. Can use physics collisions to position props realistically.

  • Layout node

    Provides tools for populating a scene with instanced USD assets. You can place individual components, paint/scatter components in different ways using customizable brushes, and edit existing instances.

  • Custom Layout Brushes

    How to create layout brush digital assets you can use to customize the behavior of the Layout LOP.

Shading

  • Shader Framework

    Describes the Solaris shading framework, including shader node translation to USD primitives.

  • Using MaterialX with Karma

    Houdini has VOP node equivalents of the MaterialX shader nodes. You can build a shader network using these nodes, or import an existing MaterialX shader, and use them with Karma (Houdini’s USD renderer).

  • /solaris/materialx_nodes

Karma rendering

Tutorials