Page 1 of 1

raytracing bezier patches..

Posted: Thu Nov 07, 2013 4:17 pm
by AlbusDumbledore
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..

Re: raytracing bezier patches..

Posted: Thu Nov 07, 2013 5:33 pm
by friedlinguini
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.

Re: raytracing bezier patches..

Posted: Thu Nov 07, 2013 5:35 pm
by graphicsMan
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.

Re: raytracing bezier patches..

Posted: Thu Nov 07, 2013 10:31 pm
by ginkgo
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.

Re: raytracing bezier patches..

Posted: Sun Nov 10, 2013 11:38 am
by hobold
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.

Re: raytracing bezier patches..

Posted: Sat Aug 09, 2014 9:53 am
by hobold
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: