Shadows & Visibility 3D Modeling, Graphics, and Animation Prof. Jarek Rossignac College of Computing Georgia Institute of Technology 11/7/2015 Jarek Rossignac, CoC, IIC, GT Shadows & visibility,

Download Report

Transcript Shadows & Visibility 3D Modeling, Graphics, and Animation Prof. Jarek Rossignac College of Computing Georgia Institute of Technology 11/7/2015 Jarek Rossignac, CoC, IIC, GT Shadows & visibility,

Shadows & Visibility
3D Modeling, Graphics, and Animation
Prof. Jarek Rossignac
College of Computing
Georgia Institute of Technology
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 1
Graphic acceleration
• Eliminate insignificant details
– Use lower resolution approximations computed through simplification
• Use images instead of geometry
–
–
–
–
Texture maps instead of details
Imposters (billboards)
Panoramas
Images + depth
• Don’t render what is not visible
– Things that fall outside of viewing frustum
– Back faces
– Parts occluded by others
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 2
Motivation
• Visibility
– Most objects in a scene are hidden from any given view point
– Rendering them wastes GPU cycles
– Need efficient techniques for rejecting what is obviously hidden
• Rejection tests can be exact, conservative (reject more), approximate
• Shadows
– Objects in the shadow do not reflect direct illumination
– Want to know which light sources illuminate an object
– Need a quick test for being “in the shadow”
• Visibility and shadows are defined in terms of occluders
– Surfaces or objects that may block the passage of light when placed
between the object and the viewer/light
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 3
Occlusion culling in urban walkthrough
• From Peter Wonka
• Need only display a few facades--the rest is hidden
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 4
Shadows / visibility duality
FROM POINT
• Point light source
– Shadow (volume): set of points that do not see the light
• From-point visibility
– Occluded space: set of points hidden from the viewpoint
FROM AREA
• Area light source (assume flat for simplicity)
– Umbra: set of points that do not see any light
– Penumbra: set of points that see a portion of the light source
– Clearing: set of points that see the entire light source
• From-cell visibility (cell C)
– Hidden space: set of points hidden from all points in C
– Detectable space: set of points seen from at least one point in C
– Exposed space: set of points visible from all points in C
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 5
From-point visibility
• What is visible from a given viewpoint
– Not from a given area
• Usually computed at run-time for each frame
– Should be fast, and (reasonably) accurate (no popping)
– Or done in background before the user starts looking around
• May be pre-computed for a set of important viewpoints
– Pre-computation can be slow
– User will be invited to jump to these (street crossings, vistas)
– or to drive along pre-computed paths (videos)
• May be useful for pre-computing from-cell visibility
– Identifies all objects B that are invisible when the viewpoint is in a cell A
– The cell may be a cube or volume, a 2D area, or a trajectory (taxi metaphor)
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 6
From-point visibility pre-computation
•
•
•
•
•
Select a set of viewpoints or do it when you arrive to a new one
Make 6 images (on the walls of a small cube around viewpoint)
Write object Ids instead of colors in the frame buffer
Collect all Ids from the 6 images
Objects with Ids not collected will not be displayed
Can there be errors?
Can we make any guarantees about accuracy?
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 7
Outline for from-point-visibility
•
•
•
•
Simple shapes (triangle, ball)
Simple occluders (triangle, ball)
Convex occluders
Hoops (non convex surfaces)
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 8
From-point visibility
• Viewpoint/light = {a} (a single point)
HIDDEN
11/7/2015
DETECTED
Jarek Rossignac, CoC, IIC, GT
CLEAR
Shadows & visibility, slide 9
Zen break
•
•
•
•
•
The moon is a perfect ball
It is full and perfectly clear
You see it through your window
You wonder about the meaning of life
You trace its outline on the glass
Is is a circle?
Can you prove it?
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 10
Nothing is perfect
• In general, the outline of the moon is an ellipse
• Proof:
–
–
–
–
11/7/2015
The pencil of rays from your eye to the moon is a cone
The intersection of that cone with the window if a conic
If the moon is clear and visible through the window: it is an ellipse
When the window is orthogonal to the axis of the cone: it is a circle
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 11
Cherchez la lune
•
•
•
•
The moon is a ball B(c,r) of center c and radius r
The occluder is a triangle with vertices d, e, and f
Assume viewer is at point a
Write the geometric formulae for testing whether the moon is
hidden behind the triangle
f
c
e
HIDDEN
11/7/2015
d
DETECTED
Jarek Rossignac, CoC, IIC, GT
CLEAR
Shadows & visibility, slide 12
A triangle appear clockwise when
• The vertices d, e, f, of a triangle appear clockwise when seen from
a viewpoint a when s(a,d,e,f) is true
• Procedure s(a,d,e,f) {RETURN (ad•(aeaf)>0);};
– ad•(aeaf) is a 3x3 determinant
– It is called the mixed product (or the triple product)
f
f
e
a
11/7/2015
d
clockwise
d
a
Jarek Rossignac, CoC, IIC, GT
e
counter-clockwise
Shadows & visibility, slide 13
Testing a point against a half-space
• Consider the plane through points d, e, and f
• Consider the half-space H of all points that see d, e, f clockwise
• A point c is in H when s(c,d,e,f)
s(c,d,e,f) {RETURN cd•(cecf)>0}
f
e
c
11/7/2015
d
clockwise
Also remember that
s(c,d,e,f)==0 implies that
all 4 points are co-planar!
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 14
Test whether a point is hidden by a triangle
• To test whether c is hidden from a by triangle d, e, f do
–
–
–
–
–
–
IF NOT s(a,d,e,f) THEN swap d and e
IF NOT s(a,d,e,c) THEN RETURN FALSE
IF NOT s(a,e,f,c) THEN RETURN FALSE
IF NOT s(a,f,d,c) THEN RETURN FALSE
IF s(c,d,e,f) THEN RETURN FALSE
RETURN TRUE
c
f
e
d
a
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 15
Testing a ball against a half-space
• Consider the half-space H of all points that see (d, e, f) clockwise
• A ball of center c and radius r is in H when:
ec • (edef) > r ||edef||
c
e
d
f
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 16
Is the moon hidden by a triangle?
• To test whether the ball of center c and radius r hidden from a by
triangle with vertices d, e, and f do:
–
–
–
–
–
–
IF NOT s(a,d,e,f) THEN swap d and e
IF ac • (adae) < r || adae || THEN RETURN FALSE
IF ac • (aeaf) < r || aeaf || THEN RETURN FALSE
IF ac • (afad) < r || afad || THEN RETURN FALSE
IF ec • (edef) < r || edef || THEN RETURN FALSE
RETURN TRUE
f
• Explain what each line tests
• Are these test correct?
• Are they sufficient?
e
c
d
a
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 17
Is the moon hiding a triangle?
• Triangle d, e, f is hidden from viewpoint a by a ball of center c
and radius r when its 3 vertices are hidden.
– Proof?
– How to test it?
f
f
c
c
e
Hidden moon
e
d
d
Hidden triangle
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 18
Is a convex occluder hiding a polyhedron?
• A polyhedron is hidden if all of its vertices are
– Proof?
– Will this work for subdivision surfaces?
• We do not need to test all of the vertices
– Only those of a container (minimax box, bounding ball, convex hull)
• Proof?
– Only those on the silhouette of a convex container
• Proof?
• What if the occluder is not convex
– Can it still work?
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 19
Non-convex occluders?
What if O is not convex?
– replace O by an interior ball
• Not easy to compute a (nearly) largest ball inside O
• The average of the vertices of O may be outside of O
– replace O by an interior axis-aligned box
• Not easy to compute a largest box inside
– replace O by a convex set it contains
• O may be too thin
– use a Hoop!
• See next
Andujar, Saona Navazo
CAD, 32 (13), 2000
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 20
The problem
Some occluders are too thin to contain large convex objects.
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 21
The Hoops solution
The occluder does not have to be convex, provided that its outline seems convex from the
viewpoint
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 22
Hoops: 3D Curves as Conservative
Occluders for Cell-Visibility
P. Brunet, I. Navazo, J. Rossignac, C. Saona-Vázquez
Software Department, Polytechnic University of Catalonia
GVU Center, Georgia Institute of Technology
Manchester, 7th September 2001
Jarek Rossignac, CoC, IIC, GT
When does a 3D polyloop appear convex?
Each pair of consecutive edges defines a linear half-space from
where their common vertex appears convex.
n 
CAP( P)   H ( p , p p  p p )
i i 1 i i i 1
i 1
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 24
Testing against a hoop
• Given a hoop, we can easily test whether the viewpoint or a
whole cell sees it as convex.
– Test whether the viewpoint, or whether all the vertices of the cell, lie in
the intersections of all half-spaces.
• If so, then any simply connected surface bounded by the hoop
is an occluder
– Or is it?
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 25
How to grow hoops?
• Grow a patch on the surface
• Grow a curve on the boundary of interior octree cells and
simplify it
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 26
Cell-to-cell visibility
Now, let us look at the problem of pre-computing whether any
portion of a cell A is visible from a viewpoint in cell B.
Why? (Applications?)
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 27
Notation and assumptions
•
•
•
•
•
•
•
Two sets, A and B
Two points aA, bB
O is the occluder
A, B, and O are disjoint
ab is the line segment from a to b
a–b  O ab = , a sees b (ignore self-occlusion)
a | b  O ab ≠ , a is occluded from by O
O
11/7/2015
O
a
b
a
b
A
B
A
B
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 28
Definitions
A
• HIDDEN: HO(A,B)
– B is entirely hidden from A
– HO(A,B)  a, b: a | b
O
a
• DETECTED: DO(A,B)
– B can be detected from any point of A
– DO(A,B)  a, b: a–b
B
b
O
A
B
• GUARDED: GO(A,B)
– B can be guarded from a single point of A
– GO(A,B)  a, b: a–b
A
B
O
• CLEAR: CO(A,B)
– B can be guarded from any point of A
– CO(A,B)  a, b: a–b
a
A
11/7/2015
Jarek Rossignac, CoC, IIC, GT
O
b
B
Shadows & visibility, slide 29
Occlusion
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 30
ShieldTester: Cell-to-cell visibility test for
surface occluders
Isabel Navazo, Jarek Rossignac, Joan Jou, Rahim Shariff
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 31
The Occlusion Theorem
The surface S occludes cell A from cell B, if and only if:
1.
There exists a connected component, C, of ST that is bounding a portion
D of S and has no boundary in the interior of R.
(The portion, DR, of the boundary of D that lies in R is exactly C.)
2.
Given an arbitrary ray, RAB, from a point, a, in A to a point, b, in B,
RAB has an odd number of none tangential intersections with
the closed subset, DC, of S.
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 32
Various cases
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 33
ShieldTester for triangle meshes
Obtain an edge eAB of T from a vertex of A to a vertex of B
IF eAB S =  THEN RETURN (“visible”)
FOR EACH triangle x of S that is stabbed by eAB DO {
Start a WALK that traces a connected component C of ST
IF the WALK did not run into a boundary of S THEN {
INVADE the portion of S to the left of the triangles crossed
by the WALK along C
IF the invaded portion has no hole THEN
IF the number of triangles that were stabbed by eAB
and visited by the WALK and the INVADE is odd
THEN RETURN (“occluded”)}
RETURN (“undecided”)
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 34
Detecting ray/triangle clash
c
a
b
d
e
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 35
Walking one step
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 36
Testing for ray/triangle intersection
f
s(c,d,e,f) {RETURN cd•(cecf)>0}
e
To test whether c is hidden from a by
c
triangle d, e, f do
–IF NOT s(a,d,e,f) THEN swap d and e
–IF NOT s(a,d,e,c) THEN RETURN FALSE
–IF NOT s(a,e,f,c) THEN RETURN FALSE
–IF NOT s(a,f,d,c) THEN RETURN FALSE
–IF s(c,d,e,f) THEN RETURN FALSE
–RETURN TRUE
11/7/2015
Jarek Rossignac, CoC, IIC, GT
a
d
clockwise
c
f
e
d
Shadows & visibility, slide 37
Turning left on S
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 38
Invade process
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 39
Hot edges
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 40
Results
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 41
Lots of small occluders
• Can’t grow a patch of edge-connected triangles
– Leaves/branches are small and disjoint
• Use approximate shadow fusion
–
–
–
–
–
–
Render tree(s)
Mark area of rendered pixels
Construct big rectangle inside it (how?)
Let M= max(z-buffer inside rectangle)
Push back rectangle to z=M
Use it as occluder for other objects (behind the tree)
• Accuracy depends on screen resolution
– Can be improved by splitting the screen into 4
– Do this recursively (quad-tree)
• Use bounding spheres around objects to test them
– Conservative part
– Use a hierarchy of bounding sphere (hierarchical z-buffer)
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 42
Polygons cast curved shadows!
11/7/2015
Jarek Rossignac, CoC, IIC, GT
Shadows & visibility, slide 43