Constructive Solid Constructive Solid Geometry Ray Tracing CSG

24
Constructive Solid Constructive Solid Geometry Ray Tracing CSG Ray Tracing CSG Models CSE 681

Transcript of Constructive Solid Constructive Solid Geometry Ray Tracing CSG

Page 1: Constructive Solid Constructive Solid Geometry Ray Tracing CSG

Constructive SolidConstructive Solid Geometry

Ray Tracing CSGRay Tracing CSG Models

CSE 681

Page 2: Constructive Solid Constructive Solid Geometry Ray Tracing CSG

CSG

• Form object as booleans of primitive objects– Primitives: sphere, cube, cylinder, conePrimitives: sphere, cube, cylinder, cone– Boolean operators: union, intersection, difference

• Tree structure used to manage operationsf d i i i bj– Leaf nodes are primitive objects

– Intermediate nodes specify combination operator

CSE 681

Page 3: Constructive Solid Constructive Solid Geometry Ray Tracing CSG

UnionB

C +

BC

Min (tCmin, tB

min )Ray intersects union: at first intersection

CSE 681

Page 4: Constructive Solid Constructive Solid Geometry Ray Tracing CSG

Possible ways for 2 spansPossible ways for 2 spans to overlapp

CSE 681

Page 5: Constructive Solid Constructive Solid Geometry Ray Tracing CSG

IntersectionIntersectionB

++C

BC

If ((tCmin< tB

min ) and (tCmax> tB

min ) ): tBmin

Else If ((tB < tC ) and (tB > tC ) ): tC

First time in B and in C

CSE 681

Else If ((tBmin< tC

min ) and (tBmax> tC

min ) ): tCmin

Else: none

Page 6: Constructive Solid Constructive Solid Geometry Ray Tracing CSG

DifferenceDifferenceB

-+C

BC

If ((tBmin< tC

min ): tBmin

Else if (tCmax< tB

max ): tCmax

Else: none

First time in B not in C

CSE 681

Else: none

Page 7: Constructive Solid Constructive Solid Geometry Ray Tracing CSG

DifferenceDifferenceB

+-C

BC

If ((tCmin< tB

min): tCmin

Else if (tBmax< tC

max ): tBmax

First time in C not in B

CSE 681

( max max ) maxElse: none

Page 8: Constructive Solid Constructive Solid Geometry Ray Tracing CSG

PrimitivesPrimitivesA thi th t b i t t d ( il ) ithAnything that can be intersected (easily) with a ray

Conics: solve analytically using R(t)Co cs: so ve a a y ca y us g ( )Convex polyhedraA plane (a cutting plane is useful)

can be used as a modeling tool (boolean operations) surface model (e g polyhedron) computed from CGSsurface model (e.g., polyhedron) computed from CGS

or Can be used as a model representation

k t t t d t di tl

CSE 681

keep tree structure and ray trace directly

Page 9: Constructive Solid Constructive Solid Geometry Ray Tracing CSG

Controlling the Combinations

+

-+

?

CSE 681

Page 10: Constructive Solid Constructive Solid Geometry Ray Tracing CSG

Tree StructureTree Structure- +

+T1

T2

T3

+ +T5+

T4+ -T4

i lrectangle rectangleT1T2 T3

CSE 681

circlerectangle g

Page 11: Constructive Solid Constructive Solid Geometry Ray Tracing CSG

Tree Structure #1Tree Structure #1

CSE 681

Page 12: Constructive Solid Constructive Solid Geometry Ray Tracing CSG

Tree StructureTree Structure- +

+T1

T2

T3

+ +T5+

T4- +T4

i lrectangle rectangleT1T2 T3

CSE 681

circlerectangle g

Page 13: Constructive Solid Constructive Solid Geometry Ray Tracing CSG

Tree Structure #2

CSE 681

Page 14: Constructive Solid Constructive Solid Geometry Ray Tracing CSG

Tree Structure

• Intersect ray with leaf nodes (primitive objects)• Combine intersection spans according to i di dintermediate nodes

• union• intersection• difference

• Might create multiple spans

CSE 681

Page 15: Constructive Solid Constructive Solid Geometry Ray Tracing CSG

Union of Spans

CSE 681

Page 16: Constructive Solid Constructive Solid Geometry Ray Tracing CSG

Intersection of Spans

CSE 681

Page 17: Constructive Solid Constructive Solid Geometry Ray Tracing CSG

Difference of Spans

CSE 681

Page 18: Constructive Solid Constructive Solid Geometry Ray Tracing CSG

Normals of CSG intersectionsNormals of CSG intersections

Normal of some surface (or its negation)

Union or intersection: positive normal of intersected surface

CSE 681

Page 19: Constructive Solid Constructive Solid Geometry Ray Tracing CSG

Difference normalsDifference normals• Intersection is one of:

• t i of positive object – normal of surfacetmin of positive object normal of surface• tmax of negative object – negated normal

CSE 681

Page 20: Constructive Solid Constructive Solid Geometry Ray Tracing CSG

Add transformations to tree

CSE 681http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/model/csg.html

Page 21: Constructive Solid Constructive Solid Geometry Ray Tracing CSG

Bounding Volumes ConstructionBounding Volumes

T5

•Use bounding volumes at leaf nodes• Union bounding

+ +T5 • Union bounding

volumes at interior nodes

T4Traversal•Top down

+ -T4 •Top-down

•Test bounding volume at interior

circlerectangle rectangleT1T2 T3

CSE 681

circlerectangle g

Page 22: Constructive Solid Constructive Solid Geometry Ray Tracing CSG

Examples

CSE 681

Page 23: Constructive Solid Constructive Solid Geometry Ray Tracing CSG

Examples

CSE 681

Page 24: Constructive Solid Constructive Solid Geometry Ray Tracing CSG

Examples

CSE 681