Computer Graphics Basics Probabilistic Morphable Models Summer - - PowerPoint PPT Presentation

computer graphics basics
SMART_READER_LITE
LIVE PREVIEW

Computer Graphics Basics Probabilistic Morphable Models Summer - - PowerPoint PPT Presentation

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL Computer Graphics Basics Probabilistic Morphable Models Summer School, June 2017 Sandro Schnborn University of Basel > DEPARTMENT OF


slide-1
SLIDE 1

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Computer Graphics Basics

Probabilistic Morphable Models Summer School, June 2017 Sandro Schönborn University of Basel

slide-2
SLIDE 2

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Computer Graphics

  • Artificial Image Computation
  • Focus: Photorealistic Rendering
  • Computer graphics is more:

visualization, non-photorealistic rendering, animation, …

2

slide-3
SLIDE 3

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Image Formation

Study of light:

  • Light is emitted by source
  • Light travels through space
  • Light interacts with objects
  • Light is reflected
  • Light is refracted
  • Light is captured by sensor

3

Computer Graphics: Simulation of light

slide-4
SLIDE 4

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Computer Graphics Compromise

  • Inspired by physical cameras
  • Light and matter interaction
  • Light propagation
  • Optimal goal:

Simulation of physical reality

  • Unrealistic! Infeasible
  • The perfect model?
  • Unknown parameters
  • Computational capacity

Compromise:

  • Models to achieve results

which are good enough

  • Finding good-looking and

simple approximations

  • Simple models
  • Surface rendering

(volume, interacting media, …)

  • Lambert and Phong reflectance

4

slide-5
SLIDE 5

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Rendering

Geometry: Correspondence

  • Light transport & refraction
  • Scene setup
  • Correspondence

Image point ↔ face point

Shading: Value

  • Light-matter interaction
  • Color values
  • Needs correspondence

Camera

5

slide-6
SLIDE 6

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Geometry

Coordinate transforms Model, View transform Camera model Projection Object Mesh

sensor

6

slide-7
SLIDE 7

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Shading: Light-Matter Interaction

Reflectance Models

Transform incoming light into outgoing light

7

slide-8
SLIDE 8

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Modern Graphics Pipeline

  • Common design
  • Specialized hardware
  • Efficient, parallel
  • Programmable: Shaders

(blue parts)

  • OpenGL (ES, WebGL),

Direct3D, Vulkan, Metal

8

In scalismo-faces: Close to standard design fully controllable

slide-9
SLIDE 9

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Geometry

9

slide-10
SLIDE 10

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

3D Scene

  • 3D scene

Objects in a world

  • Camera takes the picture

Image lives on image plane

10

Camera Object Multiple coordinate systems!

Typically 4 steps to image:

Model Transform View Transform Projection Viewport Transform

slide-11
SLIDE 11

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Model and View Transform

11

Model World

Reference frame

Eye

Camera frame

Model Transform 𝑈# View Transform 𝑈$ 𝑦 𝑧 𝑨

slide-12
SLIDE 12

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Pinhole Camera: Perspective Projection

  • Image formation on sensor

image plane (3D -> 2D)

  • Condition for sharp image:

A sensor pixel captures light from a single point in scene

  • Image plane coordinates by

perspective division: 𝑦′ 𝑧′ = 𝑔 ∗ 𝑦 𝑨 ⁄ 𝑧 𝑨

  • Non-linear division operation

12 Light leaves surface in all directions Camera captures rays passing through aperture A sensor point captures light from a single point in scene only

Pinhole camera

Single point aperture

Focal length f Object distance z sensor aperture

slide-13
SLIDE 13

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Perspective Effect

  • Perspective division distorts image non-linearly
  • Effect depends on relation of object size and distance

13

slide-14
SLIDE 14

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Our Transformations

  • Model-View

𝑈#$ 𝑦 = 𝑆/,1,2 𝒚 + 𝒖

  • Projection

𝒬 𝑦 = 𝑔 𝑨 𝑦 𝑧

  • Viewport

𝑈$7(𝑦) = 𝑥 2 (𝑦 + 1) ℎ 2 (1 − 𝑧) + 𝒖??

  • Describes our face-to-image

transform completely

  • 9 Parameters:
  • (3) Translation 𝒖
  • (3) Rotation 𝜒, 𝜔, 𝜘
  • (1) Focal length 𝑔
  • (2) Image Offset 𝒖??
  • 2 Constants:
  • (2) Image size / sampling

14

slide-15
SLIDE 15

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Rasterization

  • Camera: 3D → 2D

transformation for points

  • Raster Image in image plane
  • Establishes correspondence

to 3D surface for each pixel

  • Basis: geometric primitives

15

𝑥 ℎ (0,0)

(4,2)

Pixel grid, cell-centered

slide-16
SLIDE 16

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Primitives: Triangles

  • Triangle meshes for surface

parametrization:

  • Triangle
  • Position within triangle
  • Parametrization within triangle
  • Barycentric coordinates 𝝁
  • Barycentric interpolation

𝑔 𝑄 = 𝑣𝑔 𝐵 + 𝑤𝑔 𝐶 + 𝑥𝑔 𝐷

  • In/out Test:
  • All BCC valid (non-negative)

16

𝝁 = 𝑣, 𝑤, 𝑥 𝑣 + 𝑤 + 𝑥 = 1 𝑣, 𝑤, 𝑥 ≥ 0 𝐵 𝐶 𝐷 𝑄 𝑄 = 𝑣𝐵 + 𝑤𝐶 + 𝑥𝐷

counter-clockwise winding!

slide-17
SLIDE 17

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Rasterization: Correspondence

𝝁 𝝁

  • Each image pixel is mapped to surface point
  • Point identification by parameterization with triangle and barycentric coordinate

17

slide-18
SLIDE 18

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Rasterization of Triangle Primitives

  • For each triangle:
  • Find Vertex position (corners)
  • Determine bounding box
  • For all pixels in box:
  • Inside triangle?
  • Find BCC in plane:

correspondence to 3D through BCC

  • Draw the pixel

18

(0,0)

Efficient! No ray intersections (not perfect though) Vertex shader Fragment shader

slide-19
SLIDE 19

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Visibility Issues

  • Multiple triangles might cover

the same pixel

  • 3D surface occludes background
  • Only the most frontal part is

visible in the image

  • Needs special care during

rendering: Hidden Surface Removal

19 Triangles behind are drawn

  • n top of those in front
slide-20
SLIDE 20

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Hidden Surface Removal: Z-Buffer

  • Keep additional Z-Buffer:
  • Store depth information for

each pixel

  • Draw a pixel only if it lies in

front of previous drawing

  • Standard approach
  • Easy and versatile
  • Extensible to shadowing
  • Issues:

Precision, single value per pixel

20

In front

slide-21
SLIDE 21

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Illumination

21

slide-22
SLIDE 22

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Illumination

  • Color in image is result of

light and surface interactions

  • Shading: simulate light

interaction and transport

  • Illumination is global:

Lights scatters through scene, interaction with many objects

  • Global transport
  • Local interaction

22

slide-23
SLIDE 23

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Reflectance Models: BRDF

Geometry

  • 𝑴 Light direction
  • 𝑶 Surface normal
  • 𝑾 Viewing direction

Spectrum

  • Albedo (color)
  • Eye and most cameras: 3 color sensor types
  • RGB Model: spectral distribution is sampled

for red, green and blue 𝑑 = 𝑠, 𝑕, 𝑐 , 𝑠, 𝑕, 𝑐 ∈ [0,1]

23

Bidirectional Reflectance Distribution Function 𝑔 𝜇Z, 𝑴, 𝜇[, 𝑾, 𝒚 = d𝑀[ 𝑾 d𝐹Z 𝑴

incoming light (irradiance) into outgoing light (radiance)

𝑾 𝑶 𝑴

slide-24
SLIDE 24

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Lambertian Reflectance

  • Diffuse Reflectance
  • Surface absorbs all radiation

and reemits into every direction

  • Not directional
  • Constant BRDF
  • Brightness of surface depends
  • n incident energy
  • Deep surface interaction:

Albedo: 𝑙`abb (colored)

24

𝐽`abb = 𝑙`abb ∗ 𝐽d ∗ cos 𝑴, 𝑶

Observed intensity Light intensity Reflection coefficient

slide-25
SLIDE 25

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Lambertian Reflectance: Examples

25

slide-26
SLIDE 26

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Specular Highlights

  • Mirror-like reflectance
  • Highly directional
  • Reflection cone due to

surface roughness

  • Mostly without deep surface

interaction

𝑙hijk not colored

  • Parameter:

𝑜 Phong exponent Width of specular cone

26

𝐽hijk = 𝑙hijk ∗ 𝐽d ∗ cos 𝑺, 𝑾 n

slide-27
SLIDE 27

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Phong Specularity: Examples

27

Specular reflection Specular & diffuse

slide-28
SLIDE 28

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Global Illumination

Illumination is global in scene Approximation levels:

  • Ambient Light

Model scattered light as constant average value throughout scene

  • Environment Map

Incoming light intensity for each direction (empirically captured)

  • Real global illumination

Calculate light scattering through scene (extremely expensive)

28 Darnal

slide-29
SLIDE 29

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Phong Illumination Model

  • Combination of three

illumination contributions:

  • Lambert (diffuse)
  • Specular
  • Ambient (global)
  • Ambient is a scene average

light intensity 𝐽o

  • Lambert and specular part

for each light source

29

𝐽p = 𝑙qrs ∗ 𝐽o + 𝑙`abb ∗ 𝐽d ∗ cos 𝑀, 𝑂 + 𝑙hijk ∗ 𝐽d ∗ cos R, V n

𝑙`abb ∗ 𝐽d ∗ cos 𝑀, 𝑂 𝑙hijk ∗ 𝐽d ∗ cos R, V n 𝑙qrs ∗ 𝐽o

usually colored

slide-30
SLIDE 30

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Environment Maps

  • Mapping of incoming light

intensity from every direction 𝐽d

wxy 𝜄, 𝜒

  • Modeled at infinity
  • Typically empirically captured
  • Shading with environment

maps requires integration

  • ver all incoming directions

30

slide-31
SLIDE 31

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Environment Maps

31

Grace Cathedral (San Francisco)

  • P. Debevec

White surface in Grace Cathedral

slide-32
SLIDE 32

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Spherical Harmonics Illumination

  • Expand map 𝐽d

wxy 𝜄, 𝜒 with

basis functions

  • Choose Spherical Harmonics:

Eigenfunctions of Laplace

  • perator on sphere surface

𝑍

|}(𝜄, 𝜒)

  • Corresponds to Fourier transform
  • Integration becomes

multiplication of coefficients (→ fast convolution)

  • Low frequency part is sufficient

for Lambertian reflectance

32 Inigo.quilez

Ramamoorthi, Ravi, and Pat Hanrahan. "An efficient representation for irradiance environment maps." Proceedings of the 28th annual conference on Computer graphics and interactive techniques. ACM, 2001.

slide-33
SLIDE 33

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Environment Map Illumination

33

slide-34
SLIDE 34

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

3DMM Rendering of Faces

34

slide-35
SLIDE 35

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

3DMM Face Rendering

  • Rigid Model Transform
  • Pinhole camera model
  • Mesh with position and color

at each vertex (~albedo):

Two independent, discrete low- rank Gaussian Processes (~30k points)

  • Spherical Harmonics

Illumination

  • Lambert
  • Environment map

2 Bands, 9 coefficients x RGB

35

slide-36
SLIDE 36

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

3DMM Random Faces

36

slide-37
SLIDE 37

> DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE PROBABILISTIC MORPHABLE MODELS | JUNE 2017 | BASEL

Summary: Rendering

  • Computer Graphics:

Artificial image computation

  • Camera & Projection

Transformations in space and projection Maps 3D space and 2D image plane

  • Rasterization

Correspondence: image pixels ↔ surface Z-Buffer: Hidden surface removal

  • Shading

Illumination simulation

  • Reflectance

Phong: Ambient, diffuse & specular Global Illumination

37