2023-02-24 01:12:51 +00:00
|
|
|
RayHit trace(inout Ray ray)
|
2021-08-10 01:11:22 +01:00
|
|
|
{
|
|
|
|
RayHit hit = createRayHit();
|
|
|
|
|
2023-02-23 00:00:25 +00:00
|
|
|
// floor
|
2021-08-10 01:11:22 +01:00
|
|
|
intersectPlane(ray, hit, vec3(0.0,-1.5,0.0),vec3(0.0,1.0,0.0));
|
|
|
|
|
2023-02-23 00:00:25 +00:00
|
|
|
// spheres
|
2021-08-10 01:11:22 +01:00
|
|
|
for (int i = 0; i < _activeSpheres; i++)
|
|
|
|
{
|
|
|
|
intersectSphere(ray, hit, _spheres[i]);
|
|
|
|
}
|
|
|
|
|
2023-02-24 01:12:51 +00:00
|
|
|
ray.distance += hit.distance * float(hit.distance < INF);
|
|
|
|
|
2021-08-10 01:11:22 +01:00
|
|
|
return hit;
|
|
|
|
}
|