How to set variables per mesh group or material

I’m having some trouble getting OptiXMesh to do what I want.
I’m running OptiX 3.9.1, CUDA 7.5, Windows 7 (64-Bit).

My wish is to set some variables per group within the mesh. These variables differ per material.
I use a functor to walk over all MeshGroups within an imported OptiXMesh.

mesh.loadBegin_Geometry(obj_filename);
mesh.forEachGroup(per_group_functor);
mesh.loadFinish_Materials();

Within the functor I would like to set the variables on the material of each group.

Material material = m_mesh->getOptiXMaterial(group.material_number);
material["variable_name"]->setFloat(variable_value);

However, it seems that setting variables this way sets them for all groups.
Afterwards the last variable is set on all materials (which I checked using mesh->getOptiXMaterial(i)).

Maybe getOptiXMaterial always returns the same material, despite the group.material_number being different?
Do I misunderstand something, or is this possibly one of the issues discussed in this topic? Any suggestions how I might be able to set variables per material/group? I cannot upgrade to OptiX 4.0 since I’m on a Fermi class GPU.

This could be due to the flaky OBJ reader in pre-4.0, yes.

Check that the material file is really being read, first of all. The ‘mtllib’ line in the OBJ file should be the full filename including suffix, e.g. “material.mtl”. If mesh.getMaterialCount() prints 1, then the file is not being read, since a default material is always added in slot 0. You could also debug in gdb or Visual Studio since this is all host code.

It could also be more fun to roll your own OBJ-to-OptiX code in 3.9 rather than debugging OptiXMesh. You could use the ‘tinyobj’ loader from the 4.0 SDK or download it from github, then set up your own OptiX nodes and buffers and map the mesh data. This is good for learning how the scene hierarchy works too.