Multiple Geometry load

Hello, I saw in the example of the Glass how to load mulitple meshes but what if I have something like this:

GeometryGroup geometry_group = m_context->createGeometryGroup(gis.begin(), gis.end());

Where gis contains parallelograms. I did something like this to add the cow mesh to the rest:

GeometryGroup geometry_group[2] = { m_context->createGeometryGroup(gis.begin(), gis.end()), m_context->createGeometryGroup() };
  GeometryGroup maingroup = m_context->createGeometryGroup() ;
  ObjLoader loader(m_filename.c_str(), m_context, geometry_group[1], diffuse);
  maingroup->setChild(0, geometry_group[0]->getChild(0));
  maingroup->setChild(1, geometry_group[1]->getChild(0));
  maingroup->setAcceleration( m_context->createAcceleration("Bvh","Bvh") );

but I am getting a weird result. It only renders the floor (it should be the cornell box scene)

the intersection program is

std::string ptx_path2 = ptxpath("path_tracer", "");
m_pgram_intersection_mesh = m_context->createProgramFromPTXFile(ptx_path2, "mesh_intersect");

That ain’t working. You cannot simply mix and match programs from examples with different rendering implementations.

geometry_group[0] should have gis.size() GeometryInstance children.
maingroup->setChild(0, geometry_group[0]->getChild(0)); only attaches the first GeometryInstance of that to your GeometryGroup maingroup.

There need to be two intersection programs, one for the parallelogram and one for the triangles of the OBJ.

There is no used inside the path_tracer example unless you added it.
Otherwise there should be an error that createProgramFromPTXFile() failed if you didn’t add it there.

The glass example has that but it’s generating different attributes than required for the path_tracer.
You would basically need to write an intersection program which handles triangles and generates the attributes required inside the path_tracer.

Then you use the diffuse material of the path_tracer which sources the diffuse_color variable for lighting calculations, but the OBJLoader generates texture samplers for the Ka, Kd, Ks values, see ObjLoader::createMaterialParams().

You’d need to implement a closest hit program which uses the variables generated by the OBJLoader in a way required for the path_tracing diffuse BRDF calculations and use the correct intersection program and attributes.

Actually I’d recommend to try to generate own triangle mesh geometry as an exercise in the beginning instead of using the loaders to get a better understanding how things underneath fit together before abstracting them again.