raytracing bezier patches..

Practical and theoretical implementation discussion.
Post Reply
Posts: 10
Joined: Sun Nov 03, 2013 3:56 pm

raytracing bezier patches..

Post by AlbusDumbledore » Thu Nov 07, 2013 4:17 pm

You know the Newell teapot (also called a utah teapot), somewhat ugly thing, but good as an example of object. As far as I know it originally was designed as a set of bezier patches or something (about 25 or something like that).
What exactly is the best kind ot 'patch' tu use here? is it a bezier path based on
rank 3 bezier curves? How many floats is needet to make such patch? Is it very hard to wrote raytracer for that? Patch-ray intersection test routine would be needed.
I had read here one man who wrote a raytracer for quadrics but quadrics as I understand are not to much good here it would be need to get rank 3 patches i think..

Posts: 89
Joined: Thu Apr 11, 2013 5:15 pm

Re: raytracing bezier patches..

Post by friedlinguini » Thu Nov 07, 2013 5:33 pm

It's typically defined as a set of bicubic Bezier patches, which is about as simple as general-use parametric patches get. The easiest way to deal with them is to tessellate the patches into triangles and render those. Alternatively you could try tracing the patches directly. There are a few ways to do this, but they generally involve recursively subdividing the patch.

For example, you could find the bounding box of the sixteen control points of the patch. If your ray misses the box, then it is guaranteed to miss the patch. If it hits the box, and the box is smaller than some threshold, then treat it as a hit, and you find the normal from one of the corner control points and its two neighbors. If you hit the box, but the box is larger than the tolerance, then subdivide the patch into 4 smaller patches using de Casteljau subdivision, and then repeating on the four smaller boxes.

There are a lot of variations on these themes (subdivide to some level on demand, then tessellate, define the ray as two intersecting planes, and then split based on whether the control points of a patch straddle both planes, etc.). Personally, I'd get a spatial subdivision structure implemented--you mentioned in another thread that you didn't have one yet--and just go with the triangles.

Posts: 167
Joined: Mon Nov 28, 2011 7:28 pm

Re: raytracing bezier patches..

Post by graphicsMan » Thu Nov 07, 2013 5:35 pm

Google is your friend :) There are research papers describing how to ray tracing bezier patches and NURBS surfaces. The order of the patches can be 3 or anything else you decide. 3 ensures C^2 continuity across the patch, and it is possible to model many surfaces such that you can achieve that continuity at patch boundaries (by aligning nieghboring patch knot vectors). I think that going much higher than 3 will not yield visible differences, but I've never seen a perception study about that. Going less than 3 will probably yield artifacts.

Posts: 2
Joined: Fri Apr 26, 2013 7:50 pm

Re: raytracing bezier patches..

Post by ginkgo » Thu Nov 07, 2013 10:31 pm

The Newell teapot is composed of 32 bicubic bezier patches.

You can find the original dataset here. It's a simple text format that should be easy to parse. It also contains a spoon and teacup model.

Posts: 56
Joined: Wed Dec 21, 2011 6:08 pm

Re: raytracing bezier patches..

Post by hobold » Sun Nov 10, 2013 11:38 am

Bezier spline patches have been in use in graphics for a while, so they are well understood. I wouldn't say that they are the best known type of curved surface, because "best" can mean different things to different people. If you are starting from scratch, you might want to look into subdivision surfaces as well. They intuitively behave much like Bezier patches, but have fewer restrictions on the placement of their control points.

GraphicsMan's points about the degree of smoothness (i.e. how often the mathematical representation can be continuously differentiated) are important for the visual appearance. Surface models that are not continuously differentiable (C^0, e.g. the usual flat triangles) result in objects that are obviously faceted, so they can look somewhat crystalline.

Surfaces that are differentiable once (C^1) will look much smoother (their silhouettes in particular), but still have obvious weird artifacts especially with highlights and other reflections:

Starting with twice differentiable (C^2), surfaces will begin to mostly flow harmoniously, and only exhibit subtle flaws under specific, rare circumstances.

Posts: 56
Joined: Wed Dec 21, 2011 6:08 pm

Re: raytracing bezier patches..

Post by hobold » Sat Aug 09, 2014 9:53 am

Pardon the late reply. Finally got around to doing an illustration of surface smoothness, showing the range from piecewise constant to twice continuously differentiable. Lighting and texturing also have strong effects on perceived smoothness that are being shown. If you are interested see:


Post Reply