Image Synthesis

54
computer graphics & visualization Image Synthesis Interactive Terrain Rendering

description

Image Synthesis. Interactive Terrain Rendering. Motivation. Mobile Terrain Visualization. Mobile GPUs 250M pixels / second 5M triangles / second 6 Textures OpenGL ES / Direct3Dm Challenges 1,25 MB Video-RAM… Fixpoint formats Bandwidths Compression, streaming etc. Requirements. - PowerPoint PPT Presentation

Transcript of Image Synthesis

Page 1: Image Synthesis

computer graphics & visualization

Image Synthesis

Interactive Terrain Rendering

Page 2: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Motivation

Page 3: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Mobile Terrain Visualization• Mobile GPUs

– 250M pixels / second– 5M triangles / second– 6 Textures– OpenGL ES / Direct3Dm

• Challenges– 1,25 MB Video-RAM…– Fixpoint formats– Bandwidths– Compression, streaming etc.

Page 4: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Requirements• Games

– High, constant frame rates– Quality advantageous but not priorized

• Simulators– Constant frame rates (~30fps)– High degree of realism and detail, optionally stereo

• GIS– Interactive frame rates advantageous (15+ fps)– High resolution and precision

Page 5: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Challenges

Crater Lake, Oregon, US

Heightfield with bathimetry and texture

~ 500 MB

Oberbayern and Alps

Heightfield with texture

~ 350 MB

Puget Sound, WA, USA

Heightfield with texture

~ 1.25 GB

Page 6: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

ChallengesMars, MOLA mission

Heightfield with texture

~ 4.5 GB

USA complete, USGS data

Heightfield

~ 40 GB

Mars, MarsExpress mission

Heightfield with texture(Video)

~ 175 GB

Page 7: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

ChallengesData sets are:• Large to gigantic

– Data volume is increasing rapidly• Sometimes multi-modal

– Color, Albedo, Cloud coverage, Scattering properties, …• Sometimes annoted and commented

– Additional layers with meta data

Efficient Rendering ?

Page 8: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Terrain rendering• Terrain:

– A height field over a rectangular domain

– Given at discretesample points

Page 9: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Terrain renderingRendering lit and textured triangles

– Vertices, texture coords, colors, normals

Page 10: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Terrain rendering• Ray-Tracing

– Ray-tracing triangle meshes• Trace rays until a triangle is hit

• Implicit occlusion culling

Page 11: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Terrain rendering• Ray-Tracing - performance issues

– Mesh data structure has to be stored– Hierarchical representation necessary for improved

intersection testOctree or kD-tree

max/min(H)

max/min(H)

max/min(H)

• Store max/min heights for subregions• Skip regions below minimal height of ray• Employ ray coherences

Page 12: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Terrain rendering• Rendering polygonal models – analysis

– Aliasing due to undersampling of small features– No exploitation of the LOD-nature

Page 13: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Terrain rendering• Rendering techniques for terrains

– Render each triangle separately

– Draw: (v0,v1,vX), (v1,vX,vX+1), ... – Each vertex is rendered (transmitted, transformed) six times

V0 V2V1 V3

...

... VX-1

VX VX+2VX+1 VX+3

Page 14: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Terrain rendering• Rendering techniques for terrains

– Render triangle strips: v0,vX,v1,vX+1,v2,vX+1, ...

– Triangle defined by new point and previous two points– Each vertex is rendered only once

V0 V2V1 V3

...

... VX-1

VX VX+2VX+1 VX+3

Page 15: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Terrain rendering• Height field pre-processing

– Reduce number of primitives by mesh decimation– Mesh decimation based on any decimation ctriterion

• Curvature („flatness“)• Use fewer but larger triangles where the height field is flat

Page 16: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Terrain rendering• Even with mesh decimation there are still too

many triangles– Some features might not be visible because they

are too far from the viewer• Feature size is smaller than size of a pixel

– Level-of-detail should be adapted to the size of details when displayed rather than to their size in world space

Page 17: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Terrain rendering• Approach: adaptively decimate the mesh with

regard to the current view• General idea:

– Top-down approach– Start with coarse resolution (2 triangles) and

adaptively refine until desired level-of-detail is reached

– Consider world space and screen space deviation– Re-build mesh for every frame

Page 18: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Terrain rendering• Recursive split operation (as in ROAM)

Page 19: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Terrain rendering• Error criterion for split operation

– Deviation in world space• Difference between height value at center vertex and

average of left and right vertex– Deviation in screen space

• Determine upper bound for screen space length of world space difference vector (0,d,0)

Page 20: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Previous Work

– Process and render Batches of geometry: (P-)BDAM• Huge pre-processing requirements• Hardware requirements (SCSI Raid) • Average Quality

– Hierarchical, regular Grids: (Geometry Clipmaps)• Good compression, good framerates• Error control very hard, quality suffers• Losasso & Hoppe SIGGRAPH 2004

- Vast body of literature… see www.vterrain.org- Key Insight: Dynamic remeshing too expensive

Page 21: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Geometry clipmaps

Coarsest Level

Finest Level

- Terrain as mipmap pyramid- LOD using nested grids- LOD is shifted over domain, with varying height values

Page 22: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Geometry clipmaps• Advantages:

– Regular structure of nested grids enables fast rendering using triangle strips

– Only regular and continuous chunks of memory have to be read

• Disadvantages:– Does not allow to control local world/pixel error

• Renders more triangles than necessary• Introduces a significant higher pixel error in general

Page 23: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

GPU-friendly terrain rendering• Tile-based, restricted Quadtree

• Lmax error metric allows for precise error control• Low pre-processing times (15M vertices/min)• Nested hierarchy

• Pre-filtered, tiled S3TC-Mipmaps• High-quality Lanczos pre-filtering• Reduces artifacts at tile borders• S3TC virtually for free

• Precise Level of Detail Oracle• Based on the Jacobian of the projection• Does not make linear approximations• Better anti-aliasing control

Page 24: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Tile-based…• Partition data into square tiles

– Can be pre-processed independently– Frustum culling per tile– Progressive data transfer per tile

• T-Vertices: Fix with zero-area triangles– Only dynamic triangulation during run-time.

Page 25: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Restricted Quadtree Hierarchy• Tiled meshes are decimated in a pre-process • Mesh decimation as in ROAM (Real-Time Optimally

Adapting Meshes - see www.vterrain.org)– Exploits a triangle bintree structure: split along the base

edge

Page 26: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Restricted Quadtree Hierarchy• The recursive split operation

– A triangle should be split but has a base neighbor from a coarser level

• Force split of base neighbor first• Recursively force further splits if necessary until diamond

is found• Diamond can be split without further splits

Page 27: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Restricted Quadtree Hierarchy• Recursive split operation

Page 28: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Restricted Quadtree Hierarchy• Vertices can be shared across levels

– „Coarse“ Vertices used in all finer levels– Progressive encoding, less memory consumption

Page 29: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Restricted Quadtree Hierarchy• By generating approximations of the height field with

decreasingly lower approximation error, a mesh hierarchy that represents the original terrain at ever finer scales is constructed

• To generate a discrete set of hierarchy levels, an error vector (e0; e1; … ;e(n-1)) of exponentially decreasing entries ei := 2(n-1-i) is specified

• Hierarchy levels that satisfy these errors are constructed via adaptive triangulation

Page 30: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Restricted Quadtree Hierarchy• Each hierarchy level can be render as „recursive triangle fans“

– Fans around „quadtree centers“– Exploit primitive restarts on nVidia architectures

• A flag in the primitive stream that indicates a new fan• Used to avoid frequent calls from application program

Page 31: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Restricted Quadtree Hierarchy• Nested Mesh Hierarchy:

• Quadtree refinement:– Automatically results in nested mesh– Each new triangle re-uses two old vertices

• Elegant geomorphing possible– Requires only one height value per vertex & level– Can be implemented in vertex shader

„The parameter domain of each triangle is a subset of the parameter domain of exactly one triangle at the coarser levels.“

Page 32: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Tiled, S3TC Mipmaps• Tiled Mipmaps:

– Start with large 2D texture– Generate large Clipmap using Lanczos filter– Tile after filtering artifacts at boundaries reduced

• S3 Texture Compression– Designed for Games Supported by virtually all GPUs– Fast encoding in driver– Decoding virtually for free– Block Truncation Code, 4x4 pixels per block– Lossy compression: 6:1 Quality ?– We are researching other GPU-friendly methods…

Page 33: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

S3TC Quality ?Pros: „rough“ textures

Page 34: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

S3TC QualitätAnd Cons… - „smooth“ textures

Page 35: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Texture compression• Vector quantization

Encoder

Decoder

Xn

in=E(Xn)

in

X‘n=C(in)

Input mapping

Output mapping

Codebook Cwith codewords

Page 36: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Vector Quantization• Find centroids (representative vectors) to which all

elements are assigned• Elements get assigned to „closest“ representative

Page 37: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Texture compressionVector quantization: the LBG-Algorithm

1. Inital codebook {Yi(0)}i=1..M; IRn: set of input vectors;

2. Initialization k=0, D(0) =0, set

3. Find quantization regions Vi (k) = {XI: d(X,Yi) < d(X,Yj) j≠i, j=1..M}

4. Compute distortion

5. Test: If (D(k)-D(k-1))/D(k) < ) stop else continue

6. Update: increment k, find new codebook {Yi(k)}i=1..M from regions

Vi (k-1); goto 3

M

i VX

ki

k

ki

YXdD1

)()(

)(

),(

Page 38: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Texture compressionTrue-Color (3*8 Bit) vs. 12 Bit Quantization + Codebook

Page 39: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Texture compression

8 Bit 6 Bit

4 Bit 2 Bit

Page 40: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Texture compressionRegion quantization

2 bpp 2 bpp, 2x2 pixel encoding

Page 41: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Confocal scan 10242x64 RGBA

32 bpp 1 bpp

Page 42: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

CT scan 2563

Original Hierarchical encoding 21:1

Page 43: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Engine CT scan 2562x128

Original Hierarchical encoding 21:1

Page 44: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Visible Male RGB slice 2048x1216

Original 24 bpp Hierarchical encoding 0.3 bpp

Page 45: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Vortex simulation 100 x 1283

Original, 200 MB Hierarchical encoding 11 MB

Page 46: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Shockwave simulation 96 x 2563

Original, 1.4 GB Hierarchical encoding 70 MB

Page 47: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Texture compression• Vector quantization for GPUs

– Easy to decode in fragment shader• Only requires a dependent texture fetch (uses index to

lookup the entry in the codebook)– Does not allow for texture filtering (so far)

• Interpolation between indices gives errorenous results• Eventually larger regions can be decoded, rendered into

texture render target and then used to texture the object• Functionality is available but mipmapping might be a

problem

Page 48: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Scale of detail• Question:

– Now that we have a geometry and a texture MipMap, how is the resolution determined at which a particular tile has to be rendered

• Guess: – Depends on distance to viewer– Depends on projection used for rendering– Depends on orientation of tile

Page 49: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Scale of detail• Projection is non-linear (hom. division)• Pixel coords s(v), where v vertex in object space• Object space scale to pixel correspondence

– Similar to Mipmapping– Requires partial derivatives– Can be obtained by the inverse Jacobian of s(v):

• Jacobian s(v) = ∂si/∂vi

• Jacobian-1 s(v) = ∂vi/∂si

Page 50: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

From scale to level of detail• Pre-process: levels L with errors 2L meters

LOD =log2() for bounding box corners of tiles

• Tri-linear interpolation of in box– LOD per vertex for geomorphs

• Find minimum of for each box– Finest detail determines used topology– Project vertices to appropriate level (geomorph)– Requires pre-computed height for each vertex & level

• But only for coarser levels• And can be done in reduced precision (i.e. 8bits)

Page 51: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Level of detail: benefits• Near-optimal geometry filtering

– Geometry properly anti-aliased– Geometry properly reduced– No over-estimation of error

• No linear approximations of the projection• … but so far no anisotropic geometry filter• Still works very well in practice

• LOD for Textures is easier:– Mipmaps– Anisotropic texture filtering– All supported by GPU without major performance penalty

Page 52: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Texture filtering - MipMap

Page 53: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Texture filtering - anisotropic

Page 54: Image Synthesis

computer graphics & visualization

Image Synthesis – WS 07/08Dr. Jens Krüger – Computer Graphics and Visualization Group

Demos

Puget Sound

Oberbayern und Alpen