0

Yesterday, I started looking into ray-tracing, and it seems that there are many algorithms for redering spheres and other common shapes. However, I want to be able to render an arbitrary 3D shape defined by an arbitrary multivariate function.

The problem seems to be in the ray intersection algorithm: if the equation of a shape is known, then the equation to solve for the intersection points of the shape and the ray can in a sense be "pre-computed" and then solved for at run time. If the equation of the shape is not known at compile-time, then the equation to solve for the intersections will have to be constructed at run-time. Thus, it appears that a symbolic algebra system must be in place for this to actually work, which seems a little overkill.

I know that I can just find the polygonal representation of the shape, but I don't want to do this; at that point I might as well do rasterization instead of ray-tracing. Is it at all possible to do ray-tracing with arbitary multivariate functions?

This question may be trivial, but I haven't found too much when researching this question, nor do I know enough about ray tracing yet to answer my own question. Thank you to all that answer.

William Ryman
  • 231
  • 2
  • 9
  • 1
    https://en.wikipedia.org/wiki/Signed_distance_function? – David Eisenstat Oct 23 '22 at 19:17
  • 1
    @DavidEisenstat: For a useful ray caster you also need to be able to determine the surface normal (see https://en.wikipedia.org/wiki/Normal_(geometry) ); so that you can figure out the direction of "secondary rays" for reflection and refraction. – Brendan Oct 24 '22 at 02:33
  • 1
    partial derivates will give you tangents so normal should not be a problem... You can fit the solution using [Approximation search](https://stackoverflow.com/a/36163847/2521214) so no need for algebra however it will be a lot slower. Another option is convert your shape equation to SDF if possible and then use SDF based ray tracing algorithms. Also you can convert your function to taylor (or different) series which is simple polynomial easy to handle the algebraic even without algebra engine – Spektre Oct 24 '22 at 07:10
  • 1
    I built one opengl shader for multivariate polynomials today https://math.stackexchange.com/questions/3752021/how-to-calculate-intersection-between-line-and-algebraic-level-set Just as MvG writes below, each ray is a line that parametrizes into a one variable function at each pixel. We can attack it by normal one variable optimization techniques such as Newton Rhapson root finder. – mathreadler Mar 28 '23 at 18:08

1 Answers1

1

I've heard talks about how images like https://www.imaginary.org/gallery/herwig-hauser-classic or https://www.imaginary.org/gallery/oliver-labs would get rendered.

When shooting a ray the multivariate polynomial becomes univariate, parameterized along the direction of the ray. Now you would be looking for a root of this polynomial, more specifically the root with the smallest positive real parameter, corresponding to the first intersection in front of the camera. Sturm sequences were playing a role in that, if I recall correctly. Once the root has been found, the gradient of the multivariate polynomial will indicate the normal direction so you can do lighting based on that.

I don't know whether any general purpose ray tracing software would handle algebraic varieties like this. There is some specialized software out there. The one used for the images referenced above was called SURFER. There also was a GPU-based version I heard describes in a talk. I'm not quite sure whether they would be doing full ray tracing or just ray casting.

MvG
  • 57,380
  • 22
  • 148
  • 276