the making of ruby: the double cross - amddeveloper.amd.com/wordpress/media/.../makingofruby... ·...

72
The Making of Ruby: The Double Cross David Gosselin ATI Programming Lead

Upload: others

Post on 07-Jun-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

The Making of Ruby: The Double Cross

David GosselinATI Programming Lead

Page 2: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

2The Making of Ruby: The Double Cross

Outline

• Ruby Demo• Goals• Planning• Making of from Rhino FX’s perspective• ATI Art Notes • Shaders

– Depth of Field– Hair– Skin– Gem– ATI Logo

Page 3: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

3The Making of Ruby: The Double Cross

Ruby Demo

Page 4: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

4The Making of Ruby: The Double Cross

Demo Goals

• Showcase the Radeon X800

• Focus on Game Developers

• Focus on Game Players

Page 5: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

5The Making of Ruby: The Double Cross

Showcase the RADEON X800

• Over twice the performance of 9800XT– More Shaders

– More image space/full screen effects

– More off-screen effects

• Long shaders up to 512 instructions– More complex shaders

– Fewer passes

– Less shader rework

• Normal Map Compression (3DC)– Bigger/more Normal maps

Page 6: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

6The Making of Ruby: The Double Cross

Focus on Game Developers

• Better Characters– Skin– Hair– Motion Capture

• More Photo-Realism– Depth of Field– Glows and Light Blooms

Page 7: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

7The Making of Ruby: The Double Cross

Focus on Game Players

• Look like a next generation game …not a tech demo

• Establish an emotional connection with the audience

• Realistic Characters

• Entertaining

Page 8: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

8The Making of Ruby: The Double Cross

Planning: Limits we gave Rhino

• Polygon Budget– Ruby : 75,000– Optico: 50,000– Ninja: 25,000– Environment: 100,000– Props: 50,000

• Lighting Limits– 3 Dynamic lights

per shot (1 shadow casting)– Lightmaps used for set

Page 9: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

9The Making of Ruby: The Double Cross

More limits

• Animation Limits– 35 total blend shapes– 5 simultaneous blend shapes– 4 weighted bones per vertex– Number of on-screen characters limited to 4 at

once

Page 10: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

10The Making of Ruby: The Double Cross

Making of from Rhino’s Perspective

Page 11: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

11The Making of Ruby: The Double Cross

ATI Art Notes

Page 12: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

12The Making of Ruby: The Double Cross

Shaders

• Depth of Field• Hair• Skin• Gem• ATI Logo

Page 13: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

13The Making of Ruby: The Double Cross

Depth of Field

• Fundamental aspect of photorealistic rendering

– all photos contain some depth of field

• An important part of the creative and storytelling process

– allows the viewers eye’s to be directed to an area of the scene

Page 14: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

14The Making of Ruby: The Double Cross

What is Depth of Field?• Computer Graphics

traditionally uses the pinhole camera model

– This results in perfectly sharp images

• Real Cameras use lenses with variable aperture sizes

– This causes depth-of-field– Out-of-focus objects appear

blurry

pinholelens

thinlens

circle of confusion

Page 15: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

15The Making of Ruby: The Double Cross

Depth Of Field

Page 16: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

16The Making of Ruby: The Double Cross

Depth Of Field

Page 17: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

17The Making of Ruby: The Double Cross

Depth of Field: Implementation

• Render normalized camera depth into destination alpha

• Compute a down-sampled pre-blurred image

• Create composite image– Compute “blurriness” from destination alpha– Use blurriness to compute kernel size– LERP between sharp image and pre-blurred

image at each sample based on blurriness– Fade samples based on relative blurriness

to prevent “leaking”

Page 18: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

18The Making of Ruby: The Double Cross

Populating Destination Alpha• The post-processing shader needs blurriness

and relative depth of each pixel • We pass the camera distance of three planes to

scene shaders:– Focal plane: Points on this plane are in focus– Near plane: Everything closer than this is fully

blurred– Far plane: Everything beyond the far plane is fully

blurred• Each object’s pixel shader renders depth and

blurriness information into destination alpha

Page 19: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

19The Making of Ruby: The Double Cross

Destination Alpha Example

3m focal plane 6m focal plane 12m focal plane

This is where the focal plane intersects with the floor

Page 20: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

20The Making of Ruby: The Double Cross

Pre-blurring the Image

In-Focus image

1/16th Size(box filter)

3×3 Gaussian

Blur

MSAA image from back buffer(Destination alpha contains blurriness)

Pre-Blurred Image

Page 21: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

21The Making of Ruby: The Double Cross

Mapping Depth to Blurriness

• Map a point’s camera depth to [-1, 1] range as shown in pink graph

– This gives us relative depth• Scale and bias relative depth into [0, 1] range

before writing to destination alpha– Saves us from writing blurriness and depth into two

separate channels• To get blurriness, just take the absolute value

+1

rel. depth0

abs(rel. depth)

-1

NearPlane

FocalPlane

FarPlane

Page 22: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

22The Making of Ruby: The Double Cross

Circle Of Confusion Filter Kernel

Center Sample

Outer Samples

• Stochastic sampling• Poisson distribution • Samples stored as

2D offsets from center

Small Blur

Large Blur

Page 23: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

23The Making of Ruby: The Double Cross

Filter Kernel For Circle Of Confusion

• Vary kernel size based on the “blurriness”

• Sample all taps from original and pre-blurred image

– Blend between them based on tap blurriness

Point in focus Point is blurred

Page 24: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

24The Making of Ruby: The Double Cross

Reduction Of “Leaking”

• Conventional post-processing blur techniques cause “leaking” of sharp foreground objects onto blurry backgrounds

• Depth compare the samples and discard ones that can contribute to background “leaking”

– Test each sample against center sample– If sample is “sharper” then weight sample by

it’s blurriness

Page 25: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

25The Making of Ruby: The Double Cross

Leaking Example

Background LeakingBackground Leaking With Leak PreventionWith Leak Prevention

Page 26: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

26The Making of Ruby: The Double Cross

Depth of Field Demo

Page 27: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

27The Making of Ruby: The Double Cross

DOF Wrap Up

• Allowed more creative control

• Focused viewers attention

• More photo-realistic

• Blend multiple samples from sharp and pre-blurred image

Page 28: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

28The Making of Ruby: The Double Cross

Hair Rendering• Realistic hair is a key part of creating believable

characters• Hair Rendering is hard

– There is a lot of it – around 150K strands on a human head

– Many Different Hair Styles– Hair reacts to light in a complex manner– Hair is semi-transparent

• ~25% of the total render time of “Final Fantasy -The Spirits Within” was spent on the main character’s hair

Page 29: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

29The Making of Ruby: The Double Cross

Real-Time Hair Rendering

• Our approach also use the Kajiya-Kay shader model.

• Along with some observations derived from Marshner (Siggraph 2003):

– Colored hair has 2 highlights– Primary (specular) shifted towards hair tip.– Secondary (colored) shifted towards hair root.– Secondary highlight also sparkles

• Ambient Occlusion is used for self-shadowing

Page 30: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

30The Making of Ruby: The Double Cross

Hair Model Authoring

• Several layers of patches to approximate volumetric qualities of hair

• Ambient occlusion to approximate self-shadowing

– Per vertex• Why Polygons

– Lower geometric complexity than line rendering

– Makes depth sorting faster– Integrates well into our art

pipeline

Page 31: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

31The Making of Ruby: The Double Cross

Hair Lighting: Kajiya-Kay Model

• Anisotropic strand lighting model

• Use hair strand tangent (T) instead of normal (N) in lighting equations

• Assumes hair normal to lie in plane spanned by T and view vector (V)

T

N

V

L

H

Page 32: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

32The Making of Ruby: The Double Cross

Hair Lighting: Marschner Model• Based on measurements of hair

scattering properties• Observations

– Primary specular highlight shifted towards hair tip

– Secondary specular highlight• colored• shifted towards hair root

– Sparkling appearance of secondary highlight

• Math is complex, we’re just trying to match these observations pheno-menologically

Page 33: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

33The Making of Ruby: The Double Cross

Shifting Specular Highlights

• To shift the specular highlight along the length of the hair, we nudge the tangent along the direction of the normal

• Assuming T is pointing from root to tip:

– Positive nudge moves highlight towards root

– Negative nudge moves highlight towards tip

• We also add a noise component to avoid too much uniformity

N

T T’T”

Page 34: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

34The Making of Ruby: The Double Cross

Ambient Occlusion Diffuse Term

Specular Term Combined

Page 35: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

35The Making of Ruby: The Double Cross

Approximate Depth Sorting

• Need to draw in back-to-front order for correct alpha-blending

• For a head with hair this is very similar to inside to outside

• Use static index buffer with inside to outside draw order, computed at preprocess time

– Sort connected components(hair strand patches) insteadof individual triangles

Page 36: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

36The Making of Ruby: The Double Cross

Hair Demo

Page 37: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

37The Making of Ruby: The Double Cross

Hair Wrap Up

• Polygonal Model for ease of integration

• Kajia-Kay lighting plus Marshnerobservations

• Worked for our constraints

• Check out “Practical Real-Time Hair Rendering and Shading” Thursday in GPU2 sketch session

Page 38: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

38The Making of Ruby: The Double Cross

Skin Rendering

• Skin Rendering is hard– Most lighting comes from sub-surface

scattering– Pigment color mainly from epidermis– Pink/red color mainly from blood in dermis

• Traditional Lambertian lighting model is designed for ‘hard’ surfaces with no sub-surface scattering

– so it doesn’t work well for skin

Page 39: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

39The Making of Ruby: The Double Cross

Skin Cross Section

Air

Epidermis

Dermis

Bone, muscle, etc.

Page 40: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

40The Making of Ruby: The Double Cross

Texture Space Subsurface Scattering

From Matrix: Reloaded sketch

• From Realistic Human Face Rendering for “The Matrix Reloaded” @ SIGGRAPH 2003:

• Our results:

Current skin in Real Time

Page 41: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

41The Making of Ruby: The Double Cross

Basis for Our Approach• SIGGRAPH 2003 sketch Realistic Human Face

Rendering for “The Matrix Reloaded” by George Borshukov and J. P. Lewis

• Rendered a 2D light map

• Simulate subsurface diffusion in image domain (different for each color component)

• Used traditional ray tracing for areas where light can pass all the way through (e.g. ears)

• Also capture fine detail normal maps and albedomaps

Page 42: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

42The Making of Ruby: The Double Cross

Texture Space Lighting for Real Time

• Render diffuse lighting into an off-screen texture using texture coordinates as position

• Blur the off-screen diffuse lighting• Read the texture back and add specular

lighting in subsequent pass• We only used bump map for the specular

lighting pass

Page 43: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

43The Making of Ruby: The Double Cross

Basic Approach

Light in Texture Space Blur

Geometry

Sample texture space light

Back Buffer

Page 44: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

44The Making of Ruby: The Double Cross

Texture Coordinates as Position

• Need to light as a 3D model but draw into texture

• By passing texture coordinates as “position” the rasterizer does the unwrap

• Compute light vectors based on 3D position and interpolate

Page 45: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

45The Making of Ruby: The Double Cross

Standard Lighting Model

Page 46: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

46The Making of Ruby: The Double Cross

Texture Space Lighting Model

Page 47: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

47The Making of Ruby: The Double Cross

Spatially Varying Blur

• Used to simulate the subsurface component of skin lighting

• Used a grow-able Poisson disc filter

• Read the kernel size from a texture

• Allows varying the subsurface effect– Higher for places like ears/nose– Lower for places like cheeks

Page 48: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

48The Making of Ruby: The Double Cross

Shadows

• Used shadow maps– Apply shadows during texture lighting– Get “free” blur

• Soft shadows• Simulates subsurface interaction• Lower precision/size requirements• Reduces artifacts

• Only doing shadows from one key light

Page 49: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

49The Making of Ruby: The Double Cross

Shadow Maps

• Create projection matrix to generate map from the light’s point of view

• Used bounding sphere of head to ensure texture space is used efficiently

• Write depth from light into off-screen texture

• Test depth values in pixel shader

Page 50: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

50The Making of Ruby: The Double Cross

Specular• Use bump map for specular lighting

• Per-pixel exponent

• Need to shadow specular– Hard to blur shadow map directly– Expensive to do yet another blur pass for shadows– Modulate specular from shadowing light by luminance of

texture space light– Darkens specular in shadowed areas but preserves

lighting in unshadowed areas

• Shadow only dims one light (2 other un-shadowed)

Page 51: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

51The Making of Ruby: The Double Cross

Skin Rendering Demo

Page 52: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

52The Making of Ruby: The Double Cross

Skin Wrap Up

• Texture based lighting gives the Illusion of sub-surface scattering

• Practical on today’s hardware

• Check out “Real-Time Skin Rendering on Graphics Hardware” in Thursday’s GPU2 Sketch session

Page 53: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

53The Making of Ruby: The Double Cross

Rendering A Diamond

• Diamonds in the real-world have complex lighting

– Reflection – internal & external– Refraction – multiple bounces– Color Shifts– Bright Highlights

Page 54: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

54The Making of Ruby: The Double Cross

Rendering A Diamond

• Reflection can be simulated effectively with cubemaps.

• Refraction is a bit harder– A single bounce can be calculated

correctly– Multiple bounces require raytracing– not feasible on current hardware in real-

time– So we fake it

Page 55: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

55The Making of Ruby: The Double Cross

Basic Algorithm

• Draw back face refractions to the back buffer

• Additively blend on top of back face refractions:

– Front Face Refractions– Front Face Reflections

(Environment Cube Map)– Front Face Specular Lighting

• Draw sparkles based on Illumination

Page 56: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

56The Making of Ruby: The Double Cross

Faking Refractions

• Look up into a refraction cubemap• Use multiple refraction vectors

– Straight up refraction vector– Refraction with different IR, then reflected by

a vector random to each face• To prevent sampling close to first refraction ray

• Use multiple normals (lerp between smooth and face for more variation)

• Can also add an “edge” map to give even more hard edges (more visual complexity)

Page 57: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

57The Making of Ruby: The Double Cross

Creating a Refraction Cubemap

• Rendered with Maya

• Camera inside of gem looking out

• Lighting environment approximated by an environment map

Page 58: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

58The Making of Ruby: The Double Cross

RefractionsInto Back Buffer

+( ) * =Back Face Refractions Edge

+( ) * =Front Face Refractions Edge

+Additive Blend With Back Buffer

Page 59: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

59The Making of Ruby: The Double Cross

Combined Refractions

Page 60: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

60The Making of Ruby: The Double Cross

Reflections• Reflection cube map lookup• To fake dispersion:

– “Rainbow” cubemap lookup– Modulate rainbow sample with reflection

sample• Lerp between modulated and original

reflection sample to control dispersion strength

• Modulate with Fresnel term• Add specular highlights

Page 61: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

61The Making of Ruby: The Double Cross

Cube Maps

Blurred Environment Map Rainbow Map

Page 62: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

62The Making of Ruby: The Double Cross

Environment Lighting

* =

LERP( , ,0.5) =

* =

Environment Map Rainbow Map

Fresnel Term

Page 63: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

63The Making of Ruby: The Double Cross

Final Look

Environment Lighting

+Refractions Specular Lighting

Page 64: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

64The Making of Ruby: The Double Cross

Sparkles

• Placed at strategic points on geometry• Sparkles move rigidly with gem• Expanded based on their texture coords

– Screen-aligned• Faded in based on an off-screen texture

luminance at center of sparkle• Modulate with a noise value to make

them flicker a little bit

Page 65: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

65The Making of Ruby: The Double Cross

Flares Positioned

• Only center matters• “Cloud” works well• No need to reside only on

faces, inside gem works too

Flare Geometry

Single Flare

Page 66: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

66The Making of Ruby: The Double Cross

Conceptual Flare Process

Off-screen bufferFlare Geometry

For each flare– Look up luminance of its center in off-screen– If luminance is > threshold

• Draw (in reality don’t kill)

Page 67: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

67The Making of Ruby: The Double Cross

Demo

Page 68: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

68The Making of Ruby: The Double Cross

Gem Wrap Up

• Used multiple cube-map lookups to simulate refractions

• Used various maps to add visual complexity

• Flares based on off-screen buffer

• In the end it’s the look that counts

Page 69: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

69The Making of Ruby: The Double Cross

ATI Logo

• Procedurally generated– Less texture memory– “infinite” resolution

• Store lines/points as shader constants– Position– Vector to endpoint– Vector to endpoint / length^2

• Test inside/outside to color red/white

Page 70: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

70The Making of Ruby: The Double Cross

ATI Logo Segments

• Test point against each line(ellipse)/point– Using DOT/Saturate and a few arithmetic

instructions• Use min to determine if it should be red/white• Use smoothstep to AA the result

Page 71: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

71The Making of Ruby: The Double Cross

Ruby Demo

Page 72: The Making of Ruby: The Double Cross - AMDdeveloper.amd.com/wordpress/media/.../MakingOfRuby... · The Making of Ruby: The Double Cross 28 Hair Rendering • Realistic hair is a key

72The Making of Ruby: The Double Cross

ATILead Programmer

David GosselinLead ArtistEli Turner

Programming / Shader ProgrammingAlex Vlachos

Christopher OatJason L. Mitchell

Natasha TatarchukPedro Sander

Thorsten ScheuermannAdditional Engine Programming

Chris BrennanJohn IsidoroProduction

Callan McInallyStephen Smith

RhinoFxDirector: Harry Dorrington

Senior Executive Producer/Partner: Rick WaggonheimSenior Executive Producer: Camille Geier

Senior Producer: Karen BiancaStory & Concepts: Harry Dorrington & David Zung

Storyboarding / Visualization: David Zung & Ji YoonLead Animator: Jeff Guerrero

Technical Consultant & Animation: David BarosinAnimator/Modeler: Dan Vislocky

Lead Lighter & Project Lead: Joe Burrascano

Texture Artist / Lighter: Chimin YangTexture Artist / Lighter: Ido Kalir

Lighter: Natalia SenkoShader / Texture Artist: Dylan Maxwell

Texture Artist: Martin BoksarModeler: Paul Liaw

Modeler: John VelazquezModeler: Shin Kull

3D Artist: Michael WareShader / Texture Artist: Dylan Maxwell

Technical Animation / Dynamics: Ji YoonTechnical Director: Jesse ClemensCompositor/Graphics: Guy AtzmanEditor/Compositor: Marc Steinberg

Software Development: Jim CallahanSystems Engineer: Paul Tsung

Photoshop Artists / Graphics: Chris GreenMo Cap Production Manager: Kristen Ames

Motion Capture Company: Perspective StudiosMotion Capture Stunt Actor: Declan Mulvey

Motion Capture Stunt Actor: Andre “Chyna” McCoyMotion Capture Stunt Actor: Casey Eastlick

Fight Coordinator: Declan MulveyCasting – Voice and Stunt: Wendy Litwack Casting

Voice Talent: Marlyne AfflackVoice Talent: Chris Phillips

Music House: Amber Music New York / LAMusic Producer: Kate Gibson

Music: Will RichterMusic Sound Design: Bill Chesley

Voice Record / Mix: Tonic New YorkSound Engineer: Jody Nazarro