Q100170: Getting started applying Textures to objects in Katana

Follow

SUMMARY

Textures are handled in a variety of different ways by shader libraries and studio pipelines and Katana offers a flexible framework to assign textures, following some common conventions. 

Below is a summary of some of these options that work with the 3Delight, RenderMan and Arnold renderers. Please also see the attached example scene that demonstrates both approaches explained here.

 

MORE INFORMATION

Using material attributes to declare textures

The simplest way to give each object its own texture is to create a material per object and explicitly declare the textures as string parameters in the shader. Each object is then assigned the relevant material.

This approach is the most labour-intensive, especially when working with a scene that contains a large number of objects, and lacks flexibility when changes to a material have to be made.

Often many objects can share the same material, but need to be assigned different textures. In this case, it is possible to set up the scene so that each object picks up its own textures:

 

Using object attributes to declare textures

Rather than setting the texture on the material, the objects to be rendered can point to the relevant texture file via an arbitrary attribute.

 

User data and primvars in Katana

Renderers allows the use of user data or primvars which can be looked up by shaders. In Katana, the convention is for arbitrary geometry data to be read in as attributes called geometry.arbitrary.xxx, which are then, by default, also written out as user or primvar data to renderers. This means that if you are using primvars or user data to specify textures, you can have this work automatically.

 

Using primvars to declare textures when using RenderMan in Katana

RenderMan has a method to handle textures across instances which is to resolve the Shader Parameter Syntax at the instance location and to do this via RenderMan <primstr:attributename> syntax. However, this was only introduced in RenderMan 24.

 

Creating an example scene

The following are instructions on how to use object attributes to declare textures. This example is using the 3Delight renderer:

  1. Add a CameraCreate, a NetworkMaterialCreate, and two Pony nodes from the Help > I want a pony menu. Be sure to change the name parameter on each of the Pony nodes so they are unique.

  2. Create an AttributeSet node downstream of each Pony and set the path to the Scene Graph location of the respective upstream Pony.

    mceclip1.png

  3. Edit each of the AttributeSet nodes and change each attributeName parameter to 'geometry.arbitrary.basecolor.value' and type parameter to 'string'.

    mceclip4.png

  4. Set the stringValue of each AttributeSet to point to a unique texture file. You can find example files included with Katana at $KATANA_ROOT/demos/tx_files/, alternatively I have attached the textures files to this article.

    mceclip5.png

  5. Jump into the NetworkMaterialCreate node (Shortcut: Ctrl+MMB or Ctrl+Enter when selected) and create a dlPrincipled and a dlTexture shading node.

  6. Edit the dlTexture node and set the Texture File parameter to '{attr:geometry.arbitrary.basecolor.value}'; this reads the file path from the attribute set previously.

    mceclip6.png

  7. Connect the outputColor port of the dlTexture to the input of the Base > Color port of the dlPrincipled node and jump out of the NetworkMaterialCreate (Shortcut: Ctrl+Backspace).

    mceclip7.png

  8. Select all nodes, except the Pony nodes, and press 'M' to create a merge node downstream.

    mceclip8.png

  9. Create and connect a MaterialAssign node below the Merge, adding a custom CEL reference with the value '/root/world/geo//*', and setting the materialAssign parameter to '/root/materials/NetworkMaterial'. This will apply the material to all locations below the 'geo' location in the Scene Graph.

    mceclip9.png

  10. Finally, create a GafferThree node downstream of the MaterialAssign and add an Environment Light from the Add 3Delight menu.

When rendering you will now see two different textures applied to the ponies from a single material.

mceclip10.png 

 

FURTHER READING

For more information on handling textures across instances, please refer to: Q100508: Increasing scene graph cook performance with Hierarchical (Instance Source) Instancing

 

ATTACHMENTS

We're sorry to hear that

Please tell us why