Sei sulla pagina 1di 1

Easy going vector graphics as textures on the GPU (sap 0322)

Grup de Grafics`

Gustavo Patow de Girona, Universitat de Girona, Spain.

Patow ∗ de Girona, Universitat de Girona, Spain. 1 Introduction Vector graphics always have had a
Patow ∗ de Girona, Universitat de Girona, Spain. 1 Introduction Vector graphics always have had a
Patow ∗ de Girona, Universitat de Girona, Spain. 1 Introduction Vector graphics always have had a
Patow ∗ de Girona, Universitat de Girona, Spain. 1 Introduction Vector graphics always have had a
Patow ∗ de Girona, Universitat de Girona, Spain. 1 Introduction Vector graphics always have had a

1 Introduction

Vector graphics always have had a great appealing because of their seamless scaling capabilities. Unfortunately, methods that use them

as textures are, in general, hard to implement, require a heavy pre- processing like segmenting the contour and embedding each seg- ment in a triangle [Loop and Blinn 2005], or allocate unnecessary data and use somewhat intricate encodings [Ray et al. 2005; Qin

et al. 2006]. Recently, in [Lefebvre and Hoppe 2006] they intro-

duced an efficient and elegant hashing approach, but their imple- mentation is not immediate in terms of simplicity. This paper pro- poses a simple, yet powerful technique to store and retrieve vector graphics to be used as textures for real time rendering.

out out color
out
out
color

(a)

color color Back- ground
color
color
Back-
ground
rendering. out out color (a) color color Back- ground (b) Figure 1: (a) The edges in

(b)

Figure 1: (a) The edges in a cell are structured using a BSP tree. (b) References to the exterior are linked to the next layer.

2 Preprocessing and visualization

A plain vector graphic can be extremely complex to evaluate in

the GPU, as it can be formed by thousands of oriented polygonal

e-mail: dagush@ima.udg.edu

figures organized into layers, each with hundreds of edges. To im- prove access efficiency, we partition the vector graphic with a grid that is used as a spatial hash, encoded in the Hash Texture. Each

hash entry can either be a solid color, or a pointer into a second texture called the Nodes Texture. Firstly, each polygonal figure that overlaps with the cell is converted into a BSP tree (Figure 1(a)). Each tree node contains a segment splitting the cell in two halves, and two pointers to the left and right children. If any of those is

a reference to the ”interior” of the figure, the figure color is stored

instead. If any refers to the ”exterior”, a null code is temporarily stored. In a second step, if a tree node contains a null code, it is replaced by a pointer to the root node of the tree representing the next layer (Figure 1(b)), unless it is the last one (background color). If a figure completely covers the cell, the tree is pruned and child nodes are replaced by the covering figure color. The binary trees are balanced to minimize, in runtime, the number of needed accesses.

Evaluation is completely done in the fragment shaders. Given the sampling texture coordinates, the hash texture is queried. If the value is not a color code, a simple iterative traversal starts at the

root node of the first tree reference, and descends until a color code

is

encountered. At each node, the position of the texture coordinates

is

compared with respect to the stored line segment, and one of the

two children is chosen.

3 Results and Future Work

As we can see in the companion images, our method works well for distances ranging from close to far views. Frame rates are sustained at more than 150 fps on a GeForce 7600, even with a large num- ber of vector textured objects. One improvement on the technique would be to switch to a mip-mapped texture for large distances, using the vector representation only for closer views.

References

L

EFEBVRE , S., AND H OPPE , H. 2006. Perfect spatial hashing. In SIGGRAPH ’06: ACM SIGGRAPH 2006 Papers , ACM Press, New York, NY, USA, 579–588.

L

OOP, C., AND B LINN , J. 2005. Resolution independent curve rendering using programmable graphics hardware. ACM Trans. Graph. 24 , 3, 1000–1009.

Q IN , Z., M C C OOL , M. D., AND K APLAN , C. S. 2006. Real-time texture-mapped vector glyphs. In SI3D ’06: Proceedings of the 2006 symposium on Interactive 3D graphics and games , ACM Press, New York, NY, USA, 125–132.

R AY, N., N EIGER , T., C AVIN , X., AND L EVY, B. 2005. Vector texture maps. In Tech Report ALICE-TR-05-003 .