0
\$\begingroup\$

As an example, suppose we are trying to ray-trace a sphere. There are two options. The first one is to build a mesh of triangles approximating the sphere and ray trace it. Unfortunately, the more triangles we have, the more expensive this computation will be, because we need to call the rayTriangleIntersect() once for each triangle. For the specific case of a sphere, though, there is a better way to do it: we can use a raySphereIntersect() function, generated by solving the equation of the ray with the equation of a sphere, x^2 + y^2 + z^2 = R^2. This requires only one call and is, thus, much less expensive.

My question is: is it possible to apply the same optimisation for different shapes? I.e., is there a technique to generate a surface that approaches certain mesh, allowing us to implement a specialised rayIntersection() function for that surface?

\$\endgroup\$
  • 1
    \$\begingroup\$ It sounds like you might want to look into raymarching with signed distance fields. \$\endgroup\$ – DMGregory Jan 16 at 16:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.