What is the most efficient way to perform ray tracing with a surface that you know the formula for?

Triangle mesh ray tracing has well-known solutions and many resources. There is a related issue with ray tracing for surfaces with known parametric formulas such as:

S(u,v) = (cos(u), sin(u), v)

      

What is a z-aligned unit cylinder. My question is, what's the most efficient way to apply ray tracing to this surface? The obvious solution would be to generate approximate grids from formulas and then apply ray tracing, but my question is if there is a best fit solution for this particular case - specifically by applying a kind of polynomial solver on demand.

+3


source to share


1 answer


When you mention a polynomial solver, it sounds like you are basing things on an implicit algebraic description of a surface. So in your situation, you will get rid of the trigonometric functions by using tangential semi-angle replacement :

((1-u^2)/(1+u^2), 2*u/(1+u^2), v)

      

Then you would turn this into a set of polynomial equations in x,y,z

:

(1-u^2)/(1+u^2) - x = 0
    2*u/(1+u^2) - y = 0
              v - z = 0

      

You can exclude u

and v

from these equations, for example. using resultants .



As a result, you will receive

x^2 + y^2 - 1 == 0

      

which comes as no surprise since this is your top hat. But the above approach will work on other parameterized surfaces as well. Then you can take your ray of light and, assuming the source is a camera lens, write a point on that ray as Ξ»d, where d is the direction of the ray. Plug this point into the equation, solve for Ξ», find the smallest positive solution, and you have the point where the ray crosses the surface. Also, compute the gradient of the implicit equation at that point and you have a normal surface.

I don't know how much this approach is actually used in practice. Afair most ray tracer are mesh-based for most but the most basic geometry primitives, but this may be outdated information. Of course, this will be a useful approach if you want to avoid CPU heavy mesh generation and replace it with high performance, real surface high performance computing.

There are tools such as Surfer and its descendants that render algebraic surfaces described by implicit equations as their sole target. They tend to do a lot of quirky things, especially good at handling features like very thin spikes protruding from such a surface. I've used this tool myself, for example. to illustrate this answer . However, the Surfer doesn't have a complex reflection and lighting model, so it only does ray casting.

+2


source







All Articles