isometric siggraph 2004

47
A Heightfield on an Isometric Grid Morgan McGuire and Peter Sibley Brown University A Heightfield on an Isometric Grid

Upload: wwqq

Post on 13-Dec-2015

23 views

Category:

Documents


0 download

DESCRIPTION

Isometric height grid

TRANSCRIPT

Page 1: Isometric SIGGRAPH 2004

A Heightfield on an Isometric GridMorgan McGuire and Peter SibleyBrown University

A Heightfield on an Isometric Grid

Page 2: Isometric SIGGRAPH 2004

The Isometric HeightfieldThe Isometric Heightfield

• 10% more accurate, subjectively smoother

• Practical for real applications

• GPU accelerated

• Drawback: requires resampling

Page 3: Isometric SIGGRAPH 2004

MotivationMotivation

Page 4: Isometric SIGGRAPH 2004

Traditional Ortho-HeightfieldTraditional Ortho-Heightfield

y-displacement

3D View

Grid

Page 5: Isometric SIGGRAPH 2004

Heightfield BenefitsHeightfield Benefits

• Represent scientific data at highest fidelity

• Practical

• Great for dynamic data

• Storage efficient for high-frequency data

• Simple!

Page 6: Isometric SIGGRAPH 2004

Worst Case Ortho FitWorst Case Ortho Fit

vs. Best

Page 7: Isometric SIGGRAPH 2004

Musgrave’s HeightfieldMusgrave’s Heightfield

• Shear axes to produce a parallelogram• Equilateral tessellation

rrcSrc ,, r

c x

z

Grid Space World Space

Page 8: Isometric SIGGRAPH 2004

New Isometric HeightfieldNew Isometric Heightfield• New Mapping

– Shift odd rows ½ edge length– Slide end vertices to make square tiles– Border padding for computing vertex normals

• Drop-in replacement for ortho-heightfield

c

rGrid Space World Space

1,1&2, rrcSrc

x

z

Page 9: Isometric SIGGRAPH 2004

Related WorkRelated Work

• Musgrave 88– Grid Tracing: Fast Ray Tracing for Height Fields

• Duchaineau et al 97– ROAMing terrain: real-time optimally adapting meshes

• de Boer 00– Fast Terrain Rendering Using Geometrical MipMapping

• Shankel 02– Fast Heightfield Normal Calculation

• Middleton 01, 02– Edge Detection in a Hexagonal-image Processing Framework– Markov Random Fields for Square Hexagonal Textures

Page 10: Isometric SIGGRAPH 2004

AnalysisAnalysis

Page 11: Isometric SIGGRAPH 2004

Signal Processing AnalysisSignal Processing Analysis

• Underlying “true” function h(x, z)• Heightfield approximation:

– Low-pass filter and sample– y(x, z) at integer x, z– Barycentric interpolation for non-integer x, z

• Reasons for poor fit:– Aliasing from inadequate sampling– Inappropriate reconstruction filter (i.e. triangles)

Page 12: Isometric SIGGRAPH 2004

ExperimentExperiment

• Approximate a 2D Sinusoid

h(x, z) = sin(f[x cos + z sin ] +)• Vary phase, angle, and frequency• Error Metrics

– Elevation– Shading– Normal deflection– Curvature

• Any function is a weighted sum of sinusoids• Draw generalizations about arbitrary functions

Page 13: Isometric SIGGRAPH 2004

Cleaner High Freq.Cleaner High Freq.

Ortho Iso

Page 14: Isometric SIGGRAPH 2004

Smoother Low Freq.Smoother Low Freq.

Ortho Iso

Shaded

Page 15: Isometric SIGGRAPH 2004

Smoother Low Freq.Smoother Low Freq.

Ortho Iso

Shaded

Curvature

Page 16: Isometric SIGGRAPH 2004

Shading Error

Isometric: 25% more accurate shading.

(lower is better)

Page 17: Isometric SIGGRAPH 2004

AlgorithmsAlgorithms

Page 18: Isometric SIGGRAPH 2004

ResamplingResampling

• Existing ortho-grid sampled data– Reconstruct true continuous surface– Filter and downsample on hex pattern– Lossless if original was correctly sampled

• Artist created data– Iso-heightfield as modeling primitive

Page 19: Isometric SIGGRAPH 2004

Moving on the SurfaceMoving on the Surface

• We know elevation at vertices

• We need elevation between vertices– Must exactly match rendered elevation!

• 4 cases, easily derived from Barycentric interpolation

H

G I

L=(1-)H+IJ=(1-)H + G

P=(1-)J+L

Page 20: Isometric SIGGRAPH 2004

Fast Vertex NormalsFast Vertex Normals

• Indices of neighbors:

• Grid space edge vectors:

• Vertex normal contains 6 cross-products:

D E

IP

F

H G

Cps

pisCphsCpg

pfsCpesCpd

11

11

0,,1sin,,

sin,,0,,1

sin,,sin,,

321

321

321

321

PyIyPIPyHyPH

PyGyPGPyFyPF

PyEyPEPyDyPD

PIPDPHPIPGPH

PFPGPEPFPDPEN

Page 21: Isometric SIGGRAPH 2004

Fast Vertex NormalsFast Vertex Normals

• Algebra dramatically simplifies:

• Operation count: 6 add, 1 mul

– Cheaper than 1 cross-product!

yyyyy EHGDFIEHGDN ,4,2sin 364

D E

IP

F

H G

Page 22: Isometric SIGGRAPH 2004

Normals in Vertex ShaderNormals in Vertex Shader

const uniform mat4 K =

vec3 A(tex2D(d), tex2D(h), tex2D(i));vec3 B(tex2D(g), tex2D(e), tex2D(f));vec4 C(A – B, 1);vec4 N = mul(K, C);

0000

0011

4000

03

23

13

1

1TMV

Precomputed outside vertex shader

Actual per-vertex work

• 6 texture lookups (NV50?)

• Neighbor indices are the same for each tile– Precompute and store in tex coord stream

Page 23: Isometric SIGGRAPH 2004

Fast Shadow VolumesFast Shadow Volumes

Page 24: Isometric SIGGRAPH 2004

Heightfield TilesHeightfield Tiles Page from disk Unit of LOD, texturing

Wake Island from Battlefield 1942 courtesy of Digital Illusions CE

Page 25: Isometric SIGGRAPH 2004

Triangle StripsTriangle Strips

Start

End

Page 26: Isometric SIGGRAPH 2004

Sub-sampled LODSub-sampled LOD

• Geo-mipmapping would be ideal– Cannot afford to touch vertices on CPU

• Use subsampling– Keep edges at maximum resolution – Carefully alpha-blend transitions

Page 27: Isometric SIGGRAPH 2004
Page 28: Isometric SIGGRAPH 2004

LOD MovieLOD Movie

Page 29: Isometric SIGGRAPH 2004

Efficient Storage (NV20+)Efficient Storage (NV20+)

• Pack x, z in int16 vertex stream – Same for every tile

• Pack y in int16 texture coordinate stream

• Combine streams in vertex shader

• Modify y on CPU, upload a relatively small vertex array– 2 bytes/vertex vs. 12 bytes/vertex

Page 30: Isometric SIGGRAPH 2004

Efficient Storage (NV40)Efficient Storage (NV40)

• Put y in a texture– SM 3 allows texture lookup in vertex shader!

• Modify y using render-to-texture– Navier-Stokes– Render deformations– Tire tracks & footprints– [insert your favorite GPU hack here]

Page 31: Isometric SIGGRAPH 2004

ApplicationsApplications

Page 32: Isometric SIGGRAPH 2004

VisualizationVisualization

Page 33: Isometric SIGGRAPH 2004

GamesGames

Page 34: Isometric SIGGRAPH 2004

AcknowledgementsAcknowledgements

• Advisor John F. Hughes

• Battlefield 1942 data courtesy of Digital Illusions CE• Mars data from Dr. James Head III, Brown University

• Additional coding:– Hari Khalsa– Nick Musurca

Hardware and data made available by:

Page 35: Isometric SIGGRAPH 2004
Page 36: Isometric SIGGRAPH 2004

Elevation Error

Isometric: Same quality with 10% fewer polygons.

(lower is better)

Page 37: Isometric SIGGRAPH 2004

What about ROAM?What about ROAM?

• Irregular tessellation:– y(x, z) for a data-dependent set of samples– Barycentric interpolation between samples– Can produce a better fit

• Less aliasing: put samples where needed• e.g. ROAM, Triangulated Irregular Networks

• Heightfields are still preferred for many applications…

Page 38: Isometric SIGGRAPH 2004

Our Mapping (2)Our Mapping (2)• Grid to world space:

• Grid space to memory:

• Row and column sizes:

• Also tweak end-vertices on even rows• Drop-in replacement for orthogonal heightfield

– Square tiles– Convenient texture & normal mapping

odd ,33

sin2 ;13 ;, RCRCCR

1,1&2, rrcSrc

rCcrc ,

Page 39: Isometric SIGGRAPH 2004

Need Indices and WeightsNeed Indices and Weights

H

G I

P

Indices: g = ?, h = ?, i = ?

Weights: wG = , wH = ?, wI =

Page 40: Isometric SIGGRAPH 2004

Barycentric InterpolationBarycentric Interpolation

• Simple equations exist for g, h, i, , • 4 triangle orientations: {even row, odd row} x {up, down}

H

G I

L=(1-)H+IJ=(1-)H + G

P=(1-)J+L

wG = 1 –, wH = 1 , wI =

Page 41: Isometric SIGGRAPH 2004

ExampleExample

• Given P = (c, r)• Let• Example: odd row, up triangle

• 3 other cases

Crcprrvccu ,,

)( and )12mod( vur

g = p + C, h = p, i = g +1

= v, = u

Page 42: Isometric SIGGRAPH 2004

Self-Shadowing is HardSelf-Shadowing is Hard

Problems:

• Shadow maps are expensive for terrain– High fill rate

• Shadow volumes expensive for terrain– High fill and vertex rate

• Pre-computation, horizon map no good for dynamic data

Page 43: Isometric SIGGRAPH 2004

A Trick for ShadowingA Trick for Shadowing

• Constrain the sun orbit the z-axis – i.e. moves strictly East-West

• (x0, z0) only be shadowed by (x0 – k, z0)

• Start at the sun end of the x-axis, iterate over vertices

• Incrementally compute the max shadowed elevation

• Works on ortho-heightfield too

Page 44: Isometric SIGGRAPH 2004

Fast Shadow VolumesFast Shadow Volumes

• Terrain shadows other objects• Other objects do not shadow terrain (use projective

shadows, shadow maps, volumes, etc. for that)• Iterates along rows, which are memory-aligned• Almost free

– Compute shadowing inside the loop that uploads elevation to the graphics card

Page 45: Isometric SIGGRAPH 2004

Future WorkFuture Work

• Compute true Geo-mipmapped LOD in hardware?

• LOD w/ normal maps

• Update shadow elevation in hardware?

• Experiments with deformation and destruction

Page 46: Isometric SIGGRAPH 2004

Irregular SamplingIrregular Sampling

Regular

Irregular spacing captures shape better:

Irregular

Page 47: Isometric SIGGRAPH 2004

General Ortho ProblemGeneral Ortho Problem