I hosted Cycles in my application and trying to generate normal maps using cycles. Blender’s code is my reference.
In Blender’s bake_api.c, there is a method
static bool cast_ray_highpoly(BVHTreeFromMesh *treeData, TriTessFace *triangle_low, TriTessFace *triangles, BakePixel *pixel_array_low, BakePixel *pixel_array, const float mat_low, BakeHighPolyData *highpoly, const float co, const float dir, const int pixel_id, const int tot_highpoly)
It shoots a ray from low-poly face to high-poly. Blender has its own data-structure to represent the BVH tree.
I can replicate blender’s BVHTreeFromMesh and its population logic. But, BVH is a heavy data-structure and constructing it is a very expensive thing. Every mesh in Cycles already has its BVH, I would like to do ray-cast with Cycles using Cycles BVH.
Can you please give some clue how to do it?
Thanks in advance.