Bump mapping in optix 6.0

Bump mapping, spec mapping often be included in many scenes’ materials. How can I get the triangle information of the current hit point in the close hit function to calculate the tangent and Btangent directions? I load the mesh by OptixMesh.

OptiXMesh sponza_mesh;
	sponza_mesh.context = context;
	loadMesh("D:\\MyDocument\\BackUP\\sponza\\sponza.obj", sponza_mesh);
	for (size_t i = 0; i < sponza_mesh.geom_instance->getMaterialCount(); ++i) {
		sponza_mesh.geom_instance->setMaterial(static_cast<int>(i), sponza_mat[i]);
	}

My optix version is Optix 6.0, win10, P4000 graphics card.

I found relevant questions in the forum, but I still didn’t find a good way. I found optixPrimitiveIndexOffsets in the samples of the SDK, which seems to redefine something about mesh. Should I load the model in a similar way instead of OptixMesh?

Hi YuSHan,

In OptiX 6, I think the functions you are looking for are:

rtGetPrimitiveIndex() and rtGetTriangleBarycentrics()

https://raytracing-docs.nvidia.com/optix6/guide_6_5/index.html#host#triangles
https://raytracing-docs.nvidia.com/optix6/guide_6_5/index.html#programs#semantics

And in OptiX 7, you have:

optixGetPrimitiveIndex(), optixGetTriangleBarycentrics(), and also optixGetTriangleVertexData() if you need it.

https://raytracing-docs.nvidia.com/optix7/guide/index.html#acceleration_structures#primitive-build-inputs
https://raytracing-docs.nvidia.com/optix7/guide/index.html#device_side_functions#triangle-mesh-random-access


David.