Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering...

63
Making Your Bokeh Fascinating Real - time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course Masaki Kawase Silicon Studio, Corp. [email protected]

Transcript of Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering...

Page 1: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Making Your Bokeh FascinatingReal-time Rendering of Physically Based Optical Effect in Theory and Practice

SIGGRAPH 2015 Course

Masaki Kawase

Silicon Studio, Corp.

[email protected]

Page 2: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Introduction

• Basic idea and theory [Kawase08]

– Only circular aperture

• Practical implementation and optimization [Kawase12]

– Any kind of aperture shapes

2

Page 3: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Contents

• Creating the Pencil Map

• Creating the Bundle-of-Light-Ray Map (Pencil Map)– “Bundle of Light Rays” or “Pencil Rays”

(referred to as “Pencil” here onwards)

• Application to Arbitrary Aperture Shapes

• Scattering or Gathering?

• Results

• Conclusion

3

Page 4: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Creating the Pencil Map

Page 5: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Creating the Pencil Map

• Precompute light paths from the aberration diagram– Takes spherical and axial chromatic aberrations into account

Light paths make up

pencil map

(small number of rays)

Longitudinal aberration

diagram

Pencil mapAmount of aberration

Incid

ent h

eig

ht

5

Page 6: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Circular Bokeh Rendering

• V coordinate represents the distance from the optical axis

– Mapping each slice to a circle produces a circular ‘bokeh’

Pencil map

Circular bokeh

U: Distance from lens

V: D

ista

nce

from

op

tica

l axis

6

Page 7: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Discretized Result…

7

• Chromatic aberration is an issue

• Three wavelengths (R/G/B) are insufficient to represent the dispersion

Page 8: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Increasing Wavelength Samplings

• Calculate the map with more wavelengths

• Convert into the RGB space

8

Page 9: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

3-Wavelength Samplings

9

Page 10: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Sufficient Wavelength Samplings

10

Page 11: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Bokeh with Spherical and Chromatic Aberration

• Imperfect focus

• Front bokeh with red sharp edge

• Back bokeh with blue soft edge

11

Zoomed-in view around the focal point

Page 12: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Comparison with photographs

Captured in real photographs

Generated from pencil map

12

Page 13: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Creating the Pencil Map of Doublet

13

• Calculate the map with the longitudinal aberration diagram

• Using actual lens parameters (if they exist)

– Only ray paths of each wavelength are required

Light paths make up

pencil map

Longitudinal aberration

diagram

Pencil map

Page 14: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Pencil Map of Doublet

Pencil maps and bokeh

Zoomed-in view around the focal point

14

Page 15: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Comparison with photographs

15

• Typical correction– Front bokeh has soft purple edge and the center is darker– Back bokeh has sharp green edge and the center is brighter

Front bokeh in photographs Back bokeh in photographs

Front and back Bokeh with Pencil map

Page 16: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Different Type of Doublet

• Residual chromatic aberration is more visible thanresidual spherical aberration

Light paths make up

pencil map

Longitudinal aberration

diagram

Pencil map

16

Page 17: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Pencil Map of Doublet (Different Type)

Zoomed-in view around the focal point

Pencil maps and bokeh17

Page 18: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Pencil Map of Doublet (Previous Type)

Pencil maps and bokeh

Zoomed-in view around the focal point

18

Page 19: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Comparison with photographs

Front bokeh in photographs Back bokeh in photographs

Front and back Bokeh with Pencil map

19

Page 20: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Optimization of Pencil Map

• Wasteful parts in the texture– Sparse, many texels are empty

– There is not enough precision around the more important ‘focusing’ texels

Wasteful pencil map

20

Page 21: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Optimization of Pencil Map (cont’d)

• Normalizing height of bundle at every distance(u-axis)by the maximum height(bokeh size)

• Less empty texels, and great improvement in precision around focusing texels

Wasteful pencil map Normalized pencil map

21

Page 22: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Spherical lens (with no corrections)

Aspherical lens (chromatic aberration is not corrected)

Achromatic doublet lens

22

Page 23: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Achromatic doublet lens (different type)

Apochromatic (APO) lens

Perfect lens (does not actually exist)

23

Page 24: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Application to Arbitrary Aperture Shapes

Page 25: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Various Aperture Shapes

• Aperture shape is an important artistic factor– Typically 5~9 diaphragm blades

– Changes from rounded to n-gon

• How to map pencil onto the polygonal aperture shape?– 3D Textures?

• Too large, not practical?

Pencil mapAperture shape

25

Page 26: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Indirect Reference of Pencil Map

• Precompute an LUT texture that stores V coordinates of pencil map

LUT texture

0

1

0

0

0

0

0

00

0

0

0

0

0

1

V

Vertical slice

26

Page 27: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Indirect Reference of Pencil Map (cont’d)

• Sample pencil map indirectlyat run-time

Pencil map

0

1

V

Look up

Sampling

LUT 27

Page 28: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Indirect Reference of Pencil Map (cont’d)

• LUT determines the aperture shape

– Independent of pencil map

– Can reproduce curved shapes of a diaphragm blade

• Prepare a set of LUTs for various diaphragm conditions

– Other shapes such as stars, hearts, … can be used

28

Page 29: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Various LUTs• For the number of diaphragm blades and opening levels• Smooth deformation is possible by interpolating between two adjacent LUTs

4 blades

5 blades

6 blades

7 blades

Fully opened ClosedClosing

29

Page 30: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Silhouette LUTs for debug

Fully opened

4 blades

5 blades

6 blades

7 blades

ClosedClosing

30

Page 31: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Scattering or Gathering?

Page 32: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Both can be Implemented

• Better quality by scattering

– Heavy processing load

• Hybrid method is recommended

– Both scattering and gathering

32

Page 33: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Hybrid Method

• To determine which pixels will be scattered or gathered, use:

– The CoC size

– Difference in luminance between neighboring pixels

Original Result (green: gathering pixels)

33

Page 34: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

34

Gathering

Page 35: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

35

Hybrid of Scattering and Gathering

Page 36: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Optimization

• Use a half resolution buffer for scattering– Scattering process can be 16x faster

• Split the process into several passes withhierarchical resolution buffers– Use lower resolution for larger bokeh

– The process at the 1/4 x 1/4 resolution can be 256x faster

• Scatter a pixel every 2x2 pixelsfor relatively larger bokeh in each resolution– Pixels that have an especially heavy processing load will be 4x faster

36

Page 37: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Results

Page 38: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Back bokeh with cyan fringes

Front bokeh with red/purple fringes

Bokeh Simulation in Real Time

Page 39: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Diaphragm Simulation

5-blade Aperture

Page 40: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Diaphragm Simulation

6-blade Aperture

Page 41: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Diaphragm Simulation

7-blade Aperture

Page 42: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Diaphragm Simulation

8-blade Aperture

Page 43: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Curved Diaphragm and Optical Vignetting

• Opening / Closing

– Deformation

• Circular aperture

• Polygonal aperture

– Rotation

– Optical Vignetting

• Cat’s Eye Effect

43

Page 44: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

5-blade Circular Aperture (with Optical Vignetting)

f/1.4 (Fully Opened)

Page 45: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

5-blade Circular Aperture (with Optical Vignetting)

f/2 (1 Stop Closed)

Page 46: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

5-blade Circular Aperture (with Less Optical Vignetting)

f/2.8 (2 Stops Closed)

Page 47: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

5-blade Circular Aperture (with No Optical Vignetting)

f/5.6 (4 Stops Closed)

Page 48: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

5-blade Circular Aperture (with Fake Diffraction Spikes)

f/11 (6 Stops Closed)

Page 49: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Various Aberrations and Corrections

• Correction of SA and axial CA mostly affect bokeh

Focus plane

Back bokeh

Front bokeh

Differences between front and back bokeh

49

Page 50: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

50

Spherical Lens (with No Corrections)

Page 51: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

51

Aspherical Lens (with Chromatic Aberrations)

Correction of Spherical Aberration

Page 52: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

52

Achromatic Lens

Corrected for Red and Blue Wavelengths

Page 53: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

53

Achromatic Lens (Different Type)

Corrected for Red and Blue Wavelengths

Page 54: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

54

APO (Apochromatic) Lens

Corrected for 3 Wavelengths (More Expensive Lens)

Page 55: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

55

Almost Perfect Lens

Without any Spherical and Longitudinal Chromatic Aberrations

Page 56: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

56

STF (Smooth Transition Focus) Lens

Soft Edged Bokeh by Apodization Optical Element

Radial gradient ND filter

Page 57: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Residual Aberration Visibility

Out of focus: Large

Aberrations: Less visible

Out of focus: Small

Aberrations: Strongly Visible

Page 58: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Residual Aberration Visibility

Out of focus: Large

Aberrations: Less visible

Out of focus: Small

Aberrations: Strongly Visible

Out of focus: Large

Aberrations: Less visible

Out of focus: Small

Aberrations: Strongly Visible

Page 59: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Comparison with Photographs (Achromat)

Real photographs with achromatic lensReal-time simulation results

59

Page 60: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Comparison with Photographs (APO)

Real photographs with apochromatic lensReal-time simulation results

60

Page 61: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Conclusion

Page 62: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

Conclusion

• Reproduce photorealistic bokeh with pencil map and LUT

– Pencil map defines bokeh characteristics

– LUT defines bokeh shapes

• Optimization

– Various options available

– Combinations can be used to improve performance

62

Page 63: Making Your Bokeh Fascinating - Silicon Studio · Making Your Bokeh Fascinating Real-time Rendering of Physically Based Optical Effect in Theory and Practice SIGGRAPH 2015 Course

References

• [Kawase08] Kawase, M. “Bokeh Expressions Based on Optics.” Computer Entertainment Developers Conference, 2008.

• [Kawase12] Kawase, M. “Practical Implementation of Cinematic Lens Effects.” Computer Entertainment Developers Conference, 2012.

• Kawase, M. “Reduce Artifacts Generated by Mipmapped Buffers.” Computer Entertainment Developers Conference, 2009.

• Trávník, J. “On Bokeh.” Jakub Trávník's resources. http://jtra.cz/stuff/essays/bokeh/index.html

• 安藤幸司『光と光の記録「レンズ編」』 AnfoWorld http://www.anfoworld.com/LensMF.html

• 吉田正太郎(1997)『カメラマンのための写真レンズの科学』地人書館.

63