API related to triangle mesh

Long time no see. I am always indebted.
Currently, I am thinking about the implementation of ray and triangle intersection in optix6.0.
The memory is ambiguous, but I heard that API is prepared for the intersection of triangle and ray.
I can’t find it if I look for it, so if you have a sample, please let me know.

Also, if it exists, is it faster to use the API than to write an about the triangle yourself?

OptiX 6.0.0 added the GeometryTriangles functions which handle that.

Find docs about that here:
https://raytracing-docs.nvidia.com/
https://raytracing-docs.nvidia.com/optix6/guide_6_5/index.html#host#triangles
https://raytracing-docs.nvidia.com/optix6/api_6_5/html/group___geometry_triangles.html

There is an example in the OptiX 6.x SDKs named optixGeometryTriangles especially demonstrating that.
The SDK examples using the OptiXMesh helper class are also automatically using GeometryTriangles.

On RTX boards the built-in triangle intersection is way faster because it’s done by the dedicated hardware RT cores.
Using the GeometryTriangles functions is also recommended if you use triangles on non-RTX boards.

That said, I would really recommend to port to OptiX 7.0.0 though, which has a completely different but much more modern and explicit multi-threading safe API, where none of the previous CUDA interop issues are present because the host application is effectively a CUDA application. It’s refreshingly flexible.
https://raytracing-docs.nvidia.com/optix7/index.html
https://raytracing-docs.nvidia.com/optix7/guide/index.html#acceleration_structures#primitive-build-inputs

Thank you for the quick reply!
I would like to make it based on your answers.
OptiX 7.0 is very attractive, but I don’t have much time now, so I’ll update it later.

Hello. I tried using the function.
I have some questions, so let me ask you a question.
Currently, I read an STL model that describes triangle polygon data, and I am examining the intersection of rays and triangles for that data.

The first question.
Is it absolutely necessary to set an index and register a normal vector using <setTriangleIndices ()>?
I don’t think it is necessary if I don’t need to use it in .

This is the second question.
If I give a triangular polygon model to the class, I think that a box containing the model is automatically generated. I want to know if the box is single or if it is divided internally into multiple layers.

No, that’s all the developer’s responsibility to decide what an OptiX application requires.
Non-indexed triangles and indexed triangles are explained here: https://raytracing-docs.nvidia.com/optix6/guide_6_5/index.html#host#triangles
You also don’t need to provide any normals if your specific OptiX program implementation can work without.

The acceleration structure (AS) is a bounding volume hierarchy (BVH) of axis aligned bounding boxes (AABB).

For custom primitives you as a developer must implement the bounding box program to calculate the AABB around the individual geometric primitives.
https://raytracing-docs.nvidia.com/optix6/guide_6_5/index.html#programs#specifying-bounding-boxes

For GeometryTriangles OptiX does that with a built-in program internally.

The AS build happens on the next launch after the AS has been marked dirty automatically or manually.

That BVH is built over the spatial structure of these leaf AABBs to get a fast hierarchical acceleration structure which speeds up the BVH traversal to find the closest intersection. You could call that hierarchy “layers” if you like.
How that AS works internally is abstracted by OptiX and has changed multiple times over different OptiX versions.