OptixInOneWeekend
OptixInOneWeekend copied to clipboard
"negative radius" support in sphere
thanks for sharing this project code.
what I describe is not a problem per se, but allows a sphere with a negative radius to get a valid bounding box.
// sphere.cu
RT_PROGRAM void getBounds(int pid, float result[6])
{
optix::Aabb* aabb = (optix::Aabb*)result;
- aabb->m_min = center - radius;
- aabb->m_max = center + radius;
+ aabb->m_min = center - abs(radius);
+ aabb->m_max = center + abs(radius);
}
// scene.h
{
geometryList.push_back(new ioSphere(x,y,z, 0.2f));
materialList.push_back(new ioDielectricMaterial(1.5f));
+ geometryList.push_back(new ioSphere(x,y,z, -(0.2f-0.007f)));
+ materialList.push_back(new ioDielectricMaterial(1.5f));
}
This allows, for example, dielectric nested spheres to appear similar to a bubble. I have made this change and it works as expected.
https://github.com/idcrook/weeker_raytracer/blob/edd68e9dbaddee2d34388ed2cbcf9b28ecbcc573/src/OptiX/TheNextWeek/geometry/sphere.cu#L30-L31