52
-----------------+----------------- SPARKLY BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

Embed Size (px)

Citation preview

Page 1: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - -

SPARKLY BUT NOT TOO SPARKLY!

Anti-aliasing a procedural sparkle effect

Huw Bowles Beibei Wang

SIGGRAPH 2015 Advances in Real-Time Rendering in Games

Page 2: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

SNOW SPARKLE

Page 3: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

SNOW SPARKLE

Page 4: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

WHY PROCEDURAL?

• Reasonably difficult to achieve with normal maps

• Wanted option to have procedural sparkles over a large depth range – Miniaturisation of scene

• To work independent of lighting conditions

• To be present in shadows and indoors

Page 5: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

PROCEDURAL SPARKLES

• Algorithm from Shopf: intersect sparkle grid with surface

Page 6: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

PROCEDURAL SPARKLES

• Algorithm from Shopf: intersect sparkle grid with surface

Page 7: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

PROCEDURAL SPARKLES

• Algorithm from Shopf: intersect sparkle grid with surface

Page 8: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

PROCEDURAL SPARKLES

• Finally, a number of offsets are applied to the grid – 3D noise – View vector – Time component

Page 9: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

PROCEDURAL SPARKLES – ISSUES

Page 10: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

PROCEDURAL SPARKLES – ISSUES

Page 11: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

CONTENTS

• Sparkle shape

• Expanding distance range

• Noise distortion

• Anisotropy

Page 12: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

CONTENTS

• Sparkle shape

• Expanding distance range

• Noise distortion

• Anisotropy

Page 13: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

SPARKLE SHAPE

• Sharp and pointy

• Frequent odd shapes

• Does not scale down well

Page 14: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

SPARKLE SHAPE

• Simply make round

• Reduces odd shapes

• Scales down well

• Simpler

Page 15: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

SPARKLE SHAPE – BEFORE

Page 16: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

SPARKLE SHAPE – AFTER

Page 17: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

CONTENTS

• Sparkle shape

• Expanding distance range

• Noise distortion

• Anisotropy

Page 18: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

SPARKLE SIZE

• Sparkle size inappropriate outside narrow depth range

• Multiply size by Z to compensate for perspective

Page 19: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

SPARKLE SIZE

Page 20: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

GRID SCALING

• Could blend multiple grids – Requires multiple sparkle computations

• Scale grid based on distance?

Page 21: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

GRID SCALING

Page 22: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

GRID LEVELS

• Solution - step the grid scale

0

2

4

6

8

10

121 4 7

10

13

16

19

22

25

28

31

34

37

40

43

46

49

52

55

58

61

64

67

70

73

76

79

82

85

88

91

94

97

10

0

10

3

Grid Scale

scale

scale linear steps

Page 23: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

GRID LEVELS

• Logarithmic steps

0

2

4

6

8

10

121 4 7

10

13

16

19

22

25

28

31

34

37

40

43

46

49

52

55

58

61

64

67

70

73

76

79

82

85

88

91

94

97

10

0

10

3

Grid Scale

scale

scale linear steps

scale log steps

Page 24: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

LINEAR GRID LEVELS

Page 25: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

LOG GRID LEVELS

Page 26: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

ONE GRID LEVEL

Page 27: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

MULTIPLE GRID LEVELS

Page 28: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

VIEW DEPENDENCE

• We shift the sparkle grid based on the view vector

View vectors (blue) very similar when normalized (green)

Page 29: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

VIEW DEPENDENCE

• We shift the sparkle grid based on the view vector

View vectors (blue) very similar when normalized (green)

Modulus (orange) before normalisation produces variation in result (green)

Page 30: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

VIEW DEPENDENCE OFF

Page 31: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

VIEW DEPENDENCE ON

Page 32: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

CONTENTS

• Sparkle shape

• Expanding distance range

• Noise distortion

• Anisotropy

Page 33: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

NOISE DISTORTION

• Grid look ups jittered by a 3D noise function

• Strong compression/expansion of the sparkle shapes

• Looks unattractive and makes aliasing difficult to deal with

Page 34: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

NOISE DISTORTION

• Jitter sparkle center only

• Compute nearby sparkle grid point and jitter its position

• No distortion

Page 35: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

WITHOUT NOISE

Page 36: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

APPLY NOISE TO LOOK UPS

Page 37: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

APPLY NOISE TO SPARKLE CENTER ONLY

Page 38: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

CONTENTS

• Sparkle shape

• Expanding distance range

• Noise distortion

• Anisotropy

Page 39: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

ANISOTROPY

• Before After

V V

M

Page 40: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

ANISOTROPY - BEFORE

Page 41: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

ANISOTROPY - AFTER

Page 42: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

RESULT

Page 43: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

CONCLUSIONS

• We provide a number of practical improvements to the grid based sparkle algorithm

• Boosted flexibility and robustness

• Could push sparkle size down

• The effect was independent of lighting conditions

Page 44: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

CONCLUSIONS

• Important to ensure shading signal is appropriate for the sampling

• Our additions provide direct and explicit control over the sparkle size and shape

Page 45: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

REFERENCES

• 2012 Shopf, J., Gettin' Procedural, http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2012/10/Shopf-Procedural.pdf

Page 46: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

ACKNOWLEDGEMENTS

• Shadertoy + community for knowledge & inspiration

• The amazing team that worked on the game that we cannot name

• For the conversations and support – Tom Williams, Jim Callin, Kenneth Mitchell

• Natalya Tatarchuk for this course!

SIGGRAPH 2015 Advances in Real-Time Rendering in Games

Page 47: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

THANKS!

• Questions?

• Please let us know what you think!

– Huw Bowles [email protected]

Shadertoy: huwb

– Beibei Wang [email protected]

Page 48: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

ADDITIONAL SLIDES

Page 49: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

SHADER CODE

• See slide notes

Page 50: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

ANISOTROPY

• Project the view vector V onto the surface to get a new vector M which will be the major axis of the elliptical sparkle shape

• M = V – dot(V,N)*N

N

V

M

Page 51: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

ANISOTROPY

• Before After

• Let X denote lookup offset from sparkle center

• Project X onto major axis: X_M = dot(X,M)*M

• Shift X along this axis: X -= (1.0 - abs(dot(V,N))) * X_M

N

V

M

N

V

M

Page 52: Sparkly but not too sparkly! - Inria BUT NOT TOO SPARKLY! Anti-aliasing a procedural sparkle effect Huw Bowles Beibei Wang SIGGRAPH 2015 Advances in Real-Time Rendering in Games

- - - - - - - - - - - - - - + - - - - - - - - - - - - - -

FAST FLOOR LOG2

• An obscure result thrown in for fun

• For our grid scale levels computation, the level index was given by – floor(log(depth))

• For base 2, this is exactly the exponent stored in a IEEE float, which can be unpacked as follows, assuming inp is positive: float fastfloorlog2( float inp ) { return (floatBitsToInt( inp ) >> 23) - 127.0; }