VIII. Visibility algorithms (II)
Hybrid algorithsms: priority list algorithms Find the object visibility Combine the operations in object space (examples: comparisons and object partitioning) with operations in image space (example: scan conversion) The list of sorted objects is computed with the object precision => correct redrawing to any resolution
Depth sorting algorithm = Pictorial algorithm, Newell-Newell-Sancha alg. Assume a polygonal network representation Stages: 1. Sort the polygons in the increasing order of the minimum value of z of the vertices (sorting in object space) 2. Solve the ambiguities produced by the superimposing of z extensions (eventually polygonal partition; comparisons in image space) 3. Draw the polygons in the increasing order of the minimum values z of the vertices
Depth-sort algorithm 5 levels of testing for the second stage:
Depth-sort alg stage 2 (T4) Q in the same part with the observer relative to plane P => L=(,P,Q, ) otherwise (T5) (T5) The projections of P and Q are not intersection => L=(,P,Q, ) otherwise (T3 ) (T3 ) (T3) with inversed roles for P and Q (T4 ) (T4) with inversed roles for P and Q Otherwise Find the intersections edge by edge Replace the polygons in the list with its components
Example 1 (a) (T3) false, (T4) true; (b) (T3) true
Depth sort example 2 (a) (T3 ) is true (b) tests failed (c) mark a polygon to avoid infinite cycling due to the tests
Polygon positions
Depth sort algorithm
Depth sort algorithm
Alg. using binary tree for spatial patitioning (BSP) Recommended when the observer position is changing Idea: object group that is on the same side with the observer relative to the plane of a polygon can hide, but cannot be hidden by, other groups Partition the scene: tree BSP with internal nodes planes, terminal nodes space regions
BSP
BSP
BSP
Tree crossing Inorder to establish the polygon drawing priority (if the observer is in the frontal plane of the root, in an inversed order otherwise)
Ray-tracing algorithm Draw the visual rays (parametric) from the observer to the scene objects The window is divided: rectangular grid Assume the objects are opaque => each element from the grid is colored with the color of the first object that is intersected by the ray
Ray-tracing
Ray-tracing
Ray-tracing
Ray tracing algorithm select the projection center and the window from the projection plane for each scan line of the image do for each pixel of the scan line do find the ray from the projection center to the pixel for each object from the scene do if the object is intersected and is the closest until now then retain the intersection and object id set the pixel color to that of the closest object
Ray-tracing - problems The quantity of intersections to be checked Example: image 1024 x 1024 and 100 objects => 100 Mb for the intersections Solutions: 1. Optimize the intersection computations 2. Avoid the intersection computations
Optimize the intersection computations Bounding volume = convex polyhedron defined by plane pairs that enclose the object The ray does not intersect the bounded volume => the ray does not intersect the object The bounded volume is built such that the computations of the intersections between the ray and the volume are much easier to be done than the intersection with the object
Bounding volume and hierarchy
Bounding volumes
Avoid intersection computations Using pre-processing techniques for partitioning rays or objects in classes. These techniques are using: 1. Hierarchy 2. Partitioning 3. Modeling objects with CSG
Hierarchy Example: hierarchy of bounding volumes with the scene objects at the terminal nodes and the bounding volumes as internal nodes The ray is not intersecting a certain bounding volume => the ray is not intersecting the volumes of the children Organize the objects from details towards general
Hierarchy
Partitioning The volume that bounds the entire scene is divided in equal subvolumes Organizing from general to details Each partition has a list of contained objects Find the partitions that are passed by the ray Find the intersections of the ray with the objects from the traversed partitions Test the inclusion of the intersection to that partition
Partitioning To avoid the intersection computations with the same object in different partitions it is maintained a list of the intersections depending on the object In the case of non-uniform distribution of the objects it is necessary an adaptive partitioning (example: octrees) Partitioning + hierarchy => hierarchy with lists or 3d grids as the internal nodes
Partitioning
Static or adaptive partitioning
Static or adaptive partitioning
Hierarchical partitioning
Hierarchical partitioning
2d or binary partitioning
2d or binary partitioning
Modeling objects using CSG The intersection of the ray with the objects = dividing [0,1] in subintervals for t for which the ray is in/out of the object The object is obtained using Boolean operations => subintervals t are obtained applying the same operations on the intervals corresponding to the intersections with the primitives
Modeling objects through CSG
Supra-sampling The spatial aliasing appears if the sampling network has an insufficient resolution Solution: supra-sampling = usage of two or more rays that are corresponding to the same pixel the final color of the pixel is a men value Remark: the ray multiplication for 1 pixel with n leads to an increase of computational time x n
Supra-sampling
Supra-sampling variants Supra-sampling with rays that are passing through fixed positions (example: corners or the center of the area that represent the pixel) Stochastic supra-sampling (random arrays) Adaptive supra-sampling: Initial representation using 5 rays If the colors of the rays are close, compute the mean value Otherwise subdivide the aria in smaller regions and repeat the step for the new regions
Adaptive supra-sampling
Supra-sampling
Adaptive supra-sampling
Ray intersection with a sphere
Ray intersection with a sphere
Ray intersection with a sphere
Ray intersection with a sphere
Ray intersection with a sphere
Ray intersection with a sphere
Ray intersection with a plane
Ray intersection with a plane
Ray intersection with a parallelepiped Useful: compute intersections with bounding volumes
Ray intersection with a parallelepiped
Ray intersection with objects
Comparisons between visibility algorithms Criteria Sorting Coherence Efficiency Visualization Algorithm Depth-sort algorithm Scan-line algorithm Warnock s algorithm Z-buffer algorithm Scan-line algorithm Area subdivision algorithm Z-buffer algorithm Depth-sort algorithm Z-buffer algorithm Warnock s algorithm Scan-line algorithm Z-buffer algorithm BSP algorithm Case Zxy algorithm Yxz algorithm (xy)z algorithm (xyz) algorithm Line coherence Area coherence Depth coherence For small number of polygons Relative const.to the polygon no.variation Complex tests and computations Shadow or primitive chnging Interactive visualization system Static scene, mobile observer
Comparisons between algorithms