A Border-Stable Approach to NURBS Surface Rendering for Ray Tracing

Ray tracing has become a popular method for generating high quality images. Most of the modern ray tracing based applications only deals with triangles as basic primitives. NURBS surface representation is common for most of 3D modelling tools because of its compactness and the useful geometric properties of NURBS surfaces. Using the direct ray tracing of NURBS surfaces, one can achieve better quality of rendered images [1]. There are many approaches to solving this problem.


Introduction
Ray tracing has become a popular method for generating high quality images. Most of the modern ray tracing based applications only deals with triangles as basic primitives. NURBS surface representation is common for most of 3D modelling tools because of its compactness and the useful geometric properties of NURBS surfaces. Using the direct ray tracing of NURBS surfaces, one can achieve better quality of rendered images [1]. There are many approaches to solving this problem.
In 1982 Kajiya [5] used ideas from algebraic geometry to obtain a numerical procedure for intersecting a ray with a bicubic surface patch. His method is robust, not requiring preliminary subdivisions to satisfy some a priori approximation. It proceeds more quickly for patches of lower degree. The algorithm is simply structured and does not require memory overhead. But unfortunately the algorithm has many disadvantages. It does not significantly utilize coherence. The algorithm computes all intersections of the given ray with a surface patch, even if just closest intersection need to be found. And finally the algorithm performs enormous amounts of floating point operations. Kajiya estimates that 6000 floating point operations may have to be performed in order to find all of the intersections between one ray and one bicubic patch. In the modern ray tracing applications global illumination algorithms are commonly used, and million of rays can be tested against one parametric patch. It makes the proposed algorithm unpractical [2].
T.Nishita, T.W.Sederberg, and M.Kakimoto [7] described methods crossing for problem solution in star -rational Bezier surface. This method was called Bezier clipping. This method can be classified as an algorithm partly based on division and partly as calculation method. After ray representation as crossing of two planes, ray -surface crossing problem can be projected from 4D space to 2D space. This method reduces the number of arithmetical operations which is necessary to perform de Casteljau subdivision with 50% in every subdivision iteration. Nishita highlighted that Bezier cutting idea can be successfully applied in cases when we need to resolve problem of cropped region estimation. At the same time Nishita noted that described method does not resolve some tasks, one of them being the frequent point search problem and the instability of the method in some surface special cases.
W. Martin et al. [6] proposed a method for reverse NURBS surface visualization in ray tracing. Using node vector processing for generating hierarchic structure of limited space, as a result tree depth declines in comparison with other subdivision methods. The idea is to S.W. Wang, Z.C. Shih and R.C. Chang [11] proposed an algorithm that combines Bezier cutting algorithm and Newton iterative algorithm in order to create effective method for ray coherence application. The first intersection point of the running ray with the Bezier surface is calculated using Bezier iterative algorithm. All following intersection points in the same pixel row are calculated using Newton iterative algorithm. The last calculated intersection point is used as previous result for the following intersection point. The device for barrier detection is used to check-up whether the intersection point that is calculated using Newton iterative algorithm is the last point. When Newton's method is not achieving convergences, then Bezier cutting is used as a replacement for calculating the intersection point.
A. Efremov, V. Havran and H.P. Seidel [1] and [2] proposed the method for NURBS surface visualization in ray tracing using following method: object's every NURBS surface is transformed into equivalent rational set of Bezier surface and exactly this set is mapped. To solve rational Bezier surface problem Bezier cutting method, that is described in [7], is used. And, also [1] and [2] proposes some modifications that improve the activity and effectiveness of Bezier cutting method.
Schollmeyer and Froehlich [9] describe an approach for NURBS surface ray tracing, where surface trimming is used to set of monotonic Bézier curves. For finding of intersection point the bisection method is used. But in this case, the number of calculations increases too.
In particular and NURBS surface is extensively used in computer graphics and computer aided design. Unfortunately, most of the algorithms for intersecting rays with parametric surfaces are expensive or have problems in some special cases. Therefore, most of modern ray tracing applications tessellate parametric surfaces into triangles during the preprocessing step of image generation. Such approach significantly increases computation speed, but can compute wrong images (if tessellation was not good enough) and requires additional memory for storage of generated triangles. Therefore, the problem of finding fast and robust algorithms for ray tracing parametric surfaces is still opened research issue [2]. This paper presents an effective approach for finding ray -NURBS surface intersection points, which are used for high-quality visualization of NURBS surfaces.

Ray-Surface Intersection problem
The mathematical task of finding an intersection point between the ray and a parametric surface can be described as a nonlinear equations system [6]: A NURBS surface patch in Cartesian 3D space can be formulated as [3,8]: ,, , where: , , p q -are the B-spline polynomials degree; , uv -are the parameters.

Projection to R 2
Typically calculation is performed in R 3 for non-rational patches and in R 4 for rational [7].
Transforming the computation from 3D space to 2D space is important technique to reduce the comparison cost of finding ray-surface intersection point. Woodward [12] (also alluded to by [6]) shows how the problem can be projected to R 2 . This means that the number of arithmetic operations to calculate a rational patch is reduced by 25%. This approach is used in [7] for rational Bezier patch subdivision. But this approach is good for other parametrical surface patch calculation by ray tracing too. In case of NURBS surfaces, the task of raysurface intersection point search is transformed to the problem of non-linear equations system solving: where: (,) , (,) XY Su vSu v -are the surface equations on the projection plane, , RR xy -is the ray projection.
The system (3) solving task is divided into two parts: preprocessing with root preliminary search and iterative root finding.

Preprocessing
Other color values in gradient texture interpolate evenly and are put on the surface. The next task is to read data from the color map. Hence, it is proposed to develop preliminary value map in order to find preliminary parameters a u and v value in each pixel. The map is composed of surface data that is coded in RGB channels. Red channel includes surface number. Mathematical relation can be described in following way: The map is coded using the OpenGL graphics library. The example of preliminary values map is shown in Fig. 1.
The next task is to read data from the color map. Input data in this case is R, G and B color value in every separate pixel. In this case we can find the preliminary value of parameters in following way: www.intechopen.com The patch number can be calculating from (4) as follows: where: Nr is surface number, which is changing in diapason [0; 254]; R is value of red channel, which is changing in diapason [1; 255].

Intersection test
The Newton iteration [10] can be used for solving system (3) solving. In this case, an iteration step takes the form: where matrix for inversion can be calculated as follows: www.intechopen.com The equation (8) can be described as follows: The increment matrix can be described as follows:

Proposed approach
The NURBS patch surface equation on the projection plane can be described as follows: The equation (11) can be described is as follows: How is can to see from (21) the increment matrix can describe the solving of next system of linear equations: In this case the increment matrix (21) is partial solving of system of linear equations by Cramer rule and can be found as follows: For practical implementation can be better the Gaussian elimination use. In this case the system of linear equations can be described as extended matrix: In this case the restriction is big number of division operator using.

Border criteria
As known the NURBS surface parameters is defended in diapason, what can be described as follows: In the process of the iterative procedure there can be a situation, that new parameters values is outside of diapason from (23). This case is showed in Fig. 2.
In this case the correction of the result is necessary. This task is divided into two parts: parameter v correction using parameter u border and the next step is parameter u correction using parameter v border. ; uv   . Otherwise, the second correction step is necessary.
Second step can be described by analogy with the first step. The parameter v correction can be described as follows: And the next step, parameter u correction, as follows:

Termination criteria
In this work, five criteria are used to decide when to terminate the Newton iteration. This criterion is analogical to termination criteria in work [6] and [13].
The first condition is the success criterion: if we are closer to the root than some predetermined  1 then we report an intersection: But in (25) is necessary to use next success criterion: if we are closer to the root values increment then some predetermined  2 and  3 : It possible report an intersection point determination if is correct first or second termination criteria. Otherwise, we continue the iteration. The other three criteria are failure criteria, meaning that if they are met, we terminate the iteration and report a miss.
We do not allow the new (u i+1 , v i+1 ) estimate to take us farther from the root then the previous one: A maximum number of iteration steps has been performed, also indicating divergence:

Experimental results
In this work the proposed method, as well as the methods suggested by Martin et al. were implemented. In order to visualize a scene the 1 ray/pixel approach was used. The size of the obtained image is 512x512 pixels. 4 scenes were visualized during the experiment: the first scene -duck that what is taken from VRML programming language standard examples, the second scene visualized experimental object from the first scene, in total 27 VRML ducks, the third scene visualized experimental object -mobile phone and the fourth scene visualized practical object -modelled machine component.
All surfaces of experimental scenes were described with the help of NURBS surface. Achieved images were shown in Fig. 4 As it is possible to see from these figures the proposed method gives an advantage on quality of the images (there's no distortion on the borders of patches). Image rendering time is shown in  Table 3.

www.intechopen.com
As we can see from Table 3 data the proposed method gives stable visualization time reduction (compare with existing methods) in experiment. Table 3 proves that proposed method gives  time reduction 13,3   The next experiment that was conducted in order to check-up the described experiment is the comparison with existing CAD system. A comparison with Autodesk AutoCAD 2010 system was conducted. "Machine element" was chosen an object's example. To conduct object's visualization in CAD system Autodesk AutoCAD 2010 this object was made with NURBS surfaces in visualization programs and was imported to Autodesk AutoCAD 2010.
To ensure correct comparison the object was colored in one color and equivalent lightening settings were adjusted. Fragments that were made larger in the visualization result, are shown in Fig. 9 a) b) Fig. 9. Objects "Machine element" visualization, using: a) proposed method, b) Autodesk AutoCAD 2010 www.intechopen.com From Fig. 9 we can see that the proposed method gives better result regarding image quality, because the object has not any defects on surface borders. Image visualization times in the experiment are following: 1, 89 seconds using proposed method; 10, 24 seconds using Autodesk AutoCAD 2010 visualization. As we can see from given data, proposed method give visualization time reduction in experiment (the difference is 5, 4 times).

Conclusion
In this work an efficient approach to direct NURBS surface rendering for ray tracing is proposed. The proposed approach based on Newton method and Cramer rule combination. The proposed approach, as well as the methods suggested by Martin et al. was implemented.