Temitope FALADE's profile

HOUDINI - RENDERING WITH KARMA XPU 1 (BASIC WORKFLOW)

HOUDINI - RENDERING WITH KARMA 1 (BASIC WORKFLOW)
INTRODUCTION
Rendering is the process of outputting image from a 3D (or 2D) software. It usually involves the computer undergoing a series of computation in order to generate the image based on the settings we performed in the software. The brain responsible for all these computations are called Render Engines.

Houdini has three renderers that shipped with it namely: Mantra, Karma, and Storm.

In this module, we are going to learn the basics of rendering all kinds of geometries and objects with Karma as this is the preferable render engine most of the time, so let's dive into it.
SOLARIS
In order for us to render with Karma inside Houdini, we need to first switch our workspace to the Solaris window. This window is where we can access the Karma render engine and it's associated settings. The workflow in Solaris primarily involves USD file descriptions, but we will not go too in-depth into that. We will only focus on the nitty-gritty things we need to know in order to render with Karma.
For the purpose of reference, this is how the Solaris window look like:
Here's how the default Build windows look like:
The only difference between Solaris and the default Build is the presence of the USD Editor Window in Solaris.
LOP NETWORK
The term LOP stands for Lighting Operator in Houdini. It is one of the five main operators that Houdini is built on, that is Surface Operator (SOP), Dynamic Operator (DOP), Render Operator (ROP), Particles Operator (POP), and Vector Operator (VOP)

This network is responsible for organizing our assets (models, hairs, particles etc.), assigning materials to them, creating camera, lighting, and rendering them inside Solaris.
In this section, we are going to learn how to use the LOP network to import our assets into the Solaris workspace.
Houdini Setup
Start by creating a geometry node in the object level and rename it as "RENDERING" and enter it's SOP level.
Let us create some objects to render inside this SOP level. We will create the following basic assets:

- A sphere
- A torus
- A test pig head
- A simple particle simulation setup
- A simple hair setup
- A simple pyro setup
- A ground plane (to cast shadows)

We are creating all these assets so that we can demonstrate how to render different kind of assets with Karma.

Simply create the geometries and simulation assets just the same way we would usually setup our VFX. Organize them accordingly.
Next, go back to the object level and create a new LOP network node. We will create a new camera as well.
Next, let us switch to the Solaris workspace.
Importing Assets to Solaris
To start importing the assets into Solaris, double click the lopnet node to enter it's LOP level. Rename this "Stage". This is where we are going to setup our scene for rendering.
Currently, there's nothing inside this LOP level. 

Create a new SOP create node; This node will allow us to import either one asset at a time (or multiple assets at a time). Rename it sphere so that we can import the sphere with it.
Double click to enter into the node's create level. This level is currently empty as well because we have not imported any asset yet. 

Let's start with the sphere. Create an object merge node, and reference-in the null output node of the sphere to import it here.
The sphere will now show in the viewport;
In the same way, let's create new SOP create nodes, enter their SOP levels, create an object merge node to import the other assets as well.

We should now have a node setup like this:
We used a merge node to display all the imported objects at once.
Assigning Materials to Assets
Let's start with the sphere;

Create a new Material Library node. This node allows us to create and store all the materials we need for all our assets.
Inside the material library, create a MTX standard surface material node. This is the standard Material X shader that works perfectly with Karma render engine. Rename this node "sphere MTX" so that we know the material is for the sphere.

To assign this material to the sphere in the viewport, LEFT CLICK drag from the material and drop on the sphere in the viewport. A drop action window will pop up. Select "set material on mesh 0" to assign. If you change the base color of the material to blue for example, the sphere will turn blue in the viewport.
Additionally, a new 'material library' node and a 'assign material' node are automatically created in the stage.
To assign new materials to the other assets, go back into the first material library we created, and create new MTX standard surface material nodes for the remaining assets. Rename them accordingly:
Drag and drop the appropriate material to the corresponding asset, choosing "set material to mesh 0" for the geometry meshes, "set material for point 0" for the particles, and "set material for volume 0" for the smoke respectively.
Now all our assets have their own unique materials assigned.
Assigning Texture Maps
For the pig head geometry which has a UV layout and a texture map for it, we can assign the texture map back inside the material library node where we created the pig head MTX.

To do this, create a USDUVtexture node and connect the RGB output into the base color input on the Material X.

Then in the File path field, you can select the texture map.

In a similar way, you can assign the texture maps for the other channels as well like the roughness, specular, bump, etc.
Assigning Materials to the Particles
For the particles, we already created a color attribute in the SOP level that we used to shade the particles. This color attribute gets carried into Solaris as well;
We do not want to assign a new color to the particles, instead, we want to utilize the existing color with the Material X. 

To do that, create a new MTX Geometry Property Value node and connect it's output into the particles MTX base color input.

In the parameter window, change the Signature to 'Color'.

In the Geomprop field, type in "displayColor".
It is going to retain the original color of the particles and display them based on their original pscale values.

This same approach is applicable to Hair Strands as well.
Now, they are looking quite big. This is because they currently do not have any pscale attribute to adjust their size. If we want to reduce them, we will need to first create a pscale attribute for them in the geometry SOP level.

Go into the geometry SOP level where the particles was originally created and add an attribute adjust float node with the attribute name as "pscale" and attribute class "point" to create a new pscale attribute for the particles. 

We will need to recache the simulation so that this new pscale attribute is baked out with the simulation.
Now back inside Solaris, the particles gets really big. This shows that the pscale attribute is now taking effect.
We can now use the attribute adjust float (pscale) to reduce the size of the particles.

For example, if we set the value to 0.001 (min) and 0.004 (max), we're going to get really reduced particles size now in Solaris. Make sure to always recache the simulation for every changes you make to the pscale so that the changes reflect inside Solaris.
This method is applicable to all kinds of particles simulation.
Assigning Materials to Volumes
General note for volume materials:
Karma Volume works well for volume rendering using Karma XPU.
MTLX Volume material works well for volume rendering using Karma CPU.
However, instead of racking our head on how to setup the volume materials from scratch, there's a much easier automatic way we can achieve that.
When you simulate your volume effects (smoke, explosions, dusts etc.) with pyro solver, and intend to render with Karma XPU, first cache out your simulation with the file cache node (no need to use any volume compress node if you're rendering inside Houdini). Then use a pyro bake volume node to do the look development for the volume post-simulation.

With the pyro bake volume node selected, you can use the 'quick setup' dropdown to choose the 'Create Render Stage' option in the dropdown.
This will prompt you to select a light preset, and after you make the choice, it will automatically setup the Stage for pyro rendering, importing every data we need automatically; and by default, Karma CPU will render the volume right out of the box without us even doing anything.

If we switch to Karma XPU, we get a nice render as well.
There might be some instances when Karma XPU might not render the volume as we expect. In such situation, what we need to do is to first use a pyro post-processing node to convert the volume to VDB.
Make sure to enable "convert to VDB" and "combine volumes" in the pyro post process node.
Once you've done that, double click on the lopnet pyrobakevolume node that was generated by the quick setups to enter into the stage for the volume render. That is how you can access the Stage for the pyro rendering (if you go via the usual Stage level, you will not see anything).
You should use the pyro bake volume node to do all the necessary look development you want to do for the pyro.

For ease of work, you can create a floating parameter window for this node by right-clicking on it, navigating to Parameters and Channels, and select Parameters. This will open up a floating window that you can now use to tweak your look development while rendering with Karma XPU.

This way, we are able to change the smoky look of our volume to fire much conveniently.
This method is applicable to all kind of volume simulations that involves pyro.
Create Lights and Camera
To create light, simply right click and type "light". You can create all kinds of light nodes in Solaris just as we would usually do in the Build workspace.

To use an environment HDRI as light source, simply create a dome light

Under the texture path field, you can select the HDRI image to use. You can also use the transform tab to rotate the light as well.

Connect the light nodes down the node as shown below:
Finally, to create a camera, simply frame your viewport, and then in the top right of the viewport where it says "No Cam", click the dropdown and select "New Camera". You can rename the camera, adjust it's settings, reposition it, and lock it to the viewport.
Here's a test render done with Karma.
If we don't want the HDRI background image to show in the render, we can turn it off in the Display options. Press D in the viewport to bring up the display options window.

Navigate to the Background tab and turn off "Display Environment Lights as Backgrounds". This will turn off the HDRI in the render.
Karma Rendering Settings
Create a Karma Render Settings node. This node contains all the important settings for rendering with Karma.
We can choose the XPU Engine in the Rendering Engine dropdown. We can use the Path Traced samples to control the number of samplings required for the rendering.
In the Advanced tab, we can choose between Bucket and Progressive rendering;
In the Image Output tab, we can choose to use a denoiser to help remove the noises generated at render-time.
Finally, connect a USD Render ROP node to do the final rendering.
A DIFFERENT APPROACH TO IMPORTING ASSETS TO KARMA FOR RENDER
Another neat workflow we can adapt to import our assets into Karma is described as follows:

1. Make sure all the objects or assets you want to render have their unique groups and UVs as well;

2. Create a new geometry node named "RENDER" specifically designed to render your objects;

3. Use object merge nodes to import all your objects/assets into this render sop level, and use a merge node to combine them according to their object types into one output. 

For example, all geometry meshes or polygons (with every single geometry having their own unique group) should be merged together into a "OUT MESHES RENDER" null node; 

All particles (with each particles having their own unique groups as well) should be merged together into a "OUT PARTICLES RENDER" null node.

All hair grooms/simulations should have their own unique groups and merged together with a "OUT GROOMS RENDER" null node;

All pyro simulations should have their own VDB groups and merged together with a "OUT VOLUMES RENDER";

4. Once you've properly organized all your assets, you can now import them into the Stage. You do not necessarily need to switch the workspace to Solaris to access Karma renderer. By simply switching the object level to Stage level will make us have access to Karma.

5. To import your assets into the Stage, an alternative to using the SOP Create node is to use SOP Import node.
6. If you want to assign materials, you need to select the SOP Import node, then under the Import Data tab, enable the "Subset Groups" and select all the available geometry groups you've set up.
7. Create the other necessary nodes you need such as the lights, and the camera(s); Use a merge node to combine all the nodes you've created. Instead of the top-down approach we used in the method discussed above, we can also work this way:

If you set the render flag to the merge node, you'll see the preview of everything in the viewport;
If you don't want to see the HDRI in the background, simply turn it off in the display option under the "background" tab.
8. To render the scene, place a Karma Render Settings node and a USD Render ROP node after the merge node:

The karma render settings would be used to tweak the final quality settings of the render, while the USD render ROP would help us to output the rendered images.
The above is the very basic framework of how we use the Stage level to setup our scenes for render.

Of course, it can get way complex than this, but this is the general workflow when rendering with Karma.
9. Create Material Library for the assets; For each category of assets you import into the Stage, you're going to create a material library for each categories. 

For example, if you're import meshes, the material library will store all the materials needed for all the meshes. 

If you're import particles, the material library will store all the materials needed for all the particles, and so on and so forth.

So for this our simple example, create a material library to store the materials for the two geometries here:
Double click to enter the Material Library node. You can now create all your materials inside here. 

If you're rendering with Karma CPU, the MTX standard surface material node will work perfectly.

If you're rendering with Karma XPU, MTX standard surface material will NOT work. Instead, use the Karma MaterialX Subnet (or Karma Material Builder) node as this works perfectly with Karma XPU. Double click to enter into this subnet to start building the materials.
Create one for the sphere, and another for the torus:
Inside this subnet is where you will now create the MTLX standard surface node.
For this example, we don't need the displacement nodes, so delete them.

Duplicate the nodes as shown below, one for the sphere, and the other for the torus

Connect the output of this standard shader to the Surface output node as shown below:
To display the color in the viewport, use the MTX Geometry Property Value node. Change the signature to 'color' and type 'displayColor' in the Geomprop field.
If you want to use texture maps instead, create a USD UV texture node and plug it's RGB output into the MTX base color (or other channels) input. Then you can choose your texture map via the File path field.
So basically, you can setup all the materials for all the geometries inside this material library designated for the geometries.

For this example, we are going to use simple colors, so let's leave our node setup from how we started;
10. Assign the Materials: Go back to the Stage level and create a new assign material node below the material library.
Then switch to the Karma XPU render view to see the updates;
Currently, the materials have not been assigned yet;
If you look in the USD scene graph window, you'll see that all the geometries are imported into the GEO_IMPORT path, and we can see the groups we created for our meshes.

Below that, we can see the two Karma Materials (XPU) that we also created for both the sphere and torus earlier.
To assign a material to the sphere, follow the steps described below:

- Select the assign material node in the Stage so that we can see it's parameters window, then LEFT CLICK drag and drop the sphere GRP from the USD scene graph into the Primitives Path of the assign material node.

In a similar fashion, expand the Materials path in the scene graph, LEFT CLICK drag and drop the sphere MTL from the scene graph list into the Material Path of the assign material node.
To assign material to the torus, click the + icon to create a new material slot and repeat the same steps above for the torus:
You can create as many slots as you need for all the geometries you want to assign them to.

If you have so many objects that shares the same group, you can simply do something like:

/GEO_IMPORT/mesh_0/**/Object_GRP

The double asterisk is going to make it a relative path and it will assign the material to all the objects that shares that same path.
As you can see, this is so easy to do. And we will see that Karma XPU picks up these materials correctly in the render:
We can use the steps described in this method to work even more efficiently inside Solaris, and get all your renderings done with Karma XPU.
HOUDINI - RENDERING WITH KARMA XPU 1 (BASIC WORKFLOW)
Published:

Owner

HOUDINI - RENDERING WITH KARMA XPU 1 (BASIC WORKFLOW)

Published: