CS 1050 Understanding and Constructing Proofs Spring 2006

  • Slides: 37
Download presentation
CS 1050: Understanding and Constructing Proofs Spring 2006 Lecture 18: BLIST FORM of CSG

CS 1050: Understanding and Constructing Proofs Spring 2006 Lecture 18: BLIST FORM of CSG and Blister Jarek Rossignac John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Page 1 / 30

Lecture Objectives • Learn how to convert a CSG expression in to its Blist

Lecture Objectives • Learn how to convert a CSG expression in to its Blist form • Learn how to use a Blist to evaluate a Boolean expression • Understand how to use this for CSG rendering on the GPU John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Page 2 / 30

Blister: GPU-based rendering of Boolean combinations of free-form triangulated shapes John Hable & Jarek

Blister: GPU-based rendering of Boolean combinations of free-form triangulated shapes John Hable & Jarek Rossignac College of Computing, IRIS cluster, GVU Center Georgia Tech, Atlanta, USA http: //www. gvu. gatech. edu/~jarek/blister/ John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Page 3 / 30

CSG (Constructive Solid Geometry) • Operators: – – A+B (Union) AB or A*B (Intersection)

CSG (Constructive Solid Geometry) • Operators: – – A+B (Union) AB or A*B (Intersection) A! (Complement) A–B=AB! (Difference) A B • Primitives (solids): – Bunnies, Triangle meshes – Natural quadrics – Subdivision shells Water-tight boundaries * • CSG expression: (A+B)(C– (D–E)) A Define solids Parsing them yields a binary tree John Hable & Jarek Rossignac (Georgia Tech, GVU) – + B C D BLISTER E Page 4 / 30

Examples of prior approaches • 3 -D: Voxels (classify wrt primitives, merge) [Meagher 84,

Examples of prior approaches • 3 -D: Voxels (classify wrt primitives, merge) [Meagher 84, Breen 89, Fang 98, Chen 00] • 2 -D: Trimmed faces (boundary evaluation) [Mantyla 86, Hoffmann 89, Krishnan 97, Bierman 01] • 1 -D: Rays from eye through pixels [Roth 82, Ellis 91, Pfister 00] B A A–B • 0 -D: Surface samples – Model space (surfels) [Rossignac 86, Bronsvoort 87, Breen 91] – Image space (fragments) [Okino 84, Sato 85, Goldfeather 86 -89, Epstein 89, Wiegant 96, Mc. Reynolds 96, Jansen 95 -87, Rossignac 92, Stewart 98, Fang 00, Stewart 02] Disjunctive form: 31, 104 products • Mixed Faces+fragments [Rappoport 97] John Hable & Jarek Rossignac (Georgia Tech, GVU) Samples+voxels [Adams 03] BLISTER Page 5 / 30

Blist form of a CSG tree Union A=1 i A i. A+i. A!B=i(A+B) B

Blist form of a CSG tree Union A=1 i A i. A+i. A!B=i(A+B) B i i. A!B!=i(A+B)! Intersection A=0 i i A B i. A!+i. AB!=i(AB)! i Difference i. A i i A A i. A! John Hable & Jarek Rossignac (Georgia Tech, GVU) i. AB!=i(A–B) B! i. A!+i. AB!!=i(A–B)! BLISTER Page 6 / 30

Merging Blist sub-expressions L L L John Hable & Jarek Rossignac (Georgia Tech, GVU)

Merging Blist sub-expressions L L L John Hable & Jarek Rossignac (Georgia Tech, GVU) R Union: L+R R Intersection: LR R! Complement: R! R! Difference: L–R=LR! BLISTER Page 7 / 30

* Example – + (A+B)*(C–(D–E)) A B C D E i A B C

* Example – + (A+B)*(C–(D–E)) A B C D E i A B C D E! i A B C D! E!! i((A+B)(C–(D–E))) i A B C D! E i((A+B)(C–(D–E)))! John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Page 8 / 30

Use a positive CSG form (for simplicity) negative (complemented) primitive A–B=AB! (A+B)!=A!B! (A+B)(C– (D–E))

Use a positive CSG form (for simplicity) negative (complemented) primitive A–B=AB! (A+B)!=A!B! (A+B)(C– (D–E)) (AB)!=A!+B! (A+B)(C(D!+E)) A!!=A * * Conversion to positive form is a trivial recursion – + A A B C D B + C D! E John Hable & Jarek Rossignac (Georgia Tech, GVU) * + BLISTER E Page 9 / 30

Algorithm for computing Blist labels Assigns to each link the label (color) of its

Algorithm for computing Blist labels Assigns to each link the label (color) of its final destination primitive C i C A P. n=A P. t=C P. f=B B B f=false Assume positive form t=true f=false f=B t=D t=true f=B f=C t=D f=C C f t D! D! f t E E f With each primitive P, store its name, P. n and its P. t (upper) and P. f (lower) labels char lml (int m) { # left most leaf of right child char left. Most; if((o[m]!='*')&&(o[m]!='+')) {left. Most=o[m]; } else {if (o[m]=='+') {f[m]=lml(r[m]); } else {t[m]=lml(r[m]); }; left. Most=lml(l[m]); }; return(left. Most); } Going right: inherit t and f. Going left: pick up blue value t=true f=false t=D f=false John Hable & Jarek Rossignac (Georgia Tech, GVU) void mb (int m, char pt, char pf) { if((o[m]!='*')&&(o[m]!='+')) { blist. Name[pc]=o[m]; blist. If. True[pc]=pt; blist. If. False[pc]=pf; t[m]=pt; f[m]=pf; pc++; } else {if (o[m]=='+') {mb(l[m], pt, f[m]); } else {mb(l[m], t[m], pf); }; mb(r[m], pt, pf); }; } BLISTER Page 10 / 30

Point-in-CSG classification using Blist C i A C B B C f t D!

Point-in-CSG classification using Blist C i A C B B C f t D! D! f t E E f Workspace: Boolean parity; 6 -bit integer next; For each primitive P in Blist do: parity : = true if point is in-or-on P; If (next==P. n) {if (parity) {next=P. t} else {next=P. f}}; The final content of next indicates whether the CSG expression is true or false John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Page 11 / 30

We can only afford 6 -bit labels C i A C B B Assign

We can only afford 6 -bit labels C i A C B B Assign integers as needed. 1 i A C D! A E f 1 3 4 4 C : 1 D!: 3 2 C : 1 B: 0 0 John Hable & Jarek Rossignac (Georgia Tech, GVU) E f 2 Reuse labels of primitives that have already been reached. 1 1 1 i t f B: 0 0 t D! 0 E: 5 5 2 1 1 D!: 1 0 BLISTER E: 2 2 0 Need 3 labels Page 12 / 30

Minimizing the number of labels Original: (A+((B+((C+((D+E)+F))+G))+H))+(I+(J+(K+L)M)N): 5 labels Can swap left and right

Minimizing the number of labels Original: (A+((B+((C+((D+E)+F))+G))+H))+(I+(J+(K+L)M)N): 5 labels Can swap left and right arguments. Strategy: swap to make tree left-heavy A+B B+A, AB BA Cost swaps: labels Height(K+L)+JM+IN+(A+(H+(B+(G+(C+(F+(D+E))))))) swaps: D+E+F+C+G+B+H+A+(((K+L)M+J)N+I): : 3 4 labels There are 64 6 -bit labels. We prove that no CSG tree with < 3909 primitives requires more than 64 labels Recently developed linear optimization: No CSG trees with < 263 primitives requires more than 64 labels. John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Page 13 / 30

Improving Blist worst-case footprint Height-based pivoting (described in the paper) could guarantee only 3909

Improving Blist worst-case footprint Height-based pivoting (described in the paper) could guarantee only 3909 primitives New cost-based pivoting with 6 stencil bits guarantees support for all CSG trees with less than 263 primitives! In general b stencil-bits support n=2 b labels and n labels suffice for all Blist expressions with up to p=2 n– 1– 1 primitives Smallest expression requiring 5 labels has 15 primitives: ((AB+C)(DE+F)+G)((HI+J)(KL+M)+N)+O Original (5 labels): (A+((B+((C+((D+E)+F))+G))+H))+(I+(J+(K+L)M)N) Height swaps (4 labels): D+E+F+C+G+B+H+A+(((K+L)M+J)N+I) Cost swaps (3 labels): (K+L)+JM+IN+(A+(H+(B+(G+(C+(F+(D+E))))))) John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Page 14 / 30

Blist is a very special decision graph • Boolean functions: many representations [Moret 82]

Blist is a very special decision graph • Boolean functions: many representations [Moret 82] • Binary Decision Graphs (BDG) [Akers 78] • Reduced Function Graphs (RFG) [Bryant 86] – Acyclic BDGs without repetition – Constructed through Shanon’s Expansion [Shannon 38] – Removing empty leaves yields BSP trees – Reduction: recursively tests graph isomorphisms – # nodes may be exponential in # primitives – Size depends on order [Payne 77] (optimal is NP-hard) – Footprint is log 2 N bits • Blist [Rossignac 99] – RFG of a Boolean expression with +, *, – operators – Linear construction & optimization cost – # nodes = # primitives = N – Footprint may be compressed to log 2 N bits (A+B)–CD=(A+B)(C!+D!) A!(B(C!+D!)+A(C!+D!) A!(B!+B(CD!+C!)+A(CD!+C!) A B C! C! D! D! A B C! D! John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Page 15 / 30

Blister Overview • Repeat until all pixels are locked – Peel: Push the unlocked

Blister Overview • Repeat until all pixels are locked – Peel: Push the unlocked fragments to the next layer • Scan each primitive: compute foremost fragment behind current layer – Lock: Identify and lock fragments on the CSG solid • For each primitive P: – Classify active fragments by toggling parity bit – For all active pixels: Update the Blist next value Contributions of layers (front-to-back) Several primitives may contribute to a layer John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Page 16 / 30

John Hable 1. 2. 3. 4. 5. John Hable & Jarek Rossignac (Georgia Tech,

John Hable 1. 2. 3. 4. 5. John Hable & Jarek Rossignac (Georgia Tech, GVU) Peel Lock Results Extensions Future Work BLISTER Page 17 / 30

Peel strategy • UNC: Peel each primitive with a counter [Goldfeather-Hultquist-Fuchs SIG’ 89] 5

Peel strategy • UNC: Peel each primitive with a counter [Goldfeather-Hultquist-Fuchs SIG’ 89] 5 4 1 2 3 6 • IBM+: Peel a product with a Depth-Interval Buffer? F=previous layer, B=infinity If (F<z<B) {B: =z} [Epstein-Jansen-Rossignac’ 89] [Stewart-Leach-John’ 98, Guha et al. ’ 03] 1 2 3 • Ga. Tech: Peel it all using texture memory [Mammen CG&A 89, Everitt’ 02, Kirsch&Döllner WSCG 04] Store F as depth texture B: =closest fragment behind F John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Page 18 / 30

Peel example Peel the arrangements of all primitives taken together For each layer, scan

Peel example Peel the arrangements of all primitives taken together For each layer, scan the front/back faces of positive/negative primitives Use a Depth-Interval Buffer to advance the layer [Epstein-Jansen-Rossignac’ 89] Produces layers of fragments in front-to-back order (A+B)–C A Negative primitive (A+B)C! B C Third layer fragments Second layer fragments First layer fragments John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Page 19 / 30

Peeling: Implementation details Initialization: • Compute (small) set of primitives that cover the CSG

Peeling: Implementation details Initialization: • Compute (small) set of primitives that cover the CSG solid • A–B A, A+B, AB smaller of A and B • Store front F and back B’ of the covering set in texture memory • Render with GL-LT and GL-GT For each layer: • F contains previous layer depth • B is initialized to infinity • Render primitives • In the pixel-shader (z=depth of fragment) • If ( z<F || B’<z ) discard fragment • If (pixel is locked) discard fragment • Standard depth-test on remaining fragments: • If (z<B) {B: =z} John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Page 20 / 30

Peel & lock example Each new layer is trimmed Pixels with fragments on the

Peel & lock example Each new layer is trimmed Pixels with fragments on the CSG solid S are locked The next layer is only computed at the active (unlocked) pixels (A+B)–C A B C Third layer locked Second layer locked First layer locked John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Page 21 / 30

Fragment/primitive classification We want to classify the fragments of each active pixel q in

Fragment/primitive classification We want to classify the fragments of each active pixel q in the current layer whose depth is S[q] Scan P generating fragments (pixel q, depth z) – If ((q is active) && (z<S[q]) ) {parity[q]=parity[q]!} Fragments of odd parity pixels are inside P. 0 1 0 John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Page 22 / 30

Classifying fragments on P Prior art tested ghost fragment moved back by e: c

Classifying fragments on P Prior art tested ghost fragment moved back by e: c If ((q is active) && (z<S[q])+e) {parity[q]=parity[q]!} a [Rossignac-Wu 92] b Possible artifacts in thin areas We solve on-cases without fake displacement: Use GL_LEQUAL Fragments on front-faces of positive primitive P or on the back -face of a negative primitive P must be classified as in-or-on P John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Page 23 / 30

ON/ON cases A B C (A–B)+C John Hable & Jarek Rossignac (Georgia Tech, GVU)

ON/ON cases A B C (A–B)+C John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Page 24 / 30

Can’t remember past classifications? Only 6 stencil-bits per pixel to keep past classification results

Can’t remember past classifications? Only 6 stencil-bits per pixel to keep past classification results • Storing Boolean for each primitive: < 7 primitives • Storing a stack of partially evaluated results < 65 primitives • Using a disjunctive form of CSG tree: no limit on N Goldfeather 86 -89, Epstein 89, Wiegant 96, Rossignac 92, Stewart 98, Stewart 02… But… the number of products can grow exponentially! * * * + + CSG expression has 48 primitives. Disjunctive form has 31, 104 products with 5 primitives per product * * + + * + + + (No pruning possible) So… use Blist instead! John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Page 25 / 30

Lock for layer 2 in the example Fragments at all active pixels are classified

Lock for layer 2 in the example Fragments at all active pixels are classified in parallel against each primitive. Their stencils are updated (based on the classification and their previous value). After the last primitive, fragments on the CSG solid are locked, others stay active. (A+B)–C A Active fragments of layer 2 Scan A Out of A (for B) B C In-or-on A (for C) Scan B In-or-on B (for C) Scan C In-or-on C! (locked) John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Out of C (active) Page 26 / 30

Use Blist to merge past classifications 1 i A 1 C : 1 B:

Use Blist to merge past classifications 1 i A 1 C : 1 B: 0 0 1 D!: 1 0 1 E: 2 2 0 Initialization: Rearrange the CSG tree to minimize the number of labels With each primitive, P, associate its 3 Blist labels: P. n, P. t, P. f P. t P: n P. f In the stencil of each pixel store: parity (bit-0), next (bits 1 -6) To classify and lock the fragments of the current layer For each primitive P in Blist do: Scan P {toggling parity when P is in front of the tested fragment} Scan all active pixels {If (next==P. n) {if (parity) {next=P. t} else {next=P. f}}} John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Page 27 / 30

Updating the stencil bits of next // Stencil=(parity-bit, next) // if (parity-bit==1 and next==P.

Updating the stencil bits of next // Stencil=(parity-bit, next) // if (parity-bit==1 and next==P. n) then next: = P. t IF (Stencil==10000010) {Stencil: = 10000011; } // if (parity-bit==0 and next==P. n) then next: = P. f IF (Stencil==00000010) {Stencil: = 0000; } A 0000010 . . . B 0000000 C 0000011 Speed-up suggested by Mark Kilgard (n. Vidia): Mask=next XOR P. t; Then toggle next where it agrees with Mask gl. Stencil. Mask( P. t ~ next ); gl. Stencil. Func( GL_EQUAL, P. t | 0 x 80, 0 xff ); gl. Stencil. Op( GL_KEEP, GL_INVERT ); John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Page 28 / 30

An example Layer 1 Layer 2 Layer 3 Layer 4 Free fragments On fragments

An example Layer 1 Layer 2 Layer 3 Layer 4 Free fragments On fragments Locked fragments John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Page 29 / 30

Timing results n. Vidia Ge. Force 6800 Bunny has 574 K triangles, Bunny 2

Timing results n. Vidia Ge. Force 6800 Bunny has 574 K triangles, Bunny 2 has 2. 3 M Average over random directions Widget Bunny 2 Complex Gear Actual layers processed when we prune active pixels prims layers kf T (sec) 4 4 4 20 48 4. 00 9. 13 9. 09 14. 1 36. 4 3. 85 6. 81 6. 77 9. 17 25. 6 0. 018 0. 325 1. 200 0. 093 0. 460 John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Page 30 / 30

Extensions • Transparency (not always correct) – Internal faces increase opacity • Shadows (shadow

Extensions • Transparency (not always correct) – Internal faces increase opacity • Shadows (shadow buffer) John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Page 31 / 30

Ongoing & future work • Increase complexity for which Blister is guaranteed to work

Ongoing & future work • Increase complexity for which Blister is guaranteed to work – Increased from 3909 to 263 primitives when using 6 stencil bits • Improve performance – Preliminary Results: already 20% faster • Select “correct” color fragments on 2 primitives – Use Active Zones [Rossignac&Voelcker 89] • Correct surface transparency – Custom classification • Voxelization / volumetric rendering – Interpolate / integrate between layers • Parallelization (SLI/Crossfire) – AFR (Alternate Frame Rendering between two graphics cards) – Split Screen/Tiles, but shared texture John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Page 32 / 30

Summary of Blister • Can render all CSG trees with up to 263 primitives

Summary of Blister • Can render all CSG trees with up to 263 primitives – Simple, efficient CSG-to-Blist conversion • Time complexity: O(Depth. Comp*Primitives) • Efficient implementation on GPU – Typical performance: 2 fps for CSG of 50 primitives • Can be used for shadows (and “transparency”) • Many improvements/extensions underway * 1 1 – + A B i D C: 1 B: 0 0 C A 1 0 D!: 1 0 1 1 E: 2 2 0 E John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Page 33 / 30

Blister Video: Realtime CSG graphics John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER

Blister Video: Realtime CSG graphics John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Page 34 / 30

Blist of a symmetric difference Simple to support, but reduces the size of the

Blist of a symmetric difference Simple to support, but reduces the size of the worst case CSG models that we can handle. L R! R A B C A B! John Hable & Jarek Rossignac (Georgia Tech, GVU) B C! BLISTER C Page 35 / 30

Assigned Reading • Read the Blister paper • Read the CST paper John Hable

Assigned Reading • Read the Blister paper • Read the CST paper John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Page 37 / 30

Assigned Homework • Learn how to convert a CSG expression into its Blist form

Assigned Homework • Learn how to convert a CSG expression into its Blist form and how to evaluate a Blist John Hable & Jarek Rossignac (Georgia Tech, GVU) BLISTER Page 38 / 30