2023-02-24 02:12:51 +01:00
|
|
|
RayHit trace(inout Ray ray)
|
2021-08-10 02:11:22 +02:00
|
|
|
{
|
|
|
|
RayHit hit = createRayHit();
|
|
|
|
|
2023-02-23 01:00:25 +01:00
|
|
|
// floor
|
2021-08-10 02:11:22 +02:00
|
|
|
intersectPlane(ray, hit, vec3(0.0,-1.5,0.0),vec3(0.0,1.0,0.0));
|
|
|
|
|
2023-02-23 01:00:25 +01:00
|
|
|
// spheres
|
2021-08-10 02:11:22 +02:00
|
|
|
for (int i = 0; i < _activeSpheres; i++)
|
|
|
|
{
|
|
|
|
intersectSphere(ray, hit, _spheres[i]);
|
|
|
|
}
|
|
|
|
|
2023-02-26 03:50:32 +01:00
|
|
|
Sphere s;
|
|
|
|
s.cr = vec4(0.0,0.0,0.0,INF*2.0);
|
|
|
|
s.material = MAT_GLOW;
|
|
|
|
s.albedo = vec3(1.0,1.0,1.0);
|
|
|
|
intersectInsideOutSphere(ray, hit, s);
|
|
|
|
|
|
|
|
//ray.distance += hit.material == MAT_CHROME
|
|
|
|
// ? hit.distance * length(ray.energy) * float(hit.distance < INF)
|
|
|
|
// : hit.distance * float(hit.distance < INF);
|
|
|
|
//ray.distance += hit.distance * float(hit.distance < INF);
|
|
|
|
ray.distance += hit.distance;
|
|
|
|
//ray.distance = clamp(ray.distance, 0, INF);
|
|
|
|
//ray.distance += hit.distance * length(ray.energy);
|
2023-02-24 02:12:51 +01:00
|
|
|
|
2021-08-10 02:11:22 +02:00
|
|
|
return hit;
|
|
|
|
}
|