Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic...

61
Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis {acnatha, rkarl, arakel}@vr.clemson.edu. Clemson University Computer Science Department Colluquium Series – p.1

Transcript of Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic...

Page 1: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Building 3D Models Using PlasticConstruction Bricks

Nathan Cournia Karl Rasche and Andrew Van Pernis

acnatha rkarl arakelvrclemsonedu

Clemson University

Computer Science Department Colluquium Series ndash p1

Outline

Computer Science Department Colluquium Series ndash p2

Outline

Motivation

Representing 3D Models As Voxels

Representing 2D Images As Voxels

Converting Voxels To Plastic ConstructionBricks

Results

Computer Science Department Colluquium Series ndash p3

Motivation

Computer Science Department Colluquium Series ndash p4

Problem Definition

Problem Given a three-dimensional model howcan we build that model using plasticconstruction bricks

Our answer Create a voxelization of the modelthen represent that voxelization as a set ofLDraw parts which have been carefully selectedto produce a buildable version of the model

Computer Science Department Colluquium Series ndash p5

Problem Definition

Problem Given a three-dimensional model howcan we build that model using plasticconstruction bricks

Our answer Create a voxelization of the modelthen represent that voxelization as a set ofLDraw parts which have been carefully selectedto produce a buildable version of the model

Computer Science Department Colluquium Series ndash p5

Problem In Pictures

rarr

Computer Science Department Colluquium Series ndash p6

Problem In Pictures

rarr

Computer Science Department Colluquium Series ndash p6

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Representing 3D Models As Voxels

Computer Science Department Colluquium Series ndash p8

Voxelization

Given a polygonal model generate a set ofvoxels

Computer Science Department Colluquium Series ndash p9

What is a voxel

A small 3D box with some properties(density color etc)

Short for volume element

3D counterpart of a 2D pixel

Computer Science Department Colluquium Series ndash p10

Voxelization

Process of converting a geometricrepresentation of a synthetic model into a setof voxels

Some processes are easier to use whenoperating on voxel data

Computing VolumeCSG (Intersection Union etc)Collision Detection

The reverse is also true Voxels are notoptimal for everything

Computer Science Department Colluquium Series ndash p11

Voxelization

Several methods for generating avoxelization exist

Casting RaysScan Converting

Most are not pretty to code

Can be slow

Can we speed it up Yes use the GPU

See httpwwwcssunysbedu vislabprojectsvolumePapersVoxel

Computer Science Department Colluquium Series ndash p12

Hardware Accelerated Voxelization

Modern graphics hardware is fast (exceedingMoorersquos Law)

Modern graphics hardware is programmable

Computationally expensive algorithms arebeing offloaded to the GPU

Fast Fourier TransformGlobal Illumination ComputationsPath Finding (AI)Collision Detection

Computer Science Department Colluquium Series ndash p13

Hardware Accelerated Voxelization

Turns out we donrsquot need to use theprogrammable GPU

Standard fixed function color and depthbuffers will suffice

Color buffer stores the color of each pixel inthe rendered scene

But what is the depth buffer

Computer Science Department Colluquium Series ndash p14

Depth Buffer

Also known as the Z-buffer

Stores the depth of each pixel in the scene

Values range from [01]

Usually initialized to 1

Smaller values are closer to the near clipplane (camera)

Traditionally used for hidden surface removal

Computer Science Department Colluquium Series ndash p15

Depth Buffer Example

Computer Science Department Colluquium Series ndash p16

HW Voxelization Algorithm

Center mesh around world origin

Set viewport to NtimesN where N is the size of adimension in the NtimesNtimesN voxel lattice

Render scene through a tightly fittedorthographic (parallel) projection from eachside of the modelrsquos bounding box

Record depth and color buffers from eachrender

Produces six set of images (6 color bufferimages 6 depth buffer images)

See httpwwwacmorgjgtpapersKarabassiEtAl99b

Computer Science Department Colluquium Series ndash p17

DepthColor Buffer Visualization

FrontBack

Computer Science Department Colluquium Series ndash p18

DepthColor Buffer Visualization

LeftRight

Computer Science Department Colluquium Series ndash p19

DepthColor Buffer Visualization

TopBottom

Computer Science Department Colluquium Series ndash p20

Determing if a Voxel is On

For each voxel in the lattice compute thedistance to each side of the cube

Test if this distance is bounded by the depthbuffers in each axis

If so voxel is inside otherwise its outside

Holes not visable from outside the object willbe filled

Computer Science Department Colluquium Series ndash p21

Determining a Voxelrsquos Color

Find the depth map which is closest to thevoxel

Look up the voxelrsquos color in the depth maprsquoscorrespoding color map

Interior voxels share the same color asclosest surface voxel

Computer Science Department Colluquium Series ndash p22

Voxelization Algorithm Notes

Works for polygonal and analytical models

Efficiency is independent of modelcomplexity

Voxelizes data in O(n)

Does not handle concave models

Computer Science Department Colluquium Series ndash p23

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 2: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Outline

Computer Science Department Colluquium Series ndash p2

Outline

Motivation

Representing 3D Models As Voxels

Representing 2D Images As Voxels

Converting Voxels To Plastic ConstructionBricks

Results

Computer Science Department Colluquium Series ndash p3

Motivation

Computer Science Department Colluquium Series ndash p4

Problem Definition

Problem Given a three-dimensional model howcan we build that model using plasticconstruction bricks

Our answer Create a voxelization of the modelthen represent that voxelization as a set ofLDraw parts which have been carefully selectedto produce a buildable version of the model

Computer Science Department Colluquium Series ndash p5

Problem Definition

Problem Given a three-dimensional model howcan we build that model using plasticconstruction bricks

Our answer Create a voxelization of the modelthen represent that voxelization as a set ofLDraw parts which have been carefully selectedto produce a buildable version of the model

Computer Science Department Colluquium Series ndash p5

Problem In Pictures

rarr

Computer Science Department Colluquium Series ndash p6

Problem In Pictures

rarr

Computer Science Department Colluquium Series ndash p6

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Representing 3D Models As Voxels

Computer Science Department Colluquium Series ndash p8

Voxelization

Given a polygonal model generate a set ofvoxels

Computer Science Department Colluquium Series ndash p9

What is a voxel

A small 3D box with some properties(density color etc)

Short for volume element

3D counterpart of a 2D pixel

Computer Science Department Colluquium Series ndash p10

Voxelization

Process of converting a geometricrepresentation of a synthetic model into a setof voxels

Some processes are easier to use whenoperating on voxel data

Computing VolumeCSG (Intersection Union etc)Collision Detection

The reverse is also true Voxels are notoptimal for everything

Computer Science Department Colluquium Series ndash p11

Voxelization

Several methods for generating avoxelization exist

Casting RaysScan Converting

Most are not pretty to code

Can be slow

Can we speed it up Yes use the GPU

See httpwwwcssunysbedu vislabprojectsvolumePapersVoxel

Computer Science Department Colluquium Series ndash p12

Hardware Accelerated Voxelization

Modern graphics hardware is fast (exceedingMoorersquos Law)

Modern graphics hardware is programmable

Computationally expensive algorithms arebeing offloaded to the GPU

Fast Fourier TransformGlobal Illumination ComputationsPath Finding (AI)Collision Detection

Computer Science Department Colluquium Series ndash p13

Hardware Accelerated Voxelization

Turns out we donrsquot need to use theprogrammable GPU

Standard fixed function color and depthbuffers will suffice

Color buffer stores the color of each pixel inthe rendered scene

But what is the depth buffer

Computer Science Department Colluquium Series ndash p14

Depth Buffer

Also known as the Z-buffer

Stores the depth of each pixel in the scene

Values range from [01]

Usually initialized to 1

Smaller values are closer to the near clipplane (camera)

Traditionally used for hidden surface removal

Computer Science Department Colluquium Series ndash p15

Depth Buffer Example

Computer Science Department Colluquium Series ndash p16

HW Voxelization Algorithm

Center mesh around world origin

Set viewport to NtimesN where N is the size of adimension in the NtimesNtimesN voxel lattice

Render scene through a tightly fittedorthographic (parallel) projection from eachside of the modelrsquos bounding box

Record depth and color buffers from eachrender

Produces six set of images (6 color bufferimages 6 depth buffer images)

See httpwwwacmorgjgtpapersKarabassiEtAl99b

Computer Science Department Colluquium Series ndash p17

DepthColor Buffer Visualization

FrontBack

Computer Science Department Colluquium Series ndash p18

DepthColor Buffer Visualization

LeftRight

Computer Science Department Colluquium Series ndash p19

DepthColor Buffer Visualization

TopBottom

Computer Science Department Colluquium Series ndash p20

Determing if a Voxel is On

For each voxel in the lattice compute thedistance to each side of the cube

Test if this distance is bounded by the depthbuffers in each axis

If so voxel is inside otherwise its outside

Holes not visable from outside the object willbe filled

Computer Science Department Colluquium Series ndash p21

Determining a Voxelrsquos Color

Find the depth map which is closest to thevoxel

Look up the voxelrsquos color in the depth maprsquoscorrespoding color map

Interior voxels share the same color asclosest surface voxel

Computer Science Department Colluquium Series ndash p22

Voxelization Algorithm Notes

Works for polygonal and analytical models

Efficiency is independent of modelcomplexity

Voxelizes data in O(n)

Does not handle concave models

Computer Science Department Colluquium Series ndash p23

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 3: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Outline

Motivation

Representing 3D Models As Voxels

Representing 2D Images As Voxels

Converting Voxels To Plastic ConstructionBricks

Results

Computer Science Department Colluquium Series ndash p3

Motivation

Computer Science Department Colluquium Series ndash p4

Problem Definition

Problem Given a three-dimensional model howcan we build that model using plasticconstruction bricks

Our answer Create a voxelization of the modelthen represent that voxelization as a set ofLDraw parts which have been carefully selectedto produce a buildable version of the model

Computer Science Department Colluquium Series ndash p5

Problem Definition

Problem Given a three-dimensional model howcan we build that model using plasticconstruction bricks

Our answer Create a voxelization of the modelthen represent that voxelization as a set ofLDraw parts which have been carefully selectedto produce a buildable version of the model

Computer Science Department Colluquium Series ndash p5

Problem In Pictures

rarr

Computer Science Department Colluquium Series ndash p6

Problem In Pictures

rarr

Computer Science Department Colluquium Series ndash p6

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Representing 3D Models As Voxels

Computer Science Department Colluquium Series ndash p8

Voxelization

Given a polygonal model generate a set ofvoxels

Computer Science Department Colluquium Series ndash p9

What is a voxel

A small 3D box with some properties(density color etc)

Short for volume element

3D counterpart of a 2D pixel

Computer Science Department Colluquium Series ndash p10

Voxelization

Process of converting a geometricrepresentation of a synthetic model into a setof voxels

Some processes are easier to use whenoperating on voxel data

Computing VolumeCSG (Intersection Union etc)Collision Detection

The reverse is also true Voxels are notoptimal for everything

Computer Science Department Colluquium Series ndash p11

Voxelization

Several methods for generating avoxelization exist

Casting RaysScan Converting

Most are not pretty to code

Can be slow

Can we speed it up Yes use the GPU

See httpwwwcssunysbedu vislabprojectsvolumePapersVoxel

Computer Science Department Colluquium Series ndash p12

Hardware Accelerated Voxelization

Modern graphics hardware is fast (exceedingMoorersquos Law)

Modern graphics hardware is programmable

Computationally expensive algorithms arebeing offloaded to the GPU

Fast Fourier TransformGlobal Illumination ComputationsPath Finding (AI)Collision Detection

Computer Science Department Colluquium Series ndash p13

Hardware Accelerated Voxelization

Turns out we donrsquot need to use theprogrammable GPU

Standard fixed function color and depthbuffers will suffice

Color buffer stores the color of each pixel inthe rendered scene

But what is the depth buffer

Computer Science Department Colluquium Series ndash p14

Depth Buffer

Also known as the Z-buffer

Stores the depth of each pixel in the scene

Values range from [01]

Usually initialized to 1

Smaller values are closer to the near clipplane (camera)

Traditionally used for hidden surface removal

Computer Science Department Colluquium Series ndash p15

Depth Buffer Example

Computer Science Department Colluquium Series ndash p16

HW Voxelization Algorithm

Center mesh around world origin

Set viewport to NtimesN where N is the size of adimension in the NtimesNtimesN voxel lattice

Render scene through a tightly fittedorthographic (parallel) projection from eachside of the modelrsquos bounding box

Record depth and color buffers from eachrender

Produces six set of images (6 color bufferimages 6 depth buffer images)

See httpwwwacmorgjgtpapersKarabassiEtAl99b

Computer Science Department Colluquium Series ndash p17

DepthColor Buffer Visualization

FrontBack

Computer Science Department Colluquium Series ndash p18

DepthColor Buffer Visualization

LeftRight

Computer Science Department Colluquium Series ndash p19

DepthColor Buffer Visualization

TopBottom

Computer Science Department Colluquium Series ndash p20

Determing if a Voxel is On

For each voxel in the lattice compute thedistance to each side of the cube

Test if this distance is bounded by the depthbuffers in each axis

If so voxel is inside otherwise its outside

Holes not visable from outside the object willbe filled

Computer Science Department Colluquium Series ndash p21

Determining a Voxelrsquos Color

Find the depth map which is closest to thevoxel

Look up the voxelrsquos color in the depth maprsquoscorrespoding color map

Interior voxels share the same color asclosest surface voxel

Computer Science Department Colluquium Series ndash p22

Voxelization Algorithm Notes

Works for polygonal and analytical models

Efficiency is independent of modelcomplexity

Voxelizes data in O(n)

Does not handle concave models

Computer Science Department Colluquium Series ndash p23

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 4: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Motivation

Computer Science Department Colluquium Series ndash p4

Problem Definition

Problem Given a three-dimensional model howcan we build that model using plasticconstruction bricks

Our answer Create a voxelization of the modelthen represent that voxelization as a set ofLDraw parts which have been carefully selectedto produce a buildable version of the model

Computer Science Department Colluquium Series ndash p5

Problem Definition

Problem Given a three-dimensional model howcan we build that model using plasticconstruction bricks

Our answer Create a voxelization of the modelthen represent that voxelization as a set ofLDraw parts which have been carefully selectedto produce a buildable version of the model

Computer Science Department Colluquium Series ndash p5

Problem In Pictures

rarr

Computer Science Department Colluquium Series ndash p6

Problem In Pictures

rarr

Computer Science Department Colluquium Series ndash p6

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Representing 3D Models As Voxels

Computer Science Department Colluquium Series ndash p8

Voxelization

Given a polygonal model generate a set ofvoxels

Computer Science Department Colluquium Series ndash p9

What is a voxel

A small 3D box with some properties(density color etc)

Short for volume element

3D counterpart of a 2D pixel

Computer Science Department Colluquium Series ndash p10

Voxelization

Process of converting a geometricrepresentation of a synthetic model into a setof voxels

Some processes are easier to use whenoperating on voxel data

Computing VolumeCSG (Intersection Union etc)Collision Detection

The reverse is also true Voxels are notoptimal for everything

Computer Science Department Colluquium Series ndash p11

Voxelization

Several methods for generating avoxelization exist

Casting RaysScan Converting

Most are not pretty to code

Can be slow

Can we speed it up Yes use the GPU

See httpwwwcssunysbedu vislabprojectsvolumePapersVoxel

Computer Science Department Colluquium Series ndash p12

Hardware Accelerated Voxelization

Modern graphics hardware is fast (exceedingMoorersquos Law)

Modern graphics hardware is programmable

Computationally expensive algorithms arebeing offloaded to the GPU

Fast Fourier TransformGlobal Illumination ComputationsPath Finding (AI)Collision Detection

Computer Science Department Colluquium Series ndash p13

Hardware Accelerated Voxelization

Turns out we donrsquot need to use theprogrammable GPU

Standard fixed function color and depthbuffers will suffice

Color buffer stores the color of each pixel inthe rendered scene

But what is the depth buffer

Computer Science Department Colluquium Series ndash p14

Depth Buffer

Also known as the Z-buffer

Stores the depth of each pixel in the scene

Values range from [01]

Usually initialized to 1

Smaller values are closer to the near clipplane (camera)

Traditionally used for hidden surface removal

Computer Science Department Colluquium Series ndash p15

Depth Buffer Example

Computer Science Department Colluquium Series ndash p16

HW Voxelization Algorithm

Center mesh around world origin

Set viewport to NtimesN where N is the size of adimension in the NtimesNtimesN voxel lattice

Render scene through a tightly fittedorthographic (parallel) projection from eachside of the modelrsquos bounding box

Record depth and color buffers from eachrender

Produces six set of images (6 color bufferimages 6 depth buffer images)

See httpwwwacmorgjgtpapersKarabassiEtAl99b

Computer Science Department Colluquium Series ndash p17

DepthColor Buffer Visualization

FrontBack

Computer Science Department Colluquium Series ndash p18

DepthColor Buffer Visualization

LeftRight

Computer Science Department Colluquium Series ndash p19

DepthColor Buffer Visualization

TopBottom

Computer Science Department Colluquium Series ndash p20

Determing if a Voxel is On

For each voxel in the lattice compute thedistance to each side of the cube

Test if this distance is bounded by the depthbuffers in each axis

If so voxel is inside otherwise its outside

Holes not visable from outside the object willbe filled

Computer Science Department Colluquium Series ndash p21

Determining a Voxelrsquos Color

Find the depth map which is closest to thevoxel

Look up the voxelrsquos color in the depth maprsquoscorrespoding color map

Interior voxels share the same color asclosest surface voxel

Computer Science Department Colluquium Series ndash p22

Voxelization Algorithm Notes

Works for polygonal and analytical models

Efficiency is independent of modelcomplexity

Voxelizes data in O(n)

Does not handle concave models

Computer Science Department Colluquium Series ndash p23

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 5: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Problem Definition

Problem Given a three-dimensional model howcan we build that model using plasticconstruction bricks

Our answer Create a voxelization of the modelthen represent that voxelization as a set ofLDraw parts which have been carefully selectedto produce a buildable version of the model

Computer Science Department Colluquium Series ndash p5

Problem Definition

Problem Given a three-dimensional model howcan we build that model using plasticconstruction bricks

Our answer Create a voxelization of the modelthen represent that voxelization as a set ofLDraw parts which have been carefully selectedto produce a buildable version of the model

Computer Science Department Colluquium Series ndash p5

Problem In Pictures

rarr

Computer Science Department Colluquium Series ndash p6

Problem In Pictures

rarr

Computer Science Department Colluquium Series ndash p6

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Representing 3D Models As Voxels

Computer Science Department Colluquium Series ndash p8

Voxelization

Given a polygonal model generate a set ofvoxels

Computer Science Department Colluquium Series ndash p9

What is a voxel

A small 3D box with some properties(density color etc)

Short for volume element

3D counterpart of a 2D pixel

Computer Science Department Colluquium Series ndash p10

Voxelization

Process of converting a geometricrepresentation of a synthetic model into a setof voxels

Some processes are easier to use whenoperating on voxel data

Computing VolumeCSG (Intersection Union etc)Collision Detection

The reverse is also true Voxels are notoptimal for everything

Computer Science Department Colluquium Series ndash p11

Voxelization

Several methods for generating avoxelization exist

Casting RaysScan Converting

Most are not pretty to code

Can be slow

Can we speed it up Yes use the GPU

See httpwwwcssunysbedu vislabprojectsvolumePapersVoxel

Computer Science Department Colluquium Series ndash p12

Hardware Accelerated Voxelization

Modern graphics hardware is fast (exceedingMoorersquos Law)

Modern graphics hardware is programmable

Computationally expensive algorithms arebeing offloaded to the GPU

Fast Fourier TransformGlobal Illumination ComputationsPath Finding (AI)Collision Detection

Computer Science Department Colluquium Series ndash p13

Hardware Accelerated Voxelization

Turns out we donrsquot need to use theprogrammable GPU

Standard fixed function color and depthbuffers will suffice

Color buffer stores the color of each pixel inthe rendered scene

But what is the depth buffer

Computer Science Department Colluquium Series ndash p14

Depth Buffer

Also known as the Z-buffer

Stores the depth of each pixel in the scene

Values range from [01]

Usually initialized to 1

Smaller values are closer to the near clipplane (camera)

Traditionally used for hidden surface removal

Computer Science Department Colluquium Series ndash p15

Depth Buffer Example

Computer Science Department Colluquium Series ndash p16

HW Voxelization Algorithm

Center mesh around world origin

Set viewport to NtimesN where N is the size of adimension in the NtimesNtimesN voxel lattice

Render scene through a tightly fittedorthographic (parallel) projection from eachside of the modelrsquos bounding box

Record depth and color buffers from eachrender

Produces six set of images (6 color bufferimages 6 depth buffer images)

See httpwwwacmorgjgtpapersKarabassiEtAl99b

Computer Science Department Colluquium Series ndash p17

DepthColor Buffer Visualization

FrontBack

Computer Science Department Colluquium Series ndash p18

DepthColor Buffer Visualization

LeftRight

Computer Science Department Colluquium Series ndash p19

DepthColor Buffer Visualization

TopBottom

Computer Science Department Colluquium Series ndash p20

Determing if a Voxel is On

For each voxel in the lattice compute thedistance to each side of the cube

Test if this distance is bounded by the depthbuffers in each axis

If so voxel is inside otherwise its outside

Holes not visable from outside the object willbe filled

Computer Science Department Colluquium Series ndash p21

Determining a Voxelrsquos Color

Find the depth map which is closest to thevoxel

Look up the voxelrsquos color in the depth maprsquoscorrespoding color map

Interior voxels share the same color asclosest surface voxel

Computer Science Department Colluquium Series ndash p22

Voxelization Algorithm Notes

Works for polygonal and analytical models

Efficiency is independent of modelcomplexity

Voxelizes data in O(n)

Does not handle concave models

Computer Science Department Colluquium Series ndash p23

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 6: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Problem Definition

Problem Given a three-dimensional model howcan we build that model using plasticconstruction bricks

Our answer Create a voxelization of the modelthen represent that voxelization as a set ofLDraw parts which have been carefully selectedto produce a buildable version of the model

Computer Science Department Colluquium Series ndash p5

Problem In Pictures

rarr

Computer Science Department Colluquium Series ndash p6

Problem In Pictures

rarr

Computer Science Department Colluquium Series ndash p6

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Representing 3D Models As Voxels

Computer Science Department Colluquium Series ndash p8

Voxelization

Given a polygonal model generate a set ofvoxels

Computer Science Department Colluquium Series ndash p9

What is a voxel

A small 3D box with some properties(density color etc)

Short for volume element

3D counterpart of a 2D pixel

Computer Science Department Colluquium Series ndash p10

Voxelization

Process of converting a geometricrepresentation of a synthetic model into a setof voxels

Some processes are easier to use whenoperating on voxel data

Computing VolumeCSG (Intersection Union etc)Collision Detection

The reverse is also true Voxels are notoptimal for everything

Computer Science Department Colluquium Series ndash p11

Voxelization

Several methods for generating avoxelization exist

Casting RaysScan Converting

Most are not pretty to code

Can be slow

Can we speed it up Yes use the GPU

See httpwwwcssunysbedu vislabprojectsvolumePapersVoxel

Computer Science Department Colluquium Series ndash p12

Hardware Accelerated Voxelization

Modern graphics hardware is fast (exceedingMoorersquos Law)

Modern graphics hardware is programmable

Computationally expensive algorithms arebeing offloaded to the GPU

Fast Fourier TransformGlobal Illumination ComputationsPath Finding (AI)Collision Detection

Computer Science Department Colluquium Series ndash p13

Hardware Accelerated Voxelization

Turns out we donrsquot need to use theprogrammable GPU

Standard fixed function color and depthbuffers will suffice

Color buffer stores the color of each pixel inthe rendered scene

But what is the depth buffer

Computer Science Department Colluquium Series ndash p14

Depth Buffer

Also known as the Z-buffer

Stores the depth of each pixel in the scene

Values range from [01]

Usually initialized to 1

Smaller values are closer to the near clipplane (camera)

Traditionally used for hidden surface removal

Computer Science Department Colluquium Series ndash p15

Depth Buffer Example

Computer Science Department Colluquium Series ndash p16

HW Voxelization Algorithm

Center mesh around world origin

Set viewport to NtimesN where N is the size of adimension in the NtimesNtimesN voxel lattice

Render scene through a tightly fittedorthographic (parallel) projection from eachside of the modelrsquos bounding box

Record depth and color buffers from eachrender

Produces six set of images (6 color bufferimages 6 depth buffer images)

See httpwwwacmorgjgtpapersKarabassiEtAl99b

Computer Science Department Colluquium Series ndash p17

DepthColor Buffer Visualization

FrontBack

Computer Science Department Colluquium Series ndash p18

DepthColor Buffer Visualization

LeftRight

Computer Science Department Colluquium Series ndash p19

DepthColor Buffer Visualization

TopBottom

Computer Science Department Colluquium Series ndash p20

Determing if a Voxel is On

For each voxel in the lattice compute thedistance to each side of the cube

Test if this distance is bounded by the depthbuffers in each axis

If so voxel is inside otherwise its outside

Holes not visable from outside the object willbe filled

Computer Science Department Colluquium Series ndash p21

Determining a Voxelrsquos Color

Find the depth map which is closest to thevoxel

Look up the voxelrsquos color in the depth maprsquoscorrespoding color map

Interior voxels share the same color asclosest surface voxel

Computer Science Department Colluquium Series ndash p22

Voxelization Algorithm Notes

Works for polygonal and analytical models

Efficiency is independent of modelcomplexity

Voxelizes data in O(n)

Does not handle concave models

Computer Science Department Colluquium Series ndash p23

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 7: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Problem In Pictures

rarr

Computer Science Department Colluquium Series ndash p6

Problem In Pictures

rarr

Computer Science Department Colluquium Series ndash p6

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Representing 3D Models As Voxels

Computer Science Department Colluquium Series ndash p8

Voxelization

Given a polygonal model generate a set ofvoxels

Computer Science Department Colluquium Series ndash p9

What is a voxel

A small 3D box with some properties(density color etc)

Short for volume element

3D counterpart of a 2D pixel

Computer Science Department Colluquium Series ndash p10

Voxelization

Process of converting a geometricrepresentation of a synthetic model into a setof voxels

Some processes are easier to use whenoperating on voxel data

Computing VolumeCSG (Intersection Union etc)Collision Detection

The reverse is also true Voxels are notoptimal for everything

Computer Science Department Colluquium Series ndash p11

Voxelization

Several methods for generating avoxelization exist

Casting RaysScan Converting

Most are not pretty to code

Can be slow

Can we speed it up Yes use the GPU

See httpwwwcssunysbedu vislabprojectsvolumePapersVoxel

Computer Science Department Colluquium Series ndash p12

Hardware Accelerated Voxelization

Modern graphics hardware is fast (exceedingMoorersquos Law)

Modern graphics hardware is programmable

Computationally expensive algorithms arebeing offloaded to the GPU

Fast Fourier TransformGlobal Illumination ComputationsPath Finding (AI)Collision Detection

Computer Science Department Colluquium Series ndash p13

Hardware Accelerated Voxelization

Turns out we donrsquot need to use theprogrammable GPU

Standard fixed function color and depthbuffers will suffice

Color buffer stores the color of each pixel inthe rendered scene

But what is the depth buffer

Computer Science Department Colluquium Series ndash p14

Depth Buffer

Also known as the Z-buffer

Stores the depth of each pixel in the scene

Values range from [01]

Usually initialized to 1

Smaller values are closer to the near clipplane (camera)

Traditionally used for hidden surface removal

Computer Science Department Colluquium Series ndash p15

Depth Buffer Example

Computer Science Department Colluquium Series ndash p16

HW Voxelization Algorithm

Center mesh around world origin

Set viewport to NtimesN where N is the size of adimension in the NtimesNtimesN voxel lattice

Render scene through a tightly fittedorthographic (parallel) projection from eachside of the modelrsquos bounding box

Record depth and color buffers from eachrender

Produces six set of images (6 color bufferimages 6 depth buffer images)

See httpwwwacmorgjgtpapersKarabassiEtAl99b

Computer Science Department Colluquium Series ndash p17

DepthColor Buffer Visualization

FrontBack

Computer Science Department Colluquium Series ndash p18

DepthColor Buffer Visualization

LeftRight

Computer Science Department Colluquium Series ndash p19

DepthColor Buffer Visualization

TopBottom

Computer Science Department Colluquium Series ndash p20

Determing if a Voxel is On

For each voxel in the lattice compute thedistance to each side of the cube

Test if this distance is bounded by the depthbuffers in each axis

If so voxel is inside otherwise its outside

Holes not visable from outside the object willbe filled

Computer Science Department Colluquium Series ndash p21

Determining a Voxelrsquos Color

Find the depth map which is closest to thevoxel

Look up the voxelrsquos color in the depth maprsquoscorrespoding color map

Interior voxels share the same color asclosest surface voxel

Computer Science Department Colluquium Series ndash p22

Voxelization Algorithm Notes

Works for polygonal and analytical models

Efficiency is independent of modelcomplexity

Voxelizes data in O(n)

Does not handle concave models

Computer Science Department Colluquium Series ndash p23

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 8: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Problem In Pictures

rarr

Computer Science Department Colluquium Series ndash p6

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Representing 3D Models As Voxels

Computer Science Department Colluquium Series ndash p8

Voxelization

Given a polygonal model generate a set ofvoxels

Computer Science Department Colluquium Series ndash p9

What is a voxel

A small 3D box with some properties(density color etc)

Short for volume element

3D counterpart of a 2D pixel

Computer Science Department Colluquium Series ndash p10

Voxelization

Process of converting a geometricrepresentation of a synthetic model into a setof voxels

Some processes are easier to use whenoperating on voxel data

Computing VolumeCSG (Intersection Union etc)Collision Detection

The reverse is also true Voxels are notoptimal for everything

Computer Science Department Colluquium Series ndash p11

Voxelization

Several methods for generating avoxelization exist

Casting RaysScan Converting

Most are not pretty to code

Can be slow

Can we speed it up Yes use the GPU

See httpwwwcssunysbedu vislabprojectsvolumePapersVoxel

Computer Science Department Colluquium Series ndash p12

Hardware Accelerated Voxelization

Modern graphics hardware is fast (exceedingMoorersquos Law)

Modern graphics hardware is programmable

Computationally expensive algorithms arebeing offloaded to the GPU

Fast Fourier TransformGlobal Illumination ComputationsPath Finding (AI)Collision Detection

Computer Science Department Colluquium Series ndash p13

Hardware Accelerated Voxelization

Turns out we donrsquot need to use theprogrammable GPU

Standard fixed function color and depthbuffers will suffice

Color buffer stores the color of each pixel inthe rendered scene

But what is the depth buffer

Computer Science Department Colluquium Series ndash p14

Depth Buffer

Also known as the Z-buffer

Stores the depth of each pixel in the scene

Values range from [01]

Usually initialized to 1

Smaller values are closer to the near clipplane (camera)

Traditionally used for hidden surface removal

Computer Science Department Colluquium Series ndash p15

Depth Buffer Example

Computer Science Department Colluquium Series ndash p16

HW Voxelization Algorithm

Center mesh around world origin

Set viewport to NtimesN where N is the size of adimension in the NtimesNtimesN voxel lattice

Render scene through a tightly fittedorthographic (parallel) projection from eachside of the modelrsquos bounding box

Record depth and color buffers from eachrender

Produces six set of images (6 color bufferimages 6 depth buffer images)

See httpwwwacmorgjgtpapersKarabassiEtAl99b

Computer Science Department Colluquium Series ndash p17

DepthColor Buffer Visualization

FrontBack

Computer Science Department Colluquium Series ndash p18

DepthColor Buffer Visualization

LeftRight

Computer Science Department Colluquium Series ndash p19

DepthColor Buffer Visualization

TopBottom

Computer Science Department Colluquium Series ndash p20

Determing if a Voxel is On

For each voxel in the lattice compute thedistance to each side of the cube

Test if this distance is bounded by the depthbuffers in each axis

If so voxel is inside otherwise its outside

Holes not visable from outside the object willbe filled

Computer Science Department Colluquium Series ndash p21

Determining a Voxelrsquos Color

Find the depth map which is closest to thevoxel

Look up the voxelrsquos color in the depth maprsquoscorrespoding color map

Interior voxels share the same color asclosest surface voxel

Computer Science Department Colluquium Series ndash p22

Voxelization Algorithm Notes

Works for polygonal and analytical models

Efficiency is independent of modelcomplexity

Voxelizes data in O(n)

Does not handle concave models

Computer Science Department Colluquium Series ndash p23

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 9: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Representing 3D Models As Voxels

Computer Science Department Colluquium Series ndash p8

Voxelization

Given a polygonal model generate a set ofvoxels

Computer Science Department Colluquium Series ndash p9

What is a voxel

A small 3D box with some properties(density color etc)

Short for volume element

3D counterpart of a 2D pixel

Computer Science Department Colluquium Series ndash p10

Voxelization

Process of converting a geometricrepresentation of a synthetic model into a setof voxels

Some processes are easier to use whenoperating on voxel data

Computing VolumeCSG (Intersection Union etc)Collision Detection

The reverse is also true Voxels are notoptimal for everything

Computer Science Department Colluquium Series ndash p11

Voxelization

Several methods for generating avoxelization exist

Casting RaysScan Converting

Most are not pretty to code

Can be slow

Can we speed it up Yes use the GPU

See httpwwwcssunysbedu vislabprojectsvolumePapersVoxel

Computer Science Department Colluquium Series ndash p12

Hardware Accelerated Voxelization

Modern graphics hardware is fast (exceedingMoorersquos Law)

Modern graphics hardware is programmable

Computationally expensive algorithms arebeing offloaded to the GPU

Fast Fourier TransformGlobal Illumination ComputationsPath Finding (AI)Collision Detection

Computer Science Department Colluquium Series ndash p13

Hardware Accelerated Voxelization

Turns out we donrsquot need to use theprogrammable GPU

Standard fixed function color and depthbuffers will suffice

Color buffer stores the color of each pixel inthe rendered scene

But what is the depth buffer

Computer Science Department Colluquium Series ndash p14

Depth Buffer

Also known as the Z-buffer

Stores the depth of each pixel in the scene

Values range from [01]

Usually initialized to 1

Smaller values are closer to the near clipplane (camera)

Traditionally used for hidden surface removal

Computer Science Department Colluquium Series ndash p15

Depth Buffer Example

Computer Science Department Colluquium Series ndash p16

HW Voxelization Algorithm

Center mesh around world origin

Set viewport to NtimesN where N is the size of adimension in the NtimesNtimesN voxel lattice

Render scene through a tightly fittedorthographic (parallel) projection from eachside of the modelrsquos bounding box

Record depth and color buffers from eachrender

Produces six set of images (6 color bufferimages 6 depth buffer images)

See httpwwwacmorgjgtpapersKarabassiEtAl99b

Computer Science Department Colluquium Series ndash p17

DepthColor Buffer Visualization

FrontBack

Computer Science Department Colluquium Series ndash p18

DepthColor Buffer Visualization

LeftRight

Computer Science Department Colluquium Series ndash p19

DepthColor Buffer Visualization

TopBottom

Computer Science Department Colluquium Series ndash p20

Determing if a Voxel is On

For each voxel in the lattice compute thedistance to each side of the cube

Test if this distance is bounded by the depthbuffers in each axis

If so voxel is inside otherwise its outside

Holes not visable from outside the object willbe filled

Computer Science Department Colluquium Series ndash p21

Determining a Voxelrsquos Color

Find the depth map which is closest to thevoxel

Look up the voxelrsquos color in the depth maprsquoscorrespoding color map

Interior voxels share the same color asclosest surface voxel

Computer Science Department Colluquium Series ndash p22

Voxelization Algorithm Notes

Works for polygonal and analytical models

Efficiency is independent of modelcomplexity

Voxelizes data in O(n)

Does not handle concave models

Computer Science Department Colluquium Series ndash p23

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 10: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Representing 3D Models As Voxels

Computer Science Department Colluquium Series ndash p8

Voxelization

Given a polygonal model generate a set ofvoxels

Computer Science Department Colluquium Series ndash p9

What is a voxel

A small 3D box with some properties(density color etc)

Short for volume element

3D counterpart of a 2D pixel

Computer Science Department Colluquium Series ndash p10

Voxelization

Process of converting a geometricrepresentation of a synthetic model into a setof voxels

Some processes are easier to use whenoperating on voxel data

Computing VolumeCSG (Intersection Union etc)Collision Detection

The reverse is also true Voxels are notoptimal for everything

Computer Science Department Colluquium Series ndash p11

Voxelization

Several methods for generating avoxelization exist

Casting RaysScan Converting

Most are not pretty to code

Can be slow

Can we speed it up Yes use the GPU

See httpwwwcssunysbedu vislabprojectsvolumePapersVoxel

Computer Science Department Colluquium Series ndash p12

Hardware Accelerated Voxelization

Modern graphics hardware is fast (exceedingMoorersquos Law)

Modern graphics hardware is programmable

Computationally expensive algorithms arebeing offloaded to the GPU

Fast Fourier TransformGlobal Illumination ComputationsPath Finding (AI)Collision Detection

Computer Science Department Colluquium Series ndash p13

Hardware Accelerated Voxelization

Turns out we donrsquot need to use theprogrammable GPU

Standard fixed function color and depthbuffers will suffice

Color buffer stores the color of each pixel inthe rendered scene

But what is the depth buffer

Computer Science Department Colluquium Series ndash p14

Depth Buffer

Also known as the Z-buffer

Stores the depth of each pixel in the scene

Values range from [01]

Usually initialized to 1

Smaller values are closer to the near clipplane (camera)

Traditionally used for hidden surface removal

Computer Science Department Colluquium Series ndash p15

Depth Buffer Example

Computer Science Department Colluquium Series ndash p16

HW Voxelization Algorithm

Center mesh around world origin

Set viewport to NtimesN where N is the size of adimension in the NtimesNtimesN voxel lattice

Render scene through a tightly fittedorthographic (parallel) projection from eachside of the modelrsquos bounding box

Record depth and color buffers from eachrender

Produces six set of images (6 color bufferimages 6 depth buffer images)

See httpwwwacmorgjgtpapersKarabassiEtAl99b

Computer Science Department Colluquium Series ndash p17

DepthColor Buffer Visualization

FrontBack

Computer Science Department Colluquium Series ndash p18

DepthColor Buffer Visualization

LeftRight

Computer Science Department Colluquium Series ndash p19

DepthColor Buffer Visualization

TopBottom

Computer Science Department Colluquium Series ndash p20

Determing if a Voxel is On

For each voxel in the lattice compute thedistance to each side of the cube

Test if this distance is bounded by the depthbuffers in each axis

If so voxel is inside otherwise its outside

Holes not visable from outside the object willbe filled

Computer Science Department Colluquium Series ndash p21

Determining a Voxelrsquos Color

Find the depth map which is closest to thevoxel

Look up the voxelrsquos color in the depth maprsquoscorrespoding color map

Interior voxels share the same color asclosest surface voxel

Computer Science Department Colluquium Series ndash p22

Voxelization Algorithm Notes

Works for polygonal and analytical models

Efficiency is independent of modelcomplexity

Voxelizes data in O(n)

Does not handle concave models

Computer Science Department Colluquium Series ndash p23

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 11: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Motivation

Artistic expressionMosaicsSculpturesMusic videosAnimations

Technical idea + creativityrArr publication

Block construction turns out to be aninteresting problem

Computer Science Department Colluquium Series ndash p7

Representing 3D Models As Voxels

Computer Science Department Colluquium Series ndash p8

Voxelization

Given a polygonal model generate a set ofvoxels

Computer Science Department Colluquium Series ndash p9

What is a voxel

A small 3D box with some properties(density color etc)

Short for volume element

3D counterpart of a 2D pixel

Computer Science Department Colluquium Series ndash p10

Voxelization

Process of converting a geometricrepresentation of a synthetic model into a setof voxels

Some processes are easier to use whenoperating on voxel data

Computing VolumeCSG (Intersection Union etc)Collision Detection

The reverse is also true Voxels are notoptimal for everything

Computer Science Department Colluquium Series ndash p11

Voxelization

Several methods for generating avoxelization exist

Casting RaysScan Converting

Most are not pretty to code

Can be slow

Can we speed it up Yes use the GPU

See httpwwwcssunysbedu vislabprojectsvolumePapersVoxel

Computer Science Department Colluquium Series ndash p12

Hardware Accelerated Voxelization

Modern graphics hardware is fast (exceedingMoorersquos Law)

Modern graphics hardware is programmable

Computationally expensive algorithms arebeing offloaded to the GPU

Fast Fourier TransformGlobal Illumination ComputationsPath Finding (AI)Collision Detection

Computer Science Department Colluquium Series ndash p13

Hardware Accelerated Voxelization

Turns out we donrsquot need to use theprogrammable GPU

Standard fixed function color and depthbuffers will suffice

Color buffer stores the color of each pixel inthe rendered scene

But what is the depth buffer

Computer Science Department Colluquium Series ndash p14

Depth Buffer

Also known as the Z-buffer

Stores the depth of each pixel in the scene

Values range from [01]

Usually initialized to 1

Smaller values are closer to the near clipplane (camera)

Traditionally used for hidden surface removal

Computer Science Department Colluquium Series ndash p15

Depth Buffer Example

Computer Science Department Colluquium Series ndash p16

HW Voxelization Algorithm

Center mesh around world origin

Set viewport to NtimesN where N is the size of adimension in the NtimesNtimesN voxel lattice

Render scene through a tightly fittedorthographic (parallel) projection from eachside of the modelrsquos bounding box

Record depth and color buffers from eachrender

Produces six set of images (6 color bufferimages 6 depth buffer images)

See httpwwwacmorgjgtpapersKarabassiEtAl99b

Computer Science Department Colluquium Series ndash p17

DepthColor Buffer Visualization

FrontBack

Computer Science Department Colluquium Series ndash p18

DepthColor Buffer Visualization

LeftRight

Computer Science Department Colluquium Series ndash p19

DepthColor Buffer Visualization

TopBottom

Computer Science Department Colluquium Series ndash p20

Determing if a Voxel is On

For each voxel in the lattice compute thedistance to each side of the cube

Test if this distance is bounded by the depthbuffers in each axis

If so voxel is inside otherwise its outside

Holes not visable from outside the object willbe filled

Computer Science Department Colluquium Series ndash p21

Determining a Voxelrsquos Color

Find the depth map which is closest to thevoxel

Look up the voxelrsquos color in the depth maprsquoscorrespoding color map

Interior voxels share the same color asclosest surface voxel

Computer Science Department Colluquium Series ndash p22

Voxelization Algorithm Notes

Works for polygonal and analytical models

Efficiency is independent of modelcomplexity

Voxelizes data in O(n)

Does not handle concave models

Computer Science Department Colluquium Series ndash p23

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 12: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Representing 3D Models As Voxels

Computer Science Department Colluquium Series ndash p8

Voxelization

Given a polygonal model generate a set ofvoxels

Computer Science Department Colluquium Series ndash p9

What is a voxel

A small 3D box with some properties(density color etc)

Short for volume element

3D counterpart of a 2D pixel

Computer Science Department Colluquium Series ndash p10

Voxelization

Process of converting a geometricrepresentation of a synthetic model into a setof voxels

Some processes are easier to use whenoperating on voxel data

Computing VolumeCSG (Intersection Union etc)Collision Detection

The reverse is also true Voxels are notoptimal for everything

Computer Science Department Colluquium Series ndash p11

Voxelization

Several methods for generating avoxelization exist

Casting RaysScan Converting

Most are not pretty to code

Can be slow

Can we speed it up Yes use the GPU

See httpwwwcssunysbedu vislabprojectsvolumePapersVoxel

Computer Science Department Colluquium Series ndash p12

Hardware Accelerated Voxelization

Modern graphics hardware is fast (exceedingMoorersquos Law)

Modern graphics hardware is programmable

Computationally expensive algorithms arebeing offloaded to the GPU

Fast Fourier TransformGlobal Illumination ComputationsPath Finding (AI)Collision Detection

Computer Science Department Colluquium Series ndash p13

Hardware Accelerated Voxelization

Turns out we donrsquot need to use theprogrammable GPU

Standard fixed function color and depthbuffers will suffice

Color buffer stores the color of each pixel inthe rendered scene

But what is the depth buffer

Computer Science Department Colluquium Series ndash p14

Depth Buffer

Also known as the Z-buffer

Stores the depth of each pixel in the scene

Values range from [01]

Usually initialized to 1

Smaller values are closer to the near clipplane (camera)

Traditionally used for hidden surface removal

Computer Science Department Colluquium Series ndash p15

Depth Buffer Example

Computer Science Department Colluquium Series ndash p16

HW Voxelization Algorithm

Center mesh around world origin

Set viewport to NtimesN where N is the size of adimension in the NtimesNtimesN voxel lattice

Render scene through a tightly fittedorthographic (parallel) projection from eachside of the modelrsquos bounding box

Record depth and color buffers from eachrender

Produces six set of images (6 color bufferimages 6 depth buffer images)

See httpwwwacmorgjgtpapersKarabassiEtAl99b

Computer Science Department Colluquium Series ndash p17

DepthColor Buffer Visualization

FrontBack

Computer Science Department Colluquium Series ndash p18

DepthColor Buffer Visualization

LeftRight

Computer Science Department Colluquium Series ndash p19

DepthColor Buffer Visualization

TopBottom

Computer Science Department Colluquium Series ndash p20

Determing if a Voxel is On

For each voxel in the lattice compute thedistance to each side of the cube

Test if this distance is bounded by the depthbuffers in each axis

If so voxel is inside otherwise its outside

Holes not visable from outside the object willbe filled

Computer Science Department Colluquium Series ndash p21

Determining a Voxelrsquos Color

Find the depth map which is closest to thevoxel

Look up the voxelrsquos color in the depth maprsquoscorrespoding color map

Interior voxels share the same color asclosest surface voxel

Computer Science Department Colluquium Series ndash p22

Voxelization Algorithm Notes

Works for polygonal and analytical models

Efficiency is independent of modelcomplexity

Voxelizes data in O(n)

Does not handle concave models

Computer Science Department Colluquium Series ndash p23

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 13: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Voxelization

Given a polygonal model generate a set ofvoxels

Computer Science Department Colluquium Series ndash p9

What is a voxel

A small 3D box with some properties(density color etc)

Short for volume element

3D counterpart of a 2D pixel

Computer Science Department Colluquium Series ndash p10

Voxelization

Process of converting a geometricrepresentation of a synthetic model into a setof voxels

Some processes are easier to use whenoperating on voxel data

Computing VolumeCSG (Intersection Union etc)Collision Detection

The reverse is also true Voxels are notoptimal for everything

Computer Science Department Colluquium Series ndash p11

Voxelization

Several methods for generating avoxelization exist

Casting RaysScan Converting

Most are not pretty to code

Can be slow

Can we speed it up Yes use the GPU

See httpwwwcssunysbedu vislabprojectsvolumePapersVoxel

Computer Science Department Colluquium Series ndash p12

Hardware Accelerated Voxelization

Modern graphics hardware is fast (exceedingMoorersquos Law)

Modern graphics hardware is programmable

Computationally expensive algorithms arebeing offloaded to the GPU

Fast Fourier TransformGlobal Illumination ComputationsPath Finding (AI)Collision Detection

Computer Science Department Colluquium Series ndash p13

Hardware Accelerated Voxelization

Turns out we donrsquot need to use theprogrammable GPU

Standard fixed function color and depthbuffers will suffice

Color buffer stores the color of each pixel inthe rendered scene

But what is the depth buffer

Computer Science Department Colluquium Series ndash p14

Depth Buffer

Also known as the Z-buffer

Stores the depth of each pixel in the scene

Values range from [01]

Usually initialized to 1

Smaller values are closer to the near clipplane (camera)

Traditionally used for hidden surface removal

Computer Science Department Colluquium Series ndash p15

Depth Buffer Example

Computer Science Department Colluquium Series ndash p16

HW Voxelization Algorithm

Center mesh around world origin

Set viewport to NtimesN where N is the size of adimension in the NtimesNtimesN voxel lattice

Render scene through a tightly fittedorthographic (parallel) projection from eachside of the modelrsquos bounding box

Record depth and color buffers from eachrender

Produces six set of images (6 color bufferimages 6 depth buffer images)

See httpwwwacmorgjgtpapersKarabassiEtAl99b

Computer Science Department Colluquium Series ndash p17

DepthColor Buffer Visualization

FrontBack

Computer Science Department Colluquium Series ndash p18

DepthColor Buffer Visualization

LeftRight

Computer Science Department Colluquium Series ndash p19

DepthColor Buffer Visualization

TopBottom

Computer Science Department Colluquium Series ndash p20

Determing if a Voxel is On

For each voxel in the lattice compute thedistance to each side of the cube

Test if this distance is bounded by the depthbuffers in each axis

If so voxel is inside otherwise its outside

Holes not visable from outside the object willbe filled

Computer Science Department Colluquium Series ndash p21

Determining a Voxelrsquos Color

Find the depth map which is closest to thevoxel

Look up the voxelrsquos color in the depth maprsquoscorrespoding color map

Interior voxels share the same color asclosest surface voxel

Computer Science Department Colluquium Series ndash p22

Voxelization Algorithm Notes

Works for polygonal and analytical models

Efficiency is independent of modelcomplexity

Voxelizes data in O(n)

Does not handle concave models

Computer Science Department Colluquium Series ndash p23

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 14: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

What is a voxel

A small 3D box with some properties(density color etc)

Short for volume element

3D counterpart of a 2D pixel

Computer Science Department Colluquium Series ndash p10

Voxelization

Process of converting a geometricrepresentation of a synthetic model into a setof voxels

Some processes are easier to use whenoperating on voxel data

Computing VolumeCSG (Intersection Union etc)Collision Detection

The reverse is also true Voxels are notoptimal for everything

Computer Science Department Colluquium Series ndash p11

Voxelization

Several methods for generating avoxelization exist

Casting RaysScan Converting

Most are not pretty to code

Can be slow

Can we speed it up Yes use the GPU

See httpwwwcssunysbedu vislabprojectsvolumePapersVoxel

Computer Science Department Colluquium Series ndash p12

Hardware Accelerated Voxelization

Modern graphics hardware is fast (exceedingMoorersquos Law)

Modern graphics hardware is programmable

Computationally expensive algorithms arebeing offloaded to the GPU

Fast Fourier TransformGlobal Illumination ComputationsPath Finding (AI)Collision Detection

Computer Science Department Colluquium Series ndash p13

Hardware Accelerated Voxelization

Turns out we donrsquot need to use theprogrammable GPU

Standard fixed function color and depthbuffers will suffice

Color buffer stores the color of each pixel inthe rendered scene

But what is the depth buffer

Computer Science Department Colluquium Series ndash p14

Depth Buffer

Also known as the Z-buffer

Stores the depth of each pixel in the scene

Values range from [01]

Usually initialized to 1

Smaller values are closer to the near clipplane (camera)

Traditionally used for hidden surface removal

Computer Science Department Colluquium Series ndash p15

Depth Buffer Example

Computer Science Department Colluquium Series ndash p16

HW Voxelization Algorithm

Center mesh around world origin

Set viewport to NtimesN where N is the size of adimension in the NtimesNtimesN voxel lattice

Render scene through a tightly fittedorthographic (parallel) projection from eachside of the modelrsquos bounding box

Record depth and color buffers from eachrender

Produces six set of images (6 color bufferimages 6 depth buffer images)

See httpwwwacmorgjgtpapersKarabassiEtAl99b

Computer Science Department Colluquium Series ndash p17

DepthColor Buffer Visualization

FrontBack

Computer Science Department Colluquium Series ndash p18

DepthColor Buffer Visualization

LeftRight

Computer Science Department Colluquium Series ndash p19

DepthColor Buffer Visualization

TopBottom

Computer Science Department Colluquium Series ndash p20

Determing if a Voxel is On

For each voxel in the lattice compute thedistance to each side of the cube

Test if this distance is bounded by the depthbuffers in each axis

If so voxel is inside otherwise its outside

Holes not visable from outside the object willbe filled

Computer Science Department Colluquium Series ndash p21

Determining a Voxelrsquos Color

Find the depth map which is closest to thevoxel

Look up the voxelrsquos color in the depth maprsquoscorrespoding color map

Interior voxels share the same color asclosest surface voxel

Computer Science Department Colluquium Series ndash p22

Voxelization Algorithm Notes

Works for polygonal and analytical models

Efficiency is independent of modelcomplexity

Voxelizes data in O(n)

Does not handle concave models

Computer Science Department Colluquium Series ndash p23

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 15: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Voxelization

Process of converting a geometricrepresentation of a synthetic model into a setof voxels

Some processes are easier to use whenoperating on voxel data

Computing VolumeCSG (Intersection Union etc)Collision Detection

The reverse is also true Voxels are notoptimal for everything

Computer Science Department Colluquium Series ndash p11

Voxelization

Several methods for generating avoxelization exist

Casting RaysScan Converting

Most are not pretty to code

Can be slow

Can we speed it up Yes use the GPU

See httpwwwcssunysbedu vislabprojectsvolumePapersVoxel

Computer Science Department Colluquium Series ndash p12

Hardware Accelerated Voxelization

Modern graphics hardware is fast (exceedingMoorersquos Law)

Modern graphics hardware is programmable

Computationally expensive algorithms arebeing offloaded to the GPU

Fast Fourier TransformGlobal Illumination ComputationsPath Finding (AI)Collision Detection

Computer Science Department Colluquium Series ndash p13

Hardware Accelerated Voxelization

Turns out we donrsquot need to use theprogrammable GPU

Standard fixed function color and depthbuffers will suffice

Color buffer stores the color of each pixel inthe rendered scene

But what is the depth buffer

Computer Science Department Colluquium Series ndash p14

Depth Buffer

Also known as the Z-buffer

Stores the depth of each pixel in the scene

Values range from [01]

Usually initialized to 1

Smaller values are closer to the near clipplane (camera)

Traditionally used for hidden surface removal

Computer Science Department Colluquium Series ndash p15

Depth Buffer Example

Computer Science Department Colluquium Series ndash p16

HW Voxelization Algorithm

Center mesh around world origin

Set viewport to NtimesN where N is the size of adimension in the NtimesNtimesN voxel lattice

Render scene through a tightly fittedorthographic (parallel) projection from eachside of the modelrsquos bounding box

Record depth and color buffers from eachrender

Produces six set of images (6 color bufferimages 6 depth buffer images)

See httpwwwacmorgjgtpapersKarabassiEtAl99b

Computer Science Department Colluquium Series ndash p17

DepthColor Buffer Visualization

FrontBack

Computer Science Department Colluquium Series ndash p18

DepthColor Buffer Visualization

LeftRight

Computer Science Department Colluquium Series ndash p19

DepthColor Buffer Visualization

TopBottom

Computer Science Department Colluquium Series ndash p20

Determing if a Voxel is On

For each voxel in the lattice compute thedistance to each side of the cube

Test if this distance is bounded by the depthbuffers in each axis

If so voxel is inside otherwise its outside

Holes not visable from outside the object willbe filled

Computer Science Department Colluquium Series ndash p21

Determining a Voxelrsquos Color

Find the depth map which is closest to thevoxel

Look up the voxelrsquos color in the depth maprsquoscorrespoding color map

Interior voxels share the same color asclosest surface voxel

Computer Science Department Colluquium Series ndash p22

Voxelization Algorithm Notes

Works for polygonal and analytical models

Efficiency is independent of modelcomplexity

Voxelizes data in O(n)

Does not handle concave models

Computer Science Department Colluquium Series ndash p23

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 16: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Voxelization

Several methods for generating avoxelization exist

Casting RaysScan Converting

Most are not pretty to code

Can be slow

Can we speed it up Yes use the GPU

See httpwwwcssunysbedu vislabprojectsvolumePapersVoxel

Computer Science Department Colluquium Series ndash p12

Hardware Accelerated Voxelization

Modern graphics hardware is fast (exceedingMoorersquos Law)

Modern graphics hardware is programmable

Computationally expensive algorithms arebeing offloaded to the GPU

Fast Fourier TransformGlobal Illumination ComputationsPath Finding (AI)Collision Detection

Computer Science Department Colluquium Series ndash p13

Hardware Accelerated Voxelization

Turns out we donrsquot need to use theprogrammable GPU

Standard fixed function color and depthbuffers will suffice

Color buffer stores the color of each pixel inthe rendered scene

But what is the depth buffer

Computer Science Department Colluquium Series ndash p14

Depth Buffer

Also known as the Z-buffer

Stores the depth of each pixel in the scene

Values range from [01]

Usually initialized to 1

Smaller values are closer to the near clipplane (camera)

Traditionally used for hidden surface removal

Computer Science Department Colluquium Series ndash p15

Depth Buffer Example

Computer Science Department Colluquium Series ndash p16

HW Voxelization Algorithm

Center mesh around world origin

Set viewport to NtimesN where N is the size of adimension in the NtimesNtimesN voxel lattice

Render scene through a tightly fittedorthographic (parallel) projection from eachside of the modelrsquos bounding box

Record depth and color buffers from eachrender

Produces six set of images (6 color bufferimages 6 depth buffer images)

See httpwwwacmorgjgtpapersKarabassiEtAl99b

Computer Science Department Colluquium Series ndash p17

DepthColor Buffer Visualization

FrontBack

Computer Science Department Colluquium Series ndash p18

DepthColor Buffer Visualization

LeftRight

Computer Science Department Colluquium Series ndash p19

DepthColor Buffer Visualization

TopBottom

Computer Science Department Colluquium Series ndash p20

Determing if a Voxel is On

For each voxel in the lattice compute thedistance to each side of the cube

Test if this distance is bounded by the depthbuffers in each axis

If so voxel is inside otherwise its outside

Holes not visable from outside the object willbe filled

Computer Science Department Colluquium Series ndash p21

Determining a Voxelrsquos Color

Find the depth map which is closest to thevoxel

Look up the voxelrsquos color in the depth maprsquoscorrespoding color map

Interior voxels share the same color asclosest surface voxel

Computer Science Department Colluquium Series ndash p22

Voxelization Algorithm Notes

Works for polygonal and analytical models

Efficiency is independent of modelcomplexity

Voxelizes data in O(n)

Does not handle concave models

Computer Science Department Colluquium Series ndash p23

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 17: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Hardware Accelerated Voxelization

Modern graphics hardware is fast (exceedingMoorersquos Law)

Modern graphics hardware is programmable

Computationally expensive algorithms arebeing offloaded to the GPU

Fast Fourier TransformGlobal Illumination ComputationsPath Finding (AI)Collision Detection

Computer Science Department Colluquium Series ndash p13

Hardware Accelerated Voxelization

Turns out we donrsquot need to use theprogrammable GPU

Standard fixed function color and depthbuffers will suffice

Color buffer stores the color of each pixel inthe rendered scene

But what is the depth buffer

Computer Science Department Colluquium Series ndash p14

Depth Buffer

Also known as the Z-buffer

Stores the depth of each pixel in the scene

Values range from [01]

Usually initialized to 1

Smaller values are closer to the near clipplane (camera)

Traditionally used for hidden surface removal

Computer Science Department Colluquium Series ndash p15

Depth Buffer Example

Computer Science Department Colluquium Series ndash p16

HW Voxelization Algorithm

Center mesh around world origin

Set viewport to NtimesN where N is the size of adimension in the NtimesNtimesN voxel lattice

Render scene through a tightly fittedorthographic (parallel) projection from eachside of the modelrsquos bounding box

Record depth and color buffers from eachrender

Produces six set of images (6 color bufferimages 6 depth buffer images)

See httpwwwacmorgjgtpapersKarabassiEtAl99b

Computer Science Department Colluquium Series ndash p17

DepthColor Buffer Visualization

FrontBack

Computer Science Department Colluquium Series ndash p18

DepthColor Buffer Visualization

LeftRight

Computer Science Department Colluquium Series ndash p19

DepthColor Buffer Visualization

TopBottom

Computer Science Department Colluquium Series ndash p20

Determing if a Voxel is On

For each voxel in the lattice compute thedistance to each side of the cube

Test if this distance is bounded by the depthbuffers in each axis

If so voxel is inside otherwise its outside

Holes not visable from outside the object willbe filled

Computer Science Department Colluquium Series ndash p21

Determining a Voxelrsquos Color

Find the depth map which is closest to thevoxel

Look up the voxelrsquos color in the depth maprsquoscorrespoding color map

Interior voxels share the same color asclosest surface voxel

Computer Science Department Colluquium Series ndash p22

Voxelization Algorithm Notes

Works for polygonal and analytical models

Efficiency is independent of modelcomplexity

Voxelizes data in O(n)

Does not handle concave models

Computer Science Department Colluquium Series ndash p23

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 18: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Hardware Accelerated Voxelization

Turns out we donrsquot need to use theprogrammable GPU

Standard fixed function color and depthbuffers will suffice

Color buffer stores the color of each pixel inthe rendered scene

But what is the depth buffer

Computer Science Department Colluquium Series ndash p14

Depth Buffer

Also known as the Z-buffer

Stores the depth of each pixel in the scene

Values range from [01]

Usually initialized to 1

Smaller values are closer to the near clipplane (camera)

Traditionally used for hidden surface removal

Computer Science Department Colluquium Series ndash p15

Depth Buffer Example

Computer Science Department Colluquium Series ndash p16

HW Voxelization Algorithm

Center mesh around world origin

Set viewport to NtimesN where N is the size of adimension in the NtimesNtimesN voxel lattice

Render scene through a tightly fittedorthographic (parallel) projection from eachside of the modelrsquos bounding box

Record depth and color buffers from eachrender

Produces six set of images (6 color bufferimages 6 depth buffer images)

See httpwwwacmorgjgtpapersKarabassiEtAl99b

Computer Science Department Colluquium Series ndash p17

DepthColor Buffer Visualization

FrontBack

Computer Science Department Colluquium Series ndash p18

DepthColor Buffer Visualization

LeftRight

Computer Science Department Colluquium Series ndash p19

DepthColor Buffer Visualization

TopBottom

Computer Science Department Colluquium Series ndash p20

Determing if a Voxel is On

For each voxel in the lattice compute thedistance to each side of the cube

Test if this distance is bounded by the depthbuffers in each axis

If so voxel is inside otherwise its outside

Holes not visable from outside the object willbe filled

Computer Science Department Colluquium Series ndash p21

Determining a Voxelrsquos Color

Find the depth map which is closest to thevoxel

Look up the voxelrsquos color in the depth maprsquoscorrespoding color map

Interior voxels share the same color asclosest surface voxel

Computer Science Department Colluquium Series ndash p22

Voxelization Algorithm Notes

Works for polygonal and analytical models

Efficiency is independent of modelcomplexity

Voxelizes data in O(n)

Does not handle concave models

Computer Science Department Colluquium Series ndash p23

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 19: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Depth Buffer

Also known as the Z-buffer

Stores the depth of each pixel in the scene

Values range from [01]

Usually initialized to 1

Smaller values are closer to the near clipplane (camera)

Traditionally used for hidden surface removal

Computer Science Department Colluquium Series ndash p15

Depth Buffer Example

Computer Science Department Colluquium Series ndash p16

HW Voxelization Algorithm

Center mesh around world origin

Set viewport to NtimesN where N is the size of adimension in the NtimesNtimesN voxel lattice

Render scene through a tightly fittedorthographic (parallel) projection from eachside of the modelrsquos bounding box

Record depth and color buffers from eachrender

Produces six set of images (6 color bufferimages 6 depth buffer images)

See httpwwwacmorgjgtpapersKarabassiEtAl99b

Computer Science Department Colluquium Series ndash p17

DepthColor Buffer Visualization

FrontBack

Computer Science Department Colluquium Series ndash p18

DepthColor Buffer Visualization

LeftRight

Computer Science Department Colluquium Series ndash p19

DepthColor Buffer Visualization

TopBottom

Computer Science Department Colluquium Series ndash p20

Determing if a Voxel is On

For each voxel in the lattice compute thedistance to each side of the cube

Test if this distance is bounded by the depthbuffers in each axis

If so voxel is inside otherwise its outside

Holes not visable from outside the object willbe filled

Computer Science Department Colluquium Series ndash p21

Determining a Voxelrsquos Color

Find the depth map which is closest to thevoxel

Look up the voxelrsquos color in the depth maprsquoscorrespoding color map

Interior voxels share the same color asclosest surface voxel

Computer Science Department Colluquium Series ndash p22

Voxelization Algorithm Notes

Works for polygonal and analytical models

Efficiency is independent of modelcomplexity

Voxelizes data in O(n)

Does not handle concave models

Computer Science Department Colluquium Series ndash p23

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 20: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Depth Buffer Example

Computer Science Department Colluquium Series ndash p16

HW Voxelization Algorithm

Center mesh around world origin

Set viewport to NtimesN where N is the size of adimension in the NtimesNtimesN voxel lattice

Render scene through a tightly fittedorthographic (parallel) projection from eachside of the modelrsquos bounding box

Record depth and color buffers from eachrender

Produces six set of images (6 color bufferimages 6 depth buffer images)

See httpwwwacmorgjgtpapersKarabassiEtAl99b

Computer Science Department Colluquium Series ndash p17

DepthColor Buffer Visualization

FrontBack

Computer Science Department Colluquium Series ndash p18

DepthColor Buffer Visualization

LeftRight

Computer Science Department Colluquium Series ndash p19

DepthColor Buffer Visualization

TopBottom

Computer Science Department Colluquium Series ndash p20

Determing if a Voxel is On

For each voxel in the lattice compute thedistance to each side of the cube

Test if this distance is bounded by the depthbuffers in each axis

If so voxel is inside otherwise its outside

Holes not visable from outside the object willbe filled

Computer Science Department Colluquium Series ndash p21

Determining a Voxelrsquos Color

Find the depth map which is closest to thevoxel

Look up the voxelrsquos color in the depth maprsquoscorrespoding color map

Interior voxels share the same color asclosest surface voxel

Computer Science Department Colluquium Series ndash p22

Voxelization Algorithm Notes

Works for polygonal and analytical models

Efficiency is independent of modelcomplexity

Voxelizes data in O(n)

Does not handle concave models

Computer Science Department Colluquium Series ndash p23

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 21: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

HW Voxelization Algorithm

Center mesh around world origin

Set viewport to NtimesN where N is the size of adimension in the NtimesNtimesN voxel lattice

Render scene through a tightly fittedorthographic (parallel) projection from eachside of the modelrsquos bounding box

Record depth and color buffers from eachrender

Produces six set of images (6 color bufferimages 6 depth buffer images)

See httpwwwacmorgjgtpapersKarabassiEtAl99b

Computer Science Department Colluquium Series ndash p17

DepthColor Buffer Visualization

FrontBack

Computer Science Department Colluquium Series ndash p18

DepthColor Buffer Visualization

LeftRight

Computer Science Department Colluquium Series ndash p19

DepthColor Buffer Visualization

TopBottom

Computer Science Department Colluquium Series ndash p20

Determing if a Voxel is On

For each voxel in the lattice compute thedistance to each side of the cube

Test if this distance is bounded by the depthbuffers in each axis

If so voxel is inside otherwise its outside

Holes not visable from outside the object willbe filled

Computer Science Department Colluquium Series ndash p21

Determining a Voxelrsquos Color

Find the depth map which is closest to thevoxel

Look up the voxelrsquos color in the depth maprsquoscorrespoding color map

Interior voxels share the same color asclosest surface voxel

Computer Science Department Colluquium Series ndash p22

Voxelization Algorithm Notes

Works for polygonal and analytical models

Efficiency is independent of modelcomplexity

Voxelizes data in O(n)

Does not handle concave models

Computer Science Department Colluquium Series ndash p23

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 22: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

DepthColor Buffer Visualization

FrontBack

Computer Science Department Colluquium Series ndash p18

DepthColor Buffer Visualization

LeftRight

Computer Science Department Colluquium Series ndash p19

DepthColor Buffer Visualization

TopBottom

Computer Science Department Colluquium Series ndash p20

Determing if a Voxel is On

For each voxel in the lattice compute thedistance to each side of the cube

Test if this distance is bounded by the depthbuffers in each axis

If so voxel is inside otherwise its outside

Holes not visable from outside the object willbe filled

Computer Science Department Colluquium Series ndash p21

Determining a Voxelrsquos Color

Find the depth map which is closest to thevoxel

Look up the voxelrsquos color in the depth maprsquoscorrespoding color map

Interior voxels share the same color asclosest surface voxel

Computer Science Department Colluquium Series ndash p22

Voxelization Algorithm Notes

Works for polygonal and analytical models

Efficiency is independent of modelcomplexity

Voxelizes data in O(n)

Does not handle concave models

Computer Science Department Colluquium Series ndash p23

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 23: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

DepthColor Buffer Visualization

LeftRight

Computer Science Department Colluquium Series ndash p19

DepthColor Buffer Visualization

TopBottom

Computer Science Department Colluquium Series ndash p20

Determing if a Voxel is On

For each voxel in the lattice compute thedistance to each side of the cube

Test if this distance is bounded by the depthbuffers in each axis

If so voxel is inside otherwise its outside

Holes not visable from outside the object willbe filled

Computer Science Department Colluquium Series ndash p21

Determining a Voxelrsquos Color

Find the depth map which is closest to thevoxel

Look up the voxelrsquos color in the depth maprsquoscorrespoding color map

Interior voxels share the same color asclosest surface voxel

Computer Science Department Colluquium Series ndash p22

Voxelization Algorithm Notes

Works for polygonal and analytical models

Efficiency is independent of modelcomplexity

Voxelizes data in O(n)

Does not handle concave models

Computer Science Department Colluquium Series ndash p23

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 24: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

DepthColor Buffer Visualization

TopBottom

Computer Science Department Colluquium Series ndash p20

Determing if a Voxel is On

For each voxel in the lattice compute thedistance to each side of the cube

Test if this distance is bounded by the depthbuffers in each axis

If so voxel is inside otherwise its outside

Holes not visable from outside the object willbe filled

Computer Science Department Colluquium Series ndash p21

Determining a Voxelrsquos Color

Find the depth map which is closest to thevoxel

Look up the voxelrsquos color in the depth maprsquoscorrespoding color map

Interior voxels share the same color asclosest surface voxel

Computer Science Department Colluquium Series ndash p22

Voxelization Algorithm Notes

Works for polygonal and analytical models

Efficiency is independent of modelcomplexity

Voxelizes data in O(n)

Does not handle concave models

Computer Science Department Colluquium Series ndash p23

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 25: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Determing if a Voxel is On

For each voxel in the lattice compute thedistance to each side of the cube

Test if this distance is bounded by the depthbuffers in each axis

If so voxel is inside otherwise its outside

Holes not visable from outside the object willbe filled

Computer Science Department Colluquium Series ndash p21

Determining a Voxelrsquos Color

Find the depth map which is closest to thevoxel

Look up the voxelrsquos color in the depth maprsquoscorrespoding color map

Interior voxels share the same color asclosest surface voxel

Computer Science Department Colluquium Series ndash p22

Voxelization Algorithm Notes

Works for polygonal and analytical models

Efficiency is independent of modelcomplexity

Voxelizes data in O(n)

Does not handle concave models

Computer Science Department Colluquium Series ndash p23

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 26: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Determining a Voxelrsquos Color

Find the depth map which is closest to thevoxel

Look up the voxelrsquos color in the depth maprsquoscorrespoding color map

Interior voxels share the same color asclosest surface voxel

Computer Science Department Colluquium Series ndash p22

Voxelization Algorithm Notes

Works for polygonal and analytical models

Efficiency is independent of modelcomplexity

Voxelizes data in O(n)

Does not handle concave models

Computer Science Department Colluquium Series ndash p23

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 27: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Voxelization Algorithm Notes

Works for polygonal and analytical models

Efficiency is independent of modelcomplexity

Voxelizes data in O(n)

Does not handle concave models

Computer Science Department Colluquium Series ndash p23

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 28: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Voxel Visualization

Can view voxel data as slices

Viewing voxel data is useful for manyapplication specifically in medicine

See httpwwwnlmnihgovresearchvisiblevisible_humanhtml

Computer Science Department Colluquium Series ndash p24

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 29: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Plastic Construction Brick Specifics

Plastic Construction Bricks are not cubes

A 1times1 brick has a 56 aspect ratio

Model must be squashed during voxelizationto perserve aspect ratio

Computer Science Department Colluquium Series ndash p25

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 30: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Demo

Computer Science Department Colluquium Series ndash p26

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 31: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Representing 2D Images As Voxels

Computer Science Department Colluquium Series ndash p27

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 32: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Voxelization of Images

Goal Given any 2D image output avoxelization

Pixels directly correspond to a voxel slice

Perform image scaling to reduceenlarge todesired number of voxels

Computer Science Department Colluquium Series ndash p28

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 33: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Brick Mosaics

Studs-up Studs-out

X-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 34: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Brick Mosaics

Studs-up Studs-outX-Y plane X-Z plane

Computer Science Department Colluquium Series ndash p29

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 35: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Giving Voxels Color

Platic Construction Bricks have a limitednumber of colors

Convert image to brick palette

Problem Limited number of colors in brickpalette causes banding

Computer Science Department Colluquium Series ndash p30

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 36: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Converting to Brick Palette

Solution Dither the image

Dithering is the addition of a sub-quantumsignal (often high frequency noise) to asignal of interest that is being quantized

Many dithering algorithms exist

Computer Science Department Colluquium Series ndash p31

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 37: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Dithering

We use Floyd-Steinberg dithering

Spreads error in quantization overneighboring pixels

Computer Science Department Colluquium Series ndash p32

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 38: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Generating a Construction Plan

We use a simple greedy algorithm thatprocesses 1 brick row at a time

Computer Science Department Colluquium Series ndash p33

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 39: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Converting Voxels To PlasticConstruction Bricks

Computer Science Department Colluquium Series ndash p34

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 40: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

What Is LDraw

Originally DOS programs LDraw and LEditwith a file format representing severaldifferent plastic construction brick shapes

Many editors have been developed using theLDraw parts file format

Programs exist to convert to a variety of 3Dapplications

Maintained by a standards committee now

Computer Science Department Colluquium Series ndash p35

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 41: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

LDraw File Format

ASCII text

First value is an integer indicating line type

Line Type

0 comment or meta-command

1 reference to another LDraw file

2 line between two points

3 triangle

4 quadrilateral

5 conditional line between two points

Computer Science Department Colluquium Series ndash p36

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 42: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

LDraw File Format (cont)

Reference line type is as follows1 ltcolorgt lttransformation matrixgt ltfile namegt

Line between two points is as follows2 ltcolorgt ltpoint1gt ltpoint2gt

Triangle line type is as follows3 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt

Quadrilateral line type is as follows4 ltcolorgt ltpoint1gt ltpoint2gt ltpoint3gt ltpoint4gt

Computer Science Department Colluquium Series ndash p37

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 43: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

LDraw Conventions

Brick Sizes - given using aWidthtimesLengthtimesHeight notation

Part Numbers - each different brick is given aunique part number attempts to match thoseused by the LEGOtrade Corporation

Colors - based on those used by the LEGOtradeCorporation each is assigned a uniqueinteger

Computer Science Department Colluquium Series ndash p38

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 44: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 45: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

The Simple Answer

Replace each voxel with a 1x1 brick of theappropriate color Interior voxels can beassigned any color desired

Problem This solution does not create abuildable version of the model

Computer Science Department Colluquium Series ndash p39

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 46: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Algorithm Goals

Replace neighboring voxels of the samecolor with an appropriate brick

Check for support for a brick in the layerabove or below

Use 2timesn bricks whenever possible

Avoid 1times1 bricks whenever possible

Fix building impossibilities

Computer Science Department Colluquium Series ndash p40

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 47: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

A Greedy Algorithm

Voxelization is of size xsize times ysize times zsize

Consider only an X-Z slice of the voxelization

Search for adjacent voxels in the X directionfirst

Search for adjacent voxels in the Z directionsecond

Replace neighboring voxels with the largestbrick possible

Computer Science Department Colluquium Series ndash p41

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 48: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

A Greedy Algorithmrsquos Bricks

1 times 1 1 times 2 1 times 3 1 times 4 1 times 6 1 times 8

2 times 2 2 times 3 2 times 4 2 times 6 2 times 8

Computer Science Department Colluquium Series ndash p42

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 49: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

A Greedy Algorithm (cont)

for (i=ysize minus 1 ige0 i--)

for (k=0 klt zsize k++)

j=0

while (jlt xsize)

start x = FindFirstVoxelX()

end x = FindLastVoxelX()

while(start x le endx)

length x = endx - start x + 1

if (length x == 1)

startz = k

endz = FindLastVoxelZ()

lengthz = endz - startz + 1

Computer Science Department Colluquium Series ndash p43

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 50: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

A Greedy Algorithm (cont)

if (lengthz == 1)

AddBrickZ(1times1)

else if (lengthz == 2)

AddBrickZ(1times2)

else if (lengthz == 4)

AddBrickZ(1times4)

else

AddBrickZ(1times3)

start x += 1

else if (length x2 = 0)

AddBrickX(1times3)

start x += 3

Computer Science Department Colluquium Series ndash p44

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 51: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

A Greedy Algorithm (cont)

else if (length x le 8)

AddBrickX(1timeslength x)

start x += length x

else if (length x == 10)

AddBrickX(1times6)

start x += 6

AddBrickX(1times4)

start x += 4

Computer Science Department Colluquium Series ndash p45

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 52: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

A Greedy Algorithm (cont)

else if (length x == 12)

AddBrickX(1times6)

start x += 6

AddBrickX(1times6)

start x += 6

else

AddBrickX(1times8)

start x += 8

j = endx + 1

Computer Science Department Colluquium Series ndash p46

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 53: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Improvements

Alternate primary greedy direction betweenX and Z

Use L-shaped corner pieces

Connect ldquofloatingrdquo pieces

Use bricks taller than 1

Push smaller bricks to the center

Computer Science Department Colluquium Series ndash p47

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 54: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Results

Computer Science Department Colluquium Series ndash p48

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 55: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Bauul

Computer Science Department Colluquium Series ndash p49

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 56: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Beachball

Computer Science Department Colluquium Series ndash p50

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 57: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Bunny

Computer Science Department Colluquium Series ndash p51

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 58: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Construction Plans

Use a program called LPub

Insert step meta-commands between eachX-Z slice

Example plans

Some reworking done during build

Computer Science Department Colluquium Series ndash p52

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 59: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

References

Computer Science Department Colluquium Series ndash p53

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 60: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

References

ldquoA Fast Depth-Buffer-Based Voxelization AlgorithmrdquoEvaggelia-Aggeliki Karabassi GeorgiosPapaioannou and Theoharis TheoharisACM Journal of Graphics Tools 4(4)5-101999

LDraw website httpwwwldraworg

ldquoVolume Graphicsrdquo Arie Kaufman Daniel Cohenand Roni Yagel IEEE Computer Vol26 No7 July 1993 pg 51-64

Computer Science Department Colluquium Series ndash p54

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media
Page 61: Building 3D Models Using Plastic Construction Bricks · Building 3D Models Using Plastic Construction Bricks Nathan Cournia, Karl Rasche and Andrew Van Pernis facnatha, rkarl, arakelg@vr.clemson.edu.

Media

All source code publically available (via CVS)

uber httpgraphicsvrclemsonedu

CVShttpjetvrclemsoneduviewcvsviewcvscgiuberdemoslegocvsroot=UBER

Computer Science Department Colluquium Series ndash p55

  • Outline
  • Outline
  • Motivation
  • Problem Definition
  • Problem In Pictures
  • Motivation
  • Representing 3D Models As Voxels
  • Voxelization
  • What is a voxel
  • Voxelization
  • Voxelization
  • Hardware Accelerated Voxelization
  • Hardware Accelerated Voxelization
  • Depth Buffer
  • Depth Buffer Example
  • HW Voxelization Algorithm
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • DepthColor Buffer Visualization
  • Determing if a Voxel is On
  • Determining a Voxels Color
  • Voxelization Algorithm Notes
  • Voxel Visualization
  • Plastic Construction Brick Specifics
  • Demo
  • Representing 2D Images As Voxels
  • Voxelization of Images
  • Brick Mosaics
  • Giving Voxels Color
  • Converting to Brick Palette
  • Dithering
  • Generating a Construction Plan
  • Converting Voxels To Plastic Construction Bricks
  • What Is LDraw
  • LDraw File Format
  • LDraw File Format (cont)
  • LDraw Conventions
  • The Simple Answer
  • Algorithm Goals
  • A Greedy Algorithm
  • A Greedy Algorithms Bricks
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • A Greedy Algorithm (cont)
  • Improvements
  • Results
  • Bauul
  • Beachball
  • Bunny
  • Construction Plans
  • References
  • References
  • Media