Dynamic lighting in GOW3

Preview:

Citation preview

A LIGHTING METHOD

FOR CONSOLE GAMES

Resource: Dynamic lighting in GOW3

Vassily Filippov (Sony Santa Monica)

Advances in Real-Time Rendering in 3D Graphics

and Games, SIGGRAPH 2011

INTRODUCTION

Three major issues for console games

Modeling

Lighting

Animation

PS3‟s graphics processing is handled by the

NVIDIA RSX 'Reality Synthesizer„

RSX

Nvidia GeForce 7800 Architecture

256 MB GDDR3 RAM at 700 MHz

RSX is a bottleneck

Mesh Color

Today‟s emphasis

TRADITIONAL METHOD

)0(

)(

iLNi

iilLN

iL

il

: Light direction

: Luminance

Light

Light

Light

Light

THIS METHOD

AggAgglLN )(

AggL

Aggl

: Aggregate Light direction

: Aggregate Luminance

Light

HYBRID VERTEX LIGHTS

For 1 light identical to pixel lights

For multiple lights

Calculate distance falloff per vertex.

Combine into a single Aggregate Light per-

vertex

Interpolate Aggregate Light Position per pixel

INTERPOLATING DIRECTION

Light

INTERPOLATING DIRECTION

A B

Light

L=(½LA+½L

B)

INTERPOLATING DIRECTION

A L=normalize(½LA+½L

B) B

WRONG

INTERPOLATING POSITION

A B

Light

INTERPOLATING POSITION

AL = Light_Pos−(½A+½B)

B

Light

INTERPOLATING POSITION

A

Normalize(Light_Pos−(½A+½B))

B

Light

BETTER

BUT STILL NOT SO GOOD

Light with falloff in real world, but light weights

will both set to 1 here

Resulting lighting will over-emphasize Light 1

Light 0

Vertex V

Light 1

Aggregate

light

Ideal

aggregate

light

“BETTER” APPROACH

Step1 - Subtract the world vertex position from each world

light position to create relative vectors

Step2 - Calculate lengths

And weights(light intensities are 1 for both

lights)

Light 0

Vertex V

L0

L1

Light 1

W0 = 1/L0

W1 = 1/L1

“BETTER” APPROACH

Step3 - multiply relative vectors by weights to go

to direction domain

Step4 - Add up light directions

Light 0

Vertex V

Light 1

W0 = 1/L0

W1 = 1/L1

“BETTER” APPROACH

Step5 - Accumulate weights

Step6 - Multiply aggregate direction by

accumulated weight to go back to positions

domain

We ended up with relative light vector for

aggregate light

Light 0

Vertex V

Light 1

W0 = 1/L0

W1 = 1/L1

+Wtotal

“BETTER” APPROACH

Step7 - Add vertex world position to it to get

world position of the aggregate light

Light 0

Vertex V

Light 1

“BETTER” APPROACH

Lagg is aggregate light position

Li is light position for Light i

Wi is light weight for Light i based on intensity of Light i at V

n is number of lights in the current light context

V is position of the vertex for which we combine lights

V

VL

W

VL

VLW

L

ni i

i

ni i

ii

agg

]..0[

]..0[

)( Light 0

Vertex V

“BETTER” APPROACH

Lagg is aggregate light position

Li is light position for Light i

Wi is light weight for Light i based on intensity of Light i at V

n is number of lights in the current light context

V is position of the vertex for which we combine lights

V

VL

W

VL

VLW

L

ni i

i

ni i

ii

agg

]..0[

]..0[

)(Light 0

Vertex V

“BETTER” APPROACH

Lagg is aggregate light position

Li is light position for Light i

Wi is light weight for Light i based on intensity of Light i at V

n is number of lights in the current light context

V is position of the vertex for which we combine lights

V

VL

W

VL

VLW

L

ni i

i

ni i

ii

agg

]..0[

]..0[

)( Light 0

Vertex V

“BETTER” APPROACH

Lagg is aggregate light position

Li is light position for Light i

Wi is light weight for Light i based on intensity of Light i at V

n is number of lights in the current light context

V is position of the vertex for which we combine lights

V

VL

W

VL

VLW

L

ni i

i

ni i

ii

agg

]..0[

]..0[

)( Light 0

Vertex V

“BETTER” APPROACH

Lagg is aggregate light position

Li is light position for Light i

Wi is light weight for Light i based on intensity of Light i at V

n is number of lights in the current light context

V is position of the vertex for which we combine lights

V

VL

W

VL

VLW

L

ni i

i

ni i

ii

agg

]..0[

]..0[

)( Light 0

Vertex V

“BETTER” APPROACH

Lagg is aggregate light position

Li is light position for Light i

Wi is light weight for Light i based on intensity of Light i at V

n is number of lights in the current light context

V is position of the vertex for which we combine lights

V

VL

W

VL

VLW

L

ni i

i

ni i

ii

agg

]..0[

]..0[

)(Light 0

Vertex V

AGGREGATE LIGHT COLOR

Calculate aggregate light

position

Calculate normalized

light directions

Calculate dot products

x + x =

AGGREGATE LIGHT COLOR

Cagg is aggregate light color at the

Vertex V

Ci is color of Light i

Li is direction to Light i at Vertex

V

Lagg is direction to aggregate light

))((

]..0[ ni

aggiiaggLLCC

AGGREGATE LIGHT COLOR

Cagg is aggregate light color at the

Vertex V

Ci is color of Light i

Li is direction to Light i at Vertex

V

Lagg is direction to aggregate light

))((

]..0[ ni

aggiiaggLLCC

x + x =

How well does this approximate actual lighting

by several lights?

WHY THIS WORKS

This is what is tried to approximate

Assume lights have a single scalar luminance

value and no color.

)0(

)(iLNi

ii cLN

)0(

)(iLNi

ii lLN

WHY THIS WORKS

Aggregate light approximation (with luminances)

AggAgg

LNi

iilLNlLN

i

)()(

)0(

Exact luminance calculation

Our approximation

WHY THIS WORKS

)0(

)(iLNi

ii lLN

)( ii

LlN

X

XLl ii

WHY THIS WORKS

V

VLpos

W

VLpos

VLposW

Lpos

ni i

i

ni i

ii

agg

]..0[

]..0[

)(

Light 0

Vertex V

il

WHY THIS WORKS

V

VLpos

l

VLpos

VLposl

Lpos

ni i

i

ni i

ii

agg

]..0[

]..0[

)(

Light 0

Vertex V

aggLrel

WHY THIS WORKS

]..0[

]..0[

)(

ni i

i

ni i

ii

agg

VLpos

l

VLpos

VLposl

Lrel

Light 0

Vertex V

Lagg

aggL]..0[

)(

ni i

ii

VLpos

VLposl

WHY THIS WORKS

]..0[

]..0[

)(

)(

ni i

ii

ni i

ii

agg

VLpos

VLposl

VLpos

VLposl

L

Light 0

Vertex V

Lagg

iL

WHY THIS WORKS

]..0[

]..0[

ni

ii

ni

ii

agg

Ll

Ll

L

Light 0

Vertex V

Lagg

X

WHY THIS WORKS

X

XLagg

Xlagg

AggAgg

LNi

iilLNlLN

i

)()(

)0(

XLl ii

VECTOR ARITHMETIC

V0

V1

V2

Adding multiple vectors

Length of the result

is equal to the sum of projections

WHY THIS WORKS – THE LAST STEP

XlAgg

WHY THIS WORKS – THE LAST STEP

ni

iiAgg LlXl

WHY THIS WORKS – THE LAST STEP

ni

nj

jj

nj

jj

ii

ni

iiAgg

Ll

Ll

LlLlXl

LAgg

WHY THIS WORKS – THE LAST STEP

i

AggiiAgg LLll )(

For luminance our approximation is exact

)( AggiiAgg LLCC

Which is what this method use

Extending to RGB:

RESULT

God Of War III Runs Natively At 720p With 1080p Upscaling, and

stable 60fps most of the time

Recommended