Hi, I have two questions but they are not completely unrelated. I very much would appreciate to have an answer for the first one.
- I want to find out what is the most appropriate API for developing what I want (prime or not)
I have a mesh made of triangles only.
Looking at the SDK tutorial and samples, I found out that the any_hit and closest_hit are very convenient for the ray operation I want to do (monte carlo sampling).
However, for doing that I need to access the coordinates of my mesh during the any_hit / closest_hit programs (I need uniform sampling on the surface of each triangle). I saw some examples where I can pass the coordinates of the vertex through buffer. However, I did not find any way to access the id of the triangle inside the any_hit / closest_hit programs.
If I do not get that information, there is no way I can access the correct vertex information. (Or am I wrong ?) So my question are:
Q1a) how can I access the id of the triangle that the ray hit in the any_hit routine ?
Q1b) how can I access the id of the triangle that is the closest to the hay in the closest_hit routine ?
I know Q1a) and Q1b) are not relevant if I use optix prime (I had a look at the prime* examples, there as a structure with the triaId) but it looks far less flexible. Since I need to also store data related to each triangle during the any_hit operation, I definitely need the triangle id.
- I have a question regarding the way optix works and I have two idea for the implementation of what I want to do.
Approach 2a): analytical sampling
- Starting from an initial triangle, a ray is going to intersect another triangle
- at the point of intersection, multiple (typically 1000) other ray are going to be generated with less weight (and other operation on ray or intersecting triangle)
- the ray stops when its weight (or depth level) is less (or more) than a value
This method uses quite recursive.
I estimate the number of time the number time a ray is going to generate other ray to be about 10 in average, but it will diverge very significantly.
So my question is:
Q2a) If the multiple number of reflections for one thread is 100, will the other have to wait for that thread to finish so all the other ones starts the full sequence again ?
Approach 2b): sampling using random number
- Starting from an initial triangle, a ray is going to intersect another triangle
- at the point of intersection, the ray is going to be reflected, the direction being based on a probability, but with less weight (and other operation on ray or intersecting triangle)
- the ray stops when its weight (or depth level) is less (or more) than a value
This method is far less recursive.
So I assume I need a stack size which will be smaller so I will be able to launch much more thread (?), also Optix will be faster (?)
The advantage of the method 2a) is that I can actually express in an analytical way all the reverse sample distributions I want so I do not really need random number sampling and I will converge faster toward an accurate solution than with method 2b)
The disadvantage is that I am afraid the speed will be limited by the big stack requirement and the fact I can launch less threads at the same time on my GPU (?)
Am I correct with my affirmations ? please correct me if I am wrong
Eventually my question is: which one of the two method is going to be faster ? I assume the only way to answer my question is to implement both methods. But if there is an obvious answer I would like to know.