Title: Procedural Geometry Synthesis on the GPU
1Procedural Geometry Synthesison the GPU
Patrick Lacz and John C. HartUniversity of
Illinois, Urbana-Champaign
We present a technique for creating and rendering
procedurally generated geometry, such as that
created by an L-system, completely on the GPU
using the recent render-to-vertex-array
functionality.
Highlights ? Symbols, graphics state stored in t
exture. ? Productions coded as fragment programs
? Iteration via render-to-texture ? Rendering
via render-to-vertex-array
TextureMemory
VertexShader
FragmentShader
2Transformation of an L-System
L? aLf LLf- LL
Goal Generate geometry resulting from iteration
of a single production that grows each
cylindrical segment into a branching pattern of
five segments Trick Decompose the production int
o set of productions each yielding a single
segment L?aL,afL,afL,aff-L,affL Note Each pr
oduction modifies state, then instances itself (L)
a scale f move forward rotate CCW rotat
e CW
push state pop state
3Scene-Graph Transformation
Productions in this form (left) can be
transformed into a scene graph (right).
Non-terminal symbol on productions LHS
corresponds to a union node. State-changing
terminal symbols on production right-hand side
are combined into single affine transformation
node. Two iterations of these productions results
in 25 instances of a cylindrical segment.
L
2 iters.
L?aLL?afLL?afLL?aff-LL?affL
a
af
af
aff-
aff
L
L
L
L
L
Union node Transformation node
4Encoding Into Fragments Texture
In this form, productions take the form of a
scene graph each node is expanded into a
collection of child nodes, each with an aggregate
transformation encoded here as x,y position,
rotation angle and scale
L?aL,afL,afL,aff-L,affL
Each node consists of a symbol and its
accumulated state, and is stored as a single
pixel in a deep 1-D texture, called the
symbol-state texture. Each column above is a
symbol-state texture. A single application of the
productions on a symbol-state texture generates a
new symbol-state texture.
5Representation
Each buffer can contain only a limited amount of
data. To store all the required data, we use a
deep buffer. We maintain several buffers for
which there is a pixel-level correspondence the
data is distributed across this set of buffers.
For our algorithm, this means we must apply our
programs once per buffer. The 2-D buffer is proce
ssed in 1-D using modular arithmetic. Context
sensitive productions can also be supported by
examining the 1-D neighbors.
7
8
6
3
4
5
7
8
6
7
6
3
4
5
0
1
2
8
0
1
2
3
4
5
context-sensitive lookups can be made
data for one symbol
0
1
2
texture 0
texture 1
6GPU Production Iteration
All productions are applied to all symbol-state
elements.Productions that dont match the input
symbol output an Ø-symbol.
A
B
Ø
B
Ø
A?B A?-B B?fA
Ø
Ø
Productions(coded as frag. progs)
Ø
Ø
Ø
A
p of productions Input symbol-state texture
n deep pixels Output symbol-state texture pn
deep pixels For each production i 0 p-1
Execute frag. prog. i on pixels in (0 n-1)
A
Ø
This is a lot ofwork and spacefor two results!
7Symbol-State Processing via Sorting
- Remove Ø entries from symbol-state texture
- Use occlusion query to determine of non-Ø
symbols
- Maintain original order otherwise to preserve
context sensitivity
8Multistage Bitonic Sort
A bitonic sort creates a sorting network
requiring no flow-control decisions which makes
it ideal for SIMD processing. We implement
multiple stages of the bitonic sort in a single
fragment program to reduce context-switch
overhead. On an NV30, this optimization
accelerates the sorting of up to 2048 elements.
0
1
2
3
4
5
Stage
fragment program
fragment program
9Rendering
- Convert terminal symbols to geometry directly on
the graphics card to avoid costly readback
- Use bitonic sort to collect terminal symbols and
their associated state (e.g. create one
collection of branches and another of leaves)
- Vertex shader accesses state stored in texture
memory and instances pre-stored indexed-face-set
at the proper position, scale and orientation
10References
Buck I., Purcell T. A toolkit for computation on
GPUs. In GPUGems Programming Techniques, Tips,
and Tricks for Real-Time Graphics, Fernando R.,
(Ed.), 1st ed. Addison-Wesley, 2004.
Hart J. C. The object instancing paradigm for l
inear fractal modeling. In Proc. of Graphics
Interface (1992), Morgan Kaufmann, pp. 224231.
Karwowski R., Prusinkiewicz P. Design and Imple
mentation of the LC Modeling Language. PhD
thesis, University of Calgary, 2003.
Luis F. Ortiz R. Y. P., Pinter S. S. An array l
anguage for data parallelism Definition,
compilation, and applications. Journal of
Supercomputing 5, 1 (1991), 729.
Mech R., Prusinkiewicz P. Generating subdivisio
n curves with l-systems on a GPU. In Proc. of the
SIGGRAPH 2003 conference on Sketches
applications (2003), ACM Press, pp. 11.
Purcell T. J., Donner C., Cammarano M., Jensen H
. W., Hanrahan P. Photon mapping on programmable
graphics hardware. In Proc. of the ACM
SIGGRAPH/EUROGRAPHICS conference on Graphics
hardware (2003), Eurographics Association, pp.
4150.