Terrain and NPR Rendering on the GPU - Graphics Group - Brown ...

sizzlepictureΛογισμικό & κατασκευή λογ/κού

2 Δεκ 2013 (πριν από 3 χρόνια και 8 μήνες)

86 εμφανίσεις

1

Hardware
Feature
Edges

June 7, 2004

Morgan McGuire and John F. Hughes

Brown University


NPAR 2004

Hardware
Feature
Edges

2

Goal

Find and stroke feature edges on the GPU

3

Feature Edges

Contour

Front
-
face meets back
-
face

Boundary

Ridge

Valley

Silhouette

Subset of contour


All defined by derivatives of normals…


i.e. for nice polyhedra, adjacent face normals

4

Feature Tests















1

:
:~
|
cos
0
:
cos
0
:
)
sgn(
)
sgn(
:
2
3
2
3




















complexity
depth
Contour
Silhouette
n
Artist
Boundary
n
n
n
v
v
Valley
n
n
n
v
v
Ridge
eye
n
eye
n
Contour
B
valley
B
A
A
ridge
B
A
A
B
A


eye

= center of projection


v
0



= depth complexity

v
3

v
2

v
0

v
1

n
A

n
B

n
1

n
0

A

B

eye

5

Challenge

GPU limitations
:


No “Edge Processor”

No access to adjacency

No previous state for coherence

Cannot create or destroy edge geometry

Vertex
Processor

Pixel
Processor

Rasterizer

Triangles

Edges

Adjacency

Vertices

x

x

6

Related Work

CPU Silhouettes

Exhaustive: Sutherland (circa ’77)

Randomized: Markosian et al. ’97

Cutting sphere: Gooch ’99

Dual space: Zorin and Hertzmann ’00

GPU Silhouettes

G
-
Buffer: Saito and Takahashi ’90; McCool ’03

Environment maps: Gooch ’99, Deitrich ’99

Halo: Raskar ’01, ’02

Pixel Processor + Readback: Brabec and Seidel ’03

Edge vertices
: Card & Mitchell ’02, Brennan ’03, Gooch ’03

(None allow thick lines or brush strokes)

7

Vertex Attributes

GPUs allow 16 vertex “attributes”

<position
, normal, color, tex coords>

Can store other information…

<
position
, face
-
normal A, face
-
normal B>

i.e. adjacent face normals


The edge from
v
0

to
v
1

with
adjacent faces
A

and
B
.

v
0

v
1

n
A

n
B

A

B

8

Agnosticism

The GPU doesn’t care

Attributes don’t have to be texture coords, colors

Face list doesn’t have to describe faces

Just has to have the right form

Face list: set of indices into vertex table

Vertex attributes: set of 4
-
vectors

e.g. store information about an
EDGE

of the
model mesh:

In each
VERTEX

structure we send to the GPU

Call these “edge vertices”

9

Edge Vertices

Make a new mesh

Every edge becomes two vertices

<
v
0
,
n
A
,
n
B
>, <
v
1
,
n
A
,
n
B
>

Connected by a line

Use vertex processor to find vertices on contours

Hide non
-
contours when rendering

Degenerate polygons,
a

= 0, etc.


(
n
A



eye

> 0
) xor (
n
B



eye

> 0
)


v
0

v
1

n
A

n
B

A

B

10

Our Contribution

Extend Edge Vertices with


More edge types

Ridge, Valley, Silhouette

Smooth Silhouette

Suggestive Contour

Brush strokes

Animation

Plan for Future Hardware

11

The Edge
-
Mesh

Every edge becomes
four

identical* vertices

Connected into a quadrilateral

Store adjacent vertices, not face normals

v
3

v
2

v
0

v
1

n
A

n
B

n
1

n
0

A

B


(
i
)

= <
v
0
,
v
1
,
v
2
,
v
3
,

n
0
,

n
1
,

r
,

i
>


3D Vectors

* Differentiated
by
i

= {0, 1, 2, 3}

Scalar texture parameter

12

Rendering

Test edges on the
vertex

processor


Feature Edge:

Extrude into a screen
-
space rectangle

Choose vertex position from
i

Non
-
Feature Edge:

Hide beyond clipping plane

Early
-
out avoids rasterization overhead

Animation:

Animate
v

and
n

as a regular vertex and vertex
-
normal

i
=0

i
=1

i
=2

i
=3

v
0

v
1

13

Result

14

Building a Style

15

16

Performance

17

Thick Lines

Thick quads leave visible gaps at joints

Common problem (e.g. Raskar ’02)

18

Solution: End Caps

s
0

s
1

p

m
0

m
1

quad

start cap

finish cap

“outside”

“inside”

Computed in screen space

Follow projected normals
m
0
,

m
1

The only mutual information between
adjacent edges!

19

Result

No Caps Caps

Works well for
smooth

objects…

20

Heuristic can Fail

Vertex normals
poorly reflect
curvature for this
object and our
heuristic fails.

21

Heuristic can Fail

Hidden
Failures:


Cap is on the
wrong side, but
the gap is
inside

the object.

22

Heuristic can Fail

Visible
Failure:


Cap is on the
wrong side and
the gap is
outside

the object.

23

Analysis of Failure

Failure occurs when
s

is on the “concave” side of joint:

i.e. 2D curvature is negative



Probability of failure increases when:

Curvature is high and tessellation is low

Vertex normal represents curvature poorly





0
or

0






f
d
s
e
d
s

f

e

24

Brush Textures

25

Screen vs. Object Space

s

=
v
x

|
v
y








Good for still and
high
-
poly models

s
0

=
r

s
1

= r + L








Good for animated
low
-
poly models

Attached to vertices
during animation

26

Applications

“Zero CPU cycles were harmed in the

rendering of the following images.”

27

Bunny
-
Bot

Crayon
-
Bot

Pen
-
Bot

Blue Print
-
Bot

Wispy
-
Bot

Different Strokes

28

Ink & Wash

29

Hidden Line

30

Toon Fur

31

J. Lengyel’s Realistic Fur Algorithm

Shells

Stack 16 sparse textures

Perform extrusion in vertex
shader

Looks like fur when viewed
“head on”

Looks like 16 dots when viewed
“side on”

Fins

Striped texture near
CONTOURS

Looks like fur when viewed
“side on”

We move this onto GPU

Anisotropic shading

Images from Lengyel et. al, Real
-
Time Fur over Arbitrary Surfaces

32

Realistic Fur

33

Shadow Volumes


Find polyhedron bounding shadowed points


Any intersected surface is shadowed


Compute intersection via stencil operations




Caps


At the object and infinity


E. Lengyel implemented with GPU


Sides


Find
CONTOUR

edges


Extrude each one into a quad

Dark Cap (at infinity)

Light Cap

Side

Side

34

Shadows

35

Zorin
-
Hertzmann Smooth Silhouettes

v
0

v
1

v
2

A

n
2

n
1

n
0

B

Extend edge vertex to <
v
0
,
v
1
,
v
2
,
v
3
,
n
0
,
n
1
,
n
2
,
n
3
,
r
,
i
>

Define an “above
-
water” function
f = eye


n

Either 0 or 2 edges have zero
-
crossings in
f

Estimate

zero
-
crossing points A, B and connect them

f
0
= 0.8

f
2
=
-
0.1

f
1
=
-
0.2

f
A


0

f
B


0

36

Animation

37

DeCarlo et. al’s Suggestive Contours*


Smooth silhouettes with new above
-
water function





Only stroke when “ ”


i.e.


Pack
k
1
,
k
2
,
t
1
,
t
2
,
n
,
v

(x4, for a quad) into edge vertex

0


r
w
k




2
2
2
2
1
1
T
w
T
w
f




k
k




2
)
(
)
(
B
A
t
w
B
A
B
f
A
f
d





A

B

38

* Don’t try our S.C. method at home on GeForceFX…
it is too hard to squeeze the curvature data into only 16
attributes!



Just use DeCarlo’s image space algorithm, or…

39

GeForce 6800

GeForce 6800

and
Radeon X800

support texture
reads in the vertex processor. Commercially available
by August.

Pointers (stored in textures) cut redundant data.


Using 16
-
bit pointers:

Current:

E = <v,v,v,v,n,n,r,i> x 4


=
304

bytes

New:

E = <ptr, i> x 4 + <#,#,#,#,r> =
14

bytes


20x improvement!




(# is a pointer to a regular mesh vertex)

40

GeForce 7800?

DirectX Next

specification allows geometry
to be created and destroyed


this eliminates
the need for degenerate quads…

41

Follow
-
Up

Jorn Loviscach extended our method to halos with MAX alpha
blending and suggests a new curved silhouette algorithm.

42

Acknowledgements

Evasion Group, INRIA Rhone
-
Alpes

NVIDIA

Tomer Moscovich

43

44

Feature Expressions















1

:
:~
|
cos
0
:
cos
0
:
)
sgn(
)
sgn(
:
2
3
2
3




















complexity
depth
Contour
Silhouette
n
Artist
Boundary
n
n
n
v
v
Valley
n
n
n
v
v
Ridge
eye
n
eye
n
Contour
B
valley
B
A
A
ridge
B
A
A
B
A



eye

= center of projection


v
0



= depth complexity

v
3

v
2

v
0

v
1

n
A

n
B

n
1

n
0

A

B

eye

<
v
0
, v
1
, v
2
, v
3
, n
0
, n
1
, r, i
>

n
A

= (
v
1



v
0
)


(
v
2



v
0
)

n
B

= (
v
3



v
0
)


(
v
1



v
0
)

45

Silhouettes


1
.

Set

S

:
=

(S

+

1
)

mod

255


2
.

If

S

==

0

then

clear

stencil

buffer

to

255


3
.

Render

the

model,

setting

stencil

to

S




wherever

the

depth

test

passes


4
.

Set

the

stencil

test

to

pass

where

stencil

==

S


5. Render contour edges