Shadows increase realism: Cry Cry En Engine Zaxxon Zaxxon - - PowerPoint PPT Presentation

shadows increase realism
SMART_READER_LITE
LIVE PREVIEW

Shadows increase realism: Cry Cry En Engine Zaxxon Zaxxon - - PowerPoint PPT Presentation

Shadows increase realism: Cry Cry En Engine Zaxxon Zaxxon (1982) 2 Shadows increase realism Shadows help you perceive: hidden objects 3 Shadows increase realism Shadows help you perceive: hidden objects the


slide-1
SLIDE 1
slide-2
SLIDE 2

Shadows increase realism:

2

Cry Cry En Engine Zaxxon Zaxxon (1982)

slide-3
SLIDE 3

Shadows increase realism Shadows help you perceive:

hidden objects

3

slide-4
SLIDE 4

Shadows increase realism Shadows help you perceive:

hidden objects the relative position of objects

4

slide-5
SLIDE 5

Shadows increase realism Shadows help you perceive:

hidden objects the relative position of objects the object shape

5

slide-6
SLIDE 6

6

Constraints for real-time shadows

  • Light sources

Dynamic

  • Shadow Casters

Dynamic

  • Shadow Receivers

Dynamic

Do Doom 3 3 (2004)

slide-7
SLIDE 7

2 kind of shadows:

Hard Hard shad shadows ws Point light source Soft t shad shadows ws Extended light source

7

slide-8
SLIDE 8

Point light source A point is in shadow if it is not 


visible from the light source

8

Point light source Shadow caster Shadow receiver shadow

slide-9
SLIDE 9

3 areas:

Shadow: light source completely hidden Penumbra: light source partially hidden Lit: light source completely visible

9

Extended light source penumbra Shadow caster penumbra Shadow receiver shadow

slide-10
SLIDE 10
slide-11
SLIDE 11

MIT EECS 6.837, Durand and Cutler

A point is lit if it is

visible from the light source

Computing shadows=

visible surface determination

11

slide-12
SLIDE 12

Draw the graphics primitives again, projected

  • n the ground

12

MIT EECS 6.837, Durand and Cutler

slide-13
SLIDE 13

+ Fast, easy to code

  • No self shadows, no shadows on curved

surfaces, no shadows on other objects

13

MIT EECS 6.837, Durand and Cutler

slide-14
SLIDE 14

14

Separate between occluder and receiver Draw a picture of the occluder, seen from the

light source

Use it as a texture on the receiver

Möller & Haines “Real Time Rendering”

From From th the light t source From From th the vi viewp wpoint nt

slide-15
SLIDE 15

15

Sha

Shadow w Maps s

Image space approach

Sha

Shadow w Vo Volume umes s

Object space approach

slide-16
SLIDE 16
  • 1. Offscreen rendering from th

the light t source

Keep z-buffer in a texture

  • 2. Rendering from th

the view point t

Transform current pixel into light space coord. Compare current depth with depth in texture Change lighting depending on visibility test

16

slide-17
SLIDE 17
  • ffscreen rendering from the light source:

Transformation + projection matrix Light space coordinates Store depth into an FBO

FBO -> texture

17

slide-18
SLIDE 18

Standard rendering Vertex shader:

Compute projection in screen space And in light space

Fragment shader :

Interpolate coordinates

  • Coord. texture shadow map

z = distance light source z from shadow map Comparison ⚠️Coord. texture =[0,1]2

18

Pixel

  • Coord. Light

space

slide-19
SLIDE 19

z_shadowMap < z_computed

In shadow Ambient lighting only

z_shadowMap == z_computed

Lit Ambient + Diffuse + Specular

z_shadowMap > z_computed

Should not happen, in theory

19

slide-20
SLIDE 20

20

slide-21
SLIDE 21

“it’s not a bug, it’s a feature” What’s happening?

Comparison z stored/interpolated z z value constant for each pixel Self-shadowing

Solutions:

Comparison with z+epsilon (bias) Draw only back-sided surfaces

21

slide-22
SLIDE 22

Easy: glCullFace(GL_FRONT);

22

slide-23
SLIDE 23

23

A few issues with self-shadowing (in reverse) Still need bias for comparisons.

slide-24
SLIDE 24

24

slide-25
SLIDE 25

25

slide-26
SLIDE 26

26

slide-27
SLIDE 27

27

Shadow discontinuities

slide-28
SLIDE 28

Slope-dependent: tan(angle N,L)*a + b

b > 0, a = ?

Relative: z1*(1 - epsilon) < z2

28

slide-29
SLIDE 29

It’s a projection:

Must divide by w

What does it mean if w < 0?

What should we do?

What should we do if we’re outside shadow

map?

How can we check?

29

slide-30
SLIDE 30

Pr

Pros s

Easy to implement Works, regardless of the geometry of the scene Cost does not depend on scene complexity

Cons

Cons

Several (>= 2) scene rendering Omni-directional light sources? Sampling/aliasing

Increasing shadow map resolution is not 
 enough (light source facing viewer)

30

slide-31
SLIDE 31

Increase shadow map resolution Focus shadow map on visible parts of the

scene

Adapt sampling (warping)

Depending on light-source distance

Multi-resolution Shadow maps

Cascading shadow map

31

slide-32
SLIDE 32

32

Increases the practical resolution

slide-33
SLIDE 33

How? Linear projection

Not centered on the light source Optimized based on view frustum + LS position

TSM, LiSPSM...

33

Uniform sampling in z Variable sampling in z

slide-34
SLIDE 34

34

slide-35
SLIDE 35

35

slide-36
SLIDE 36

36

slide-37
SLIDE 37

37

slide-38
SLIDE 38

38

slide-39
SLIDE 39

39

  • 1. For each shadow casters, build a shad

shadow vo volume ume

  • 2. For each fragment, count

t how many times we enter/leave a shadow volume

> 0 : in shadow = 0 : lit

slide-40
SLIDE 40

Building a shadow volume

Silhouette of each object from the light source Infinite quads touching

the light source Each silhouette edge

Counting entering/leaving

Use the stencil buffer Use the orientation of each shadow quad
 for the sign

40

slide-41
SLIDE 41

Silhouette of each object from the light

source

41

How? 1mn

slide-42
SLIDE 42

42

How? 1mn

slide-43
SLIDE 43

Use the Stencil buffer

Shadow volume side visible, front-facing: +1 Shadow volume side visible, back-facing: -1

2 rendering pass:

First front-facing, then back-facing glCullFace(...)

1 rendering pass:

glStencilOpSeparate(GL_FRONT, GL_KEEP, GL_INCR_WRAP, GL_KEEP); glStencilOpSeparate(GL_BACK, GL_KEEP, GL_DECR_WRAP, GL_KEEP);

43

slide-44
SLIDE 44

44

slide-45
SLIDE 45

What if the eye is in shadow?

45

+1

  • 1
slide-46
SLIDE 46

Have a lit point as reference A point at infinity must be lit Need to cap the shadow volume

46

Simply invert z-test and invert stencil inc/dec

+2

Near Near cap capping ing Far cappin Far capping

slide-47
SLIDE 47

47

slide-48
SLIDE 48

Pr

Pros: s:

Sharp shadows Arbitray positions for light source/caméra Robust (if well programmed)

Cons:

Cons:

silhouette computation (CPU/GPU) requirements on scene geometry (manifold, closed surfaces) Rendering the scene twice, + the shadow volumes

48

slide-49
SLIDE 49

49

slide-50
SLIDE 50
slide-51
SLIDE 51

More complex

Point- t-to to-area visibility, with continuous value

Instead of binary point-point visibility silhouette?

51

slide-52
SLIDE 52

More complex

Point- t-to to-area visibility, with continuous value

Instead of binary point-point visibility silhouette?

Shadow of the sum ≠ sum of shadows

A hides 50% and B hides 50%, A+B doesn’t hide 100%

52

slide-53
SLIDE 53

More complex

Point- t-to to-area visibility, with continuous value

Instead of binary point-point visibility silhouette?

Shadow of the sum ≠ sum of shadows

A hides 50% and B hides 50%, A+B doesn’t hide 100%

Many algorithms

With varying accuracy

Approximating the shadow casters Precomputations (Precomputed Radiance Transfert)

With varying speed

53

slide-54
SLIDE 54

Accumulating shadows:

Compute several hard shadows Add them, average the results accumulation buffer Needs many samples

Computation time proportional to # échantillons

54

4 échanti tillons 1024 échanti tillons

slide-55
SLIDE 55

For each silhouette edge:

Compute volume around penumbra (wedge) For each pixel in this wedge

Compute attenuation coefficient

Beautiful, realistic, expensive

55

Penumb Penumbra wed wedges ges [Sig03] U. Assarson, T. Möller

slide-56
SLIDE 56

56

Rendering Fake Soft t Shadows with th Smooth thies [SoR03]


  • E. Chan, F. Durand
slide-57
SLIDE 57

Percentage Close Filtering (PCF)

Filter shadow map around sampling point Possible GPU speed-ups (2x2 kernel) Pre-filtered, stored in mip-map

57

1 sample 9x9 kernel 17x17 kernel

slide-58
SLIDE 58

Percentage Closer Soft Shadows (PCSS)

[Fernando 05]

Compute kernel size first, by sampling shadow map Filter using PCF 
 (or extensions)

58

slide-59
SLIDE 59
  • 1. Blocker search

59

Average occluder depth

  • Shadow map
slide-60
SLIDE 60
  • 2. penumbra size

60

Planar

  • ccluder
slide-61
SLIDE 61
  • 3. filtering

61

  • Filter region

(size ~ )

(here, occlusion = 50 %)

slide-62
SLIDE 62
  • 1. blocker search
  • 2. penumbra size
  • 3. filtering

62

2 steps requiring several access to shadow map

slide-63
SLIDE 63

Easy, quite fast Visually pleasing results

For a small light source

No physical realism Visible artefacts

For large penumbra width If occluders hidden from center of light source For non-flat occluders

63

slide-64
SLIDE 64

Percentage Closer Soft Shadows (PCSS)

[Fernando 05]

64

Hellgate te: London (2007) PCSS PCF

slide-65
SLIDE 65

65

Soft t Shadow Maps [AHLHHS06] Atty et al. Real-time Soft Shadow Mapping by Backprojection [GBP06] Guennebaud et al..

slide-66
SLIDE 66

Shadow map = object discretization Compute shadow of discretized object Realistic, real-time, animated scene [Atty06] et [Guennebaud06]

66

slide-67
SLIDE 67

67

slide-68
SLIDE 68
slide-69
SLIDE 69

Approximating the

  • cclusion under distant

lighting

Ambient term taking visibility into account

Perceptually related to

depth, curvature and spatial proximity

69

slide-70
SLIDE 70

Integral of visibility over hemisphere Ω:

Cosine term diffuse lighting Usually, attenuation depending on the distance to P

70

slide-71
SLIDE 71

Sampling

Precomputation (ray-casting) Store in a texture

+ Rendering at no extra cost

  • Slow precomputation
  • Static scene

71

GPU GPU Gems, Gems, cha hap 17 Diffuse + AO Diffuse

slide-72
SLIDE 72

Screen-Space Ambiant Occlusion (SSAO)

Use the depth buffer as an approximation of the scene For each pixel, sample the hemisphere on the GPU Filtering for noise reduction

+ Independent form scene complexity + No pre-computation + Dynamic scene

  • Longer rendering

72

Cry Engine 2

slide-73
SLIDE 73

Fragment shaders get expensive:

Complex materials, textures, indirect lighting...

  • Pb. for complex scenes/multi-layers:

Shading for all surfaces Even if they’re invisible Z-buffer test after the fragment shader

Need: visibility before shading materials

Theoretically impossible Solution: deferred shading

73

slide-74
SLIDE 74

1st pass: rendering into 3-4 aux. buffers 2nd pass: compute shading 


using these buffers

74

Position (x,y,z) Normals Colors, materials, textures

slide-75
SLIDE 75

SSAO :

Needs a geometry buffer Is expensive: must reduce number of calls

Deferred shading :

Has a geometry buffer Did visibility as pre-computation

Good match of algorithms

75

slide-76
SLIDE 76

76

Approximati ting Dy Dynamic Global Illuminati tion in Image Sp Space Ritschel et al. 2009