texture sprites: texture elements splatted on surfaces sylvain lefebvre samuel hornus fabrice neyret...

29
Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Sylvain Lefebvre Samuel Hornus Samuel Hornus Fabrice Neyret Fabrice Neyret GRAVIR/IMAG-INRIA GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on ACM SIGGRAPH 2005 Symposium on Interactive 3D Graphics and Games 2005 Interactive 3D Graphics and Games 2005

Post on 21-Dec-2015

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

Texture Sprites: Texture Elements Splatted on Surfaces

Texture Sprites: Texture Elements Splatted on Surfaces

Sylvain LefebvreSylvain LefebvreSamuel HornusSamuel HornusFabrice NeyretFabrice Neyret

GRAVIR/IMAG-INRIAGRAVIR/IMAG-INRIA

ACM SIGGRAPH 2005 Symposium on ACM SIGGRAPH 2005 Symposium on Interactive 3D Graphics and Games 2005Interactive 3D Graphics and Games 2005

Page 2: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

AbstractAbstract

Page 3: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

IntroductionIntroduction

• Texturing 3D models with very high resolutions create two major difficulties– Storage cost of high resolution texture maps can

easily exceed the available texture memory– Creating high resolution textures proves to be a

difficult and tedious task

• Lack of representation for textures composed of sparse elements– Wastes a lot of memory– Discontinuities– Flickering due to Z-fighting

Page 4: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

IntroductionIntroduction• Texture sprites

– The texture element live on the object surface and can be updated dynamically

• Provides a general and convenient scheme for sprite-based texturing– Homogeneous appearances obtained by overlapping

many sprites– Interactive addition of local details

• Geometry and composite texture are independent– Not require: 1) mesh to conform to any constraint

2) global planar parameterization 3) modify the initial mesh

Page 5: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

ContributionsContributions

• A parameterization-free texture representation allowing efficient storage and filtered rendering of composite textures

• An efficient solution to dynamic decal management and animated texture elements

• New appealing texturing effects

• Complete GPU-implementation

Page 6: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

Sprite-Based TexturesSprite-Based Textures

• Key idea– Store the sprite attributes (position,

orientation, etc) in a 3D hierarchical structure surrounding the mesh

– Follow the idea of octree textures• The sprites attributes in the leaves of the

hierarchical grid

– The entire data-structure is compact• Many sprites share a same texture pattern • Information is stored only around the surface

Page 7: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

Sprite-Based TexturesSprite-Based Textures

• Easy to author– add, drag, drop, change size, and orientation

• The system is very flexible– Sprite ordering is controllable– Sprite overlapping can be mixed

• Each sprite can be independently animated– For instance: react to surface deformations

Page 8: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

DifficultiesDifficulties

• How to manage the hierarchical 3D grid on the GPU (fragment program)

• How to use the hierarchical 3D grid to store and retrieve sprites attributes

• How to filter the composite texture and blend overlapping sprites together

Page 9: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

3D Hierarchical Grid (in GPU)3D Hierarchical Grid (in GPU)

• Problem– Store the hierarchical grid in texture memory– Retrieve data from the grid at a given 3D

location– (This is implemented in a fragment program)

• We call this structure N N33-tree-tree– N in each dimension– Octree → N = 2– Implementation: N = 4

Page 10: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

N3-tree Memory LayoutN3-tree Memory Layout

• Tree structure– Node: indirection grid consisting of N3 cells– Cell content:

(cell type is determined by a flag stored in the A-channel)

• A = 1, data (leaf)• A = ½ , a pointer• A = 0, empty

– Store our structure in a 3D texture called the indirection pool

• Data values and pointer values are stored as RGB-triples

Page 11: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

NotationsNotations

• N*N*NN*N*N: resolution of the indirection grid corresponding to each tree nodeeach tree node

• NNll *N*Nll*N*Nll: resolution of virtual 3D grid at level l

• At level l a point M in space ( M [0, 1)3 )

lies in a cell located at

and has a local coordinate

within this cell. We have

l

l

il N

NMM

,

l

l

fl N

NMfracM

)(,

flil MMM ,,

Page 12: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

NotationsNotations

• Node are packed in the indirection pool

• S = (Su, Sv, Sw): size of indirection pool

• NSu*NSv*NSw: resolution of the texture hosting the

indirection pool

• A texture value in the indirection pool is indexed by a real valued P [0, 1)3

• P = Pi+Pf

S

SPPi

S

SPfracPf

)(

Page 13: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

NotationsNotations

• Pi identifies the node which is stored in the area

• Pi is called the node coordinates

• Pf is the local coordinate of P within the node’s indirection grid

• (!! Packing the cells does not change the local coordinates.)

SPP ii

1,

l

l

fl N

NMfracM

)(,

S

SPfracPf

)( )()( SPfracNMfrac l

SPNM fll

fl ,, S

NMfracP

l

fl

)(,

Equation(1)

Page 14: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

Tree LookupTree Lookup

• For rendering, we need to retrieve the data corresponding to a given location M in space (more precisely, on the object surface)– This is done per-pixel in a fragment program

– Start from level 0 in the tree

– At level l let Pl,i be the coordinate of the current node in the indirection pool

– The RGBA value corresponding to M is found in Pl,i at the location Pl,f , obtained by Equation(1)

– AA: in a leaf (return), an empty node (discard) or an internal node (continue to the next level (l+1) )

Page 15: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

Implementation DetailsImplementation Details

• To avoid precision issues, and minimize storage requirements we store S‧Pl,i instead of Pl,i in the indirection cells

• S‧Pl,i is an integer– Optimized the encoding: choose the number of bits to

stored in the RGB channels to exactly represent at most S indices

– The values of the pointers do not depend on the size of the indirection pool

Page 16: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

Precision LimitationsPrecision Limitations

• The limited precision of 32 bits floating point:– Limit on the depth, resolution, number of nodes of the

hierarchical grid

Page 17: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

Managing the Texture SpritesManaging the Texture Sprites

• Each sprite is associated with – various parameters– a bounding volume V defining the spatial limit

of the sprite influence on the composite texture

• Bounding volume V is used to– determine which cells are covered by sprite– detect whether two sprites overlap

Page 18: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

Storing Sprite ParametersStoring Sprite Parameters

• Sprite parameter table is a texture containing all the parameters for all the sprites– Each sprite corresponds to an index into this

texture; each texel encodes a parameter set– Store the index of the sprite parameters in the

tree leaf data field• The RGB value encodes a pointer to the sprite

parameter table

Page 19: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

Dealing with Overlapping SpritesDealing with Overlapping Sprites

• Leaf vectors table– This 3D texture implements a table of vectors

storing the sprite parameters associated with a leaf

– 2 dimensions: the vector– 1 dimension: to index the

vector of sprite parameters

• Instead of directly storing the index of one sprite in the leaves, we now store an index to the leaf vector

Page 20: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

Adding a Sprite to the TreeAdding a Sprite to the Tree

• Leaf splitting occurs only in full leaves (Omax)

– Cmax < Omax

• Insertion failures– The maximum depth level is reached only

when more than Omax sprites are crowded in the same very small region

• Ordering of sprites– Order the sprites

in the leaf vectors

Page 21: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

Positioning the Sprites on the SurfacePositioning the Sprites on the Surface

• Associate a frame to each sprite and use a parallel projection to surface

• The positioning parameters– A center point c (sprite handle)– Two vectors l, h

• defining the plane, scale, orientation of the pattern

– A normal vector n (direction of projection)

– M: (l, h, n)

• U = M-1 (P-c) ‧– U = (u, v, w): texture coordinates within the pattern

Page 22: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

Positioning the Sprites on the SurfacePositioning the Sprites on the Surface

• Deformation-proof texturing– Store a 3D parameterization (u, v, w) at each

vertex and interpolated as usual for any fragment

• Blending sprites– When multiple sprite overlap, the resulting color is

computed by blending together their contributions

– Non standard blending modes• Blobby-painting cellular textures

Page 23: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

FilteringFiltering

• Linear interpolation (for close viewpoint)

– standard texture unites of the GPU

• MIP-mapping of sprites– standard texture unites of the GPU

Page 24: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

Applications and ResultApplications and Result

• Texture authoring– Interactively scaled, rotated, or moved above or below

the already existing sprites

• Lapped texture approximation– The sample is stored only once– N3-tree minimizes the memory space required for

positioning information– Rendering does not suffer from filtering issues

created by atlases

Page 25: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

Applications and ResultApplications and Result

• Animated sprites– Modify the positioning parameters

(position, orientation, scaling)

– A sprite can cycle over a set of texture patterns, simulating an animation in a cartoon-like fashion

• Snake scales– Estimate the local geometric distortion and scale the

sprites accordingly to compensate for the deformation of the animated mesh

Page 26: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

PerformancePerformance

# of sprites Node size Tree depth Max. overlap FPS (800*600)

Lapped 536 4 4 16 27

Gears 50 4 2 8 80

Stars 69 4 2 8 26

Blobby 125 4 3 10 70

Voronoi 132 4 3 12 56

Page 27: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

Storage RequirementsStorage Requirements

Size of structure Allocated memory Total memory

Lapped 1 MB 1.6 MB 1.9 MB

Gears 0.012 MB 0.278 MB 0.442 MB

Stars 0.007 MB 0.285 MB 5.7 MB

Blobby 0.141 MB 0.418 MB 0.424 MB

Voronoi 0.180 MB 0.538 MB 0.554 MB

Page 28: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

ConclusionsConclusions

• High texturing resolution at low memory cost• Without need for a global planar parameterization• The sprite’s attributes are efficiently stored in a

hierarchical grid surrounding the object’s surface• Flexible

– Each sprite can be independently animated, moved, scaled, rotated

– Create new texturing effects, such as animated texture, textures reacting to mesh deformations

• Complete GPU implementation, real-time performance

Page 29: Texture Sprites: Texture Elements Splatted on Surfaces Sylvain Lefebvre Samuel Hornus Fabrice Neyret GRAVIR/IMAG-INRIA ACM SIGGRAPH 2005 Symposium on Interactive

Future WorkFuture Work

• Painterly rendering

• Sprite projector functions

• For point-based and volumetric representation