I’m trying to implement an algorithm for which i need a z-buffer for each source source, and I’ve run into some strange behaviour i don’t understand.
I’ve implemented a closest hit-function and a ray generation program as below, and assigned the ray generation program to an entry point, and the closest hit-program to a ray type, which i set from the host before launch.
When i launch using this ray generation program, all rays miss. When i use a slightly different ray generation program (that i usually use for different rays, which need to be iteratively traced), they don’t. However, when checking the origin and direction of the rays in the miss-program, they are the same.
I’ve really run out of ideas - is there some reason my hit program could silently fail to be loaded? The documentation mentions that there is a default no-op closest hit-program, which i guess might explain the behaviour.
And of course, i might just have stared at the code for to long, and be missing something obvious :)
RT_PROGRAM void depthmap_hit() {
depth_map_buffer[make_uint3(launch_index,source_id)] = t_hit;
}
RT_PROGRAM void depthmap_ray_gen() {
float3 U = make_float3(1, 0, 0);
float3 V = make_float3(0, 0, 0);
float3 W = make_float3(0, 1, 0);
float2 d = make_float2(launch_index) / make_float2(launch_dim) * make_float2(2.0f * M_PIf, M_PIf) + make_float2(M_PIf, 0);
float3 angle = make_float3(cos(d.x) * sin(d.y), -cos(d.y), sin(d.x) * sin(d.y));
float3 ray_origin = eye; //set to camera position before launch
float3 ray_direction = normalize(angle.x*normalize(U) + angle.y*normalize(V) + angle.z*normalize(W));
PerRayData_depth prd;
optix::Ray ray = make_Ray(ray_origin, ray_direction, ray_type, scene_epsilon, RT_DEFAULT_MAX);
rtTrace(top_object, ray, prd);
}