# How to set up material lookuptable for OSPRay

**URL:** https://discourse.paraview.org/t/how-to-set-up-material-lookuptable-for-ospray/56
**Category:** Tips and Tricks
**Created:** [May 31, 2018, 6:49pm UTC](https://discourse.paraview.org/t/how-to-set-up-material-lookuptable-for-ospray/56 "2018-05-31T18:49:30Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Dave\_DeMarle](https://discourse.paraview.org/user_avatar/discourse.paraview.org/dave_demarle/32/27_2.png) [@Dave\_DeMarle](https://discourse.paraview.org/u/Dave_DeMarle)
#### Post date: [May 31, 2018, 6:49pm UTC](https://discourse.paraview.org/t/how-to-set-up-material-lookuptable-for-ospray/56/1 "2018-05-31T18:49:31Z")

</div>

Howdy,

The new OSPRay path tracer in ParaView 5.5.0 has a mode in which each cell gets a material assigned via colormapping. To use it:

- choose “Value Indexed” for the OSPRay Material instead of any of the individual material names.
- pick an array to material map, for example “MaterialIds” that you will get with many .obj files
- set up a categorical color map with annotations that are material names.

With .obj files there is a field aligned array “MaterialNames” that has all of the material names referenced by the .obj in it. You can see it in the spreadsheet view. You could manually create a lookup table from it, but the following script will create a lookup table automatically (copy and paste it into the Python Shell).

```
anObject = GetActiveSource()
vtklevel = anObject.GetClientSideObject()
lut = GetColorTransferFunction('MaterialIds')
arr = vtklevel.GetOutput().GetFieldData().GetAbstractArray("MaterialNames")
lut.InterpretValuesAsCategories = 1
ll = []
for x in range(0, arr.GetNumberOfTuples()):
  ll.append(str(x))
  ll.append(arr.GetValue(x))

lut.Annotations = ll

```

hth
