Massively-Parallel Vector Graphics Francisco Ganacim Rodolfo - - PowerPoint PPT Presentation

massively parallel vector graphics
SMART_READER_LITE
LIVE PREVIEW

Massively-Parallel Vector Graphics Francisco Ganacim Rodolfo - - PowerPoint PPT Presentation

Massively-Parallel Vector Graphics Francisco Ganacim Rodolfo S. Lima Luiz Henrique de Figueiredo Diego Nehab IMPA ACM Transactions on Graphics (Proceedings of ACM SIGGRAPH Asia 2014) Vector graphics are everywhere Vector graphics


slide-1
SLIDE 1

Massively-Parallel Vector Graphics

Francisco Ganacim Rodolfo S. Lima Luiz Henrique de Figueiredo Diego Nehab IMPA

ACM Transactions on Graphics (Proceedings of ACM SIGGRAPH Asia 2014)

slide-2
SLIDE 2

Vector graphics are everywhere

slide-3
SLIDE 3

Vector graphics are everywhere

slide-4
SLIDE 4

Vector graphics are everywhere

slide-5
SLIDE 5

Points to be made

  • 2D graphics incredibly prevalent
  • 2D graphics is not a “solved problem”
  • It deserves more attention
  • Can benefit from parallelism
  • Increased computational power
  • Needs new algorithms
slide-6
SLIDE 6

Diffusion-based vector graphics

[Orzan et al. 2008] [Finch et al. 2011] [Sun et al. 2012 and 2014]

slide-7
SLIDE 7

PATH-BASED VECTOR GRAPHICS

Related work

slide-8
SLIDE 8

Basic concepts are paths and paints

[Warnock & Wyatt 1982]

slide-9
SLIDE 9

Paths

Closed contours

slide-10
SLIDE 10

Segments

Linear Quadratic Cubic

slide-11
SLIDE 11

Inside-outside test

Even-odd rule

  • 1
  • 1

+1

  • 1
  • 2

+1 +1 2 Winding numbers

slide-12
SLIDE 12

Inside-outside test

Non-zero rule

  • 1
  • 1

+1

  • 1
  • 2

+1 +1 2 Winding numbers

slide-13
SLIDE 13

Paints

Solid

slide-14
SLIDE 14

Paints

Radial gradient Linear gradient Texture

slide-15
SLIDE 15

Availability

  • Formats & languages
  • PostScript, CDR, PDF, SVG, OpenXPS, AI
  • TTF fonts, Type 1 fonts
  • Editors
  • Adobe Illustrator, CorelDraw, Inkscape, FontForge, …
  • Rendering tools & APIs
  • NV_Path_Rendering, OpenVG, Cairo, Qt, MuPDF,

GhostScript, Apple’s, Adobe’s, Microsoft’s, …

slide-16
SLIDE 16

Rasterization or rendering

Generate image at chosen resolution for display or printing

slide-17
SLIDE 17

Traditional rendering algorithm

  • Render one shape after the other
  • Most tools follow this approach

for all shapes prepare for acceleration for all samples in shape blend paint over output

slide-18
SLIDE 18

Active-edge-list polygon filling

  • Uses spatial coherence in horizontal spans

[Wylie et al. 1967]

slide-19
SLIDE 19
  • Rasterize winding numbers into stencil

Stencil-based polygon filling

[Neider et al. 1993]

+1 +1 +1

  • 1
  • 1
  • 1
  • 1
  • 1
  • 2
  • 1
slide-20
SLIDE 20
  • Constrained triangulation + affine implicitization

Curve rendering by graphics hardware

[Loop & Blinn 2005]

slide-21
SLIDE 21

Implicitization

Theorem: A polynomial parametric curve has a polynomial implicit form with

  • Different methods
  • Sederberg [1984]
  • Based on Cayley-Bézout or Sylvester
  • Loop & Blinn [2005]
  • Based on Salmon (affine implicitization)
slide-22
SLIDE 22
  • Stencil-based filling with affine implicitization
  • Complete, state-of-the-art pipeline

NV_Path_Rendering

[Neider et al. 1993] + [Loop & Blinn 2005] ≈ [Kokojima et al. 2006] ≈ [Kilgard & Bolz 2012]

slide-23
SLIDE 23

Cell grid Cell

Alternative approach

Illustration clipped against cell

slide-24
SLIDE 24
  • Can become blurry at high magnification levels

Magnification with image textures

[Nehab & Hoppe 2008]

slide-25
SLIDE 25

Magnification with vector textures

  • Maintains sharpness indefinitely

[Nehab & Hoppe 2008]

slide-26
SLIDE 26

General warps in object space

[Nehab & Hoppe 2008]

slide-27
SLIDE 27
  • For texture mapping and effects
  • Mostly limited to academia

[Sen 2004] [Ramanarayanan et al. 2004] [Qin et al. 2008] [Parilov & Zorin 2008] [Nehab & Hoppe 2008]

for all samples for subset of shapes containing sample blend paint into output for all shapes insert into acceleration structure

Vector texture rendering algorithm

slide-28
SLIDE 28

Vector textures

  • Extensive pre-processing
  • Retained mode
  • Samples are independent
  • General warps
  • Analogous to Ray-tracing

Traditional

  • Modest preprocessing
  • Immediate mode
  • Sample cost is amortized
  • Limited warps
  • Analogous to Z-buffering

Comparison of rendering algorithms

slide-29
SLIDE 29

for all shapes insert in acceleration structure for all output samples for subset of shapes covering sample blend paint into output

Vector textures Traditional

for all shapes prepare for acceleration for all shapes for all shape samples blend paint into output

State of the art in accelerated rendering

[Nehab & Hoppe 2008] [Kilgard & Bolz 2012] (NV_Path_Rendering)

slide-30
SLIDE 30

for all segments of all shapes insert in acceleration structure for all output samples for subset of shapes covering sample blend paint into output

Goal

Massively-Parallel Vector Graphics

Ours [Ganacim et al. 2014]

slide-31
SLIDE 31

Contributions

  • New primitive: Abstract segment
  • Based on implicitization, no intersection computations
  • New acceleration data structure: The Shortcut Tree
  • Optimal, adaptive, segment-parallel construction
  • State-of-the-art rendering quality
  • No compromises
slide-32
SLIDE 32

ABSTRACT SEGMENTS

Finding the right primitive

slide-33
SLIDE 33

Does shape cover sample?

  • 1

+1

  • 1
  • 1

p

slide-34
SLIDE 34

Does ray intersect with segment?

+1 p

  • 1
slide-35
SLIDE 35

Computing intersections

  • Segment is
  • Sample at
  • Intersection test
  • Solve for
  • For each such that
  • Test sign of to inc/dec winding number
  • Requires solving quadratics and cubic equations
  • Complicated, slow, not robust
slide-36
SLIDE 36

Monotonic segments

Monotonization makes bounding-boxes very useful

slide-37
SLIDE 37

Example of monotonized segment

p +1

  • 1
slide-38
SLIDE 38

Computing intersections

  • Split into monotonic segments during preprocess
  • Parts with
  • and have no roots for
  • Requires solving linear or quadratic equations
  • Simpler intersection test during rendering
  • One intersection at if and only if
  • Find robustly (e.g., safe Newton–Raphson)
  • Check that
  • Test sign of to inc/dec winding number
slide-39
SLIDE 39

Implicit linear test

  • Outside bounding box, trivial
  • Inside bounding box, use implicitization
slide-40
SLIDE 40

Implicit linear test

  • Outside bounding box, trivial
  • Inside bounding box, use implicitization
slide-41
SLIDE 41

What about curves?

  • Must be careful
  • Parametrization is local to [0,1]
  • Implicitization is global

– – + + + – – – + –

slide-42
SLIDE 42

Monotonic segment with no inflections

Theorem: Monotonic segments with no inflections cannot cross line connecting endpoints for

  • After split, 8 configurations
  • Goes up/down
  • Connects diagonal/anti-diagonal
  • Entirely to left/right of diagonal
slide-43
SLIDE 43

Monotonic quadratics

Theorem: Quadratic cannot reenter triangle for Theorem: Quadratic cannot reenter triangle for

  • r
slide-44
SLIDE 44

Monotonic quadratics

and

Theorem: Quadratic cannot reenter triangle for Theorem: Quadratic cannot reenter triangle for

slide-45
SLIDE 45

Abstract segments

  • Similar setup for cubics and rational quadratics
  • Primitive of choice for vector graphics pipeline
  • Encapsulates monotonic segment s
  • Bounding-box, up-down, precomputed implicitization
  • Method s.winding(x,y)
  • Returns +1 or -1 if ray from (x,y) to (∞,y) hits, 0 otherwise
slide-46
SLIDE 46

Sampling algorithm

for all samples (x,y) for all shapes winding number = 0 for all segments s winding number += s.widing(x,y) if winding number implies inside blend paint into output

slide-47
SLIDE 47

THE SHORTCUT TREE

The right acceleration data structure

slide-48
SLIDE 48

[Nehab & Hoppe 2008]: Regular grid Ours [Ganacim et al. 2014]: Quadtree

Acceleration data structure

slide-49
SLIDE 49

Sampling algorithm

for all samples find cell containing sample for subset of shapes in cell winding number = 0 for subset of segments s in cell winding number += s.winding(x,y) if winding number implies inside blend paint into output

slide-50
SLIDE 50

What goes on each cell?

  • Specialized subset of illustration
  • Everything that is needed to render cell region

Invariant: The winding number of all paths about all samples in the cell region, computed from the cell contents, is exactly the same as in the complete illustration

slide-51
SLIDE 51

[Warnock 1969]

slide-52
SLIDE 52

Clippnig is overkill

We only cast rays to the right

slide-53
SLIDE 53

What goes on each cell?

  • Specialized subset of illustration
  • Everything that is needed to render cell region
  • Only what is needed to render cell region

Invariant: The winding number of all paths about all samples in the cell region, computed from the cell contents, is exactly the same as in the complete illustration

slide-54
SLIDE 54

What about content to right of cell?

  • 1

+1

  • 1
slide-55
SLIDE 55

Cannot be simply discarded

✗ ✗ ✗

slide-56
SLIDE 56
  • 1

+1

  • 1

✓ ✓ ✓

  • 1

+1

  • 1

✓ ✓ ✓

Could use clipping

[Sutherland & Hodgman 1974]

slide-57
SLIDE 57
  • 1

+1

  • 1

✓ ✓ ✓

  • 1

+1

  • 1

✓ ✓ ✓

  • 1

+1

  • 1

✓ ✓ ✓

Shortcut simplification

[Nehab & Hoppe 2008] [Ganacim et al. 2014]

slide-58
SLIDE 58

+1

  • 1

Correctness of shortcut simplification

Theorem: Flipping a shortcut segment adds ±1 to all winding numbers in the cell Corollary: There is an integer k that restores the invariant Corollary: The residual between winding number of input and simplification at any point gives k

slide-59
SLIDE 59

Shortcut simplification summary

  • Include segment if and only if it
  • verlaps with cell
  • Add shortcut up for segments

that cross border

  • Add winding increments for

segments that cross border

Shortcut simplification preserves the invariant

B A A B

slide-60
SLIDE 60

[Warnock 1969]

slide-61
SLIDE 61

[Nehab & Hoppe 2008] (cut segments to cell boundaries)

slide-62
SLIDE 62

Ours [Ganacim et al. 2014] (preserve original segments)

slide-63
SLIDE 63

Subdivision

  • Child cells inherit winding

increments from parent

  • Include those segments that
  • verlap with each child cell
  • Check border crossings with

for shortcuts

  • Check border crossings with

for increments

Subdivision preserves the invariant

C B A D G E F C B A D G E F

slide-64
SLIDE 64

Example subdivision

slide-65
SLIDE 65

Parallel subdivision

s s

  • Segment-parallel classification

Parallel-scan followed by segment-parallel copy

slide-66
SLIDE 66

SAMPLE SCHEDULER

Sample sharing

slide-67
SLIDE 67

Sample sharing

Unit length kernel

pixel coordinates sample weight

Length 4 kernel: loop by pixel

sample weight pixel coordinates

Length 4 kernel: loop by unit sample group

sample weight pixel coordinates

slide-68
SLIDE 68

Parallel sample scheduling

Find tree cell for each sample Group samples by cell Compute sample colors… … and integrate

slide-69
SLIDE 69

RESULTS

slide-70
SLIDE 70

Alias, noise, and gamma

NVPR Linear, 8spp multisampling Ours [Ganacim et al. 2014] Linear, 32x4x4 spp, Cardinal Cubic B-spline weights [Nehab & Hoppe 2008] Linear, 1spp, Prefilter approximation Most renderers Gamma, Box weights

slide-71
SLIDE 71

Conflation

  • Resolving each path to pixels

before blending causes artifacts

  • Correct results require blending

each sample independently

  • NVPR also correct

seam

Most renderers Ours

slide-72
SLIDE 72

Examples of user-defined warps

  • Warp each sample position
  • Not a post-processing step
  • Engages sample scheduler

foreshorten swirl lens

slide-73
SLIDE 73

Preprocessing time (ms)

50 100 150 200 250 Car Drops Paper 1 Contour Paris 30k

low complexity medium complexity high complexity

slide-74
SLIDE 74

50 100 150 200 250 Car Drops Paper 1 Countour Paris 30k

Ours 32x NVPR 8x

Rendering time (ms)

low complexity medium complexity high complexity

slide-75
SLIDE 75

Left out of talk

  • New algorithm for rendering with clip-paths
  • Full SVG semantics, no stack or recursion
  • Parallel pruning algorithm in preprocessing
  • Eliminates occluded or clipped paths from cells
  • Please see paper for other omitted details
slide-76
SLIDE 76

Several ideas for future work

  • Support for rational cubics (enable object-space warps)
  • Support for mesh-based gradients
  • Parallel stroke-to-fill conversion
  • Transparency groups
  • Subpixel rendering (e.g., ClearType)
  • Raster effects over groups (e.g., Gaussian Blur)
  • Different subdivision strategies (e.g, kd-tree)
  • Port back to CPU with multi-threaded vector code
  • Hardware implementation
slide-77
SLIDE 77

Conclusions

  • Fully parallel vector graphics rendering pipeline
  • Interactive preprocessing times
  • Support for user-defined warps
  • Unprecedented output quality
  • Best option for complex illustrations
  • Source-code available

www.impa.br/~diego/projects/GanEtAl14/