ݺߣ

ݺߣShare a Scribd company logo
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            Mesh Color
    ? Lighting            Today?s emphasis
    ? 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
TRADITIONAL METHOD
                                   ?     ?
                                  (N     Li )li
                              ? ?
                          i ( N Li 0 )
 ?
 Li   : Light direction


 li   : Luminance

                                Light

                                                  Light
                 Light

                                                          Light
THIS METHOD
                          ?       ?
                         (N       L Agg ) l Agg
?
L Agg   : Aggregate Light direction

l Agg   : 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



                               Light


    A        L=(?LA+?LB)   B
INTERPOLATING DIRECTION


        WRONG

    A      L=normalize(?LA+?LB)   B
INTERPOLATING POSITION



                             Light


    A                    B
INTERPOLATING POSITION



                                    Light


    A                           B
        L = Light_Pos?(?A+?B)
INTERPOLATING POSITION


          BETTER
                                           Light


    A                                  B
        Normalize(Light_Pos?(?A+?B))
BUT STILL NOT SO GOOD


                     Ideal       Aggregate
                     aggregate   light
                        light                    Light 1
     Light 0




          Vertex V



?   Light with falloff in real world, but light weights
    will both set to 1 here

?   Resulting lighting will over-emphasize Light 1
BETTER APPROACH

                                                         Light 1
      Light 0       W0 = 1/L0
          L0
                                  L1        W1 = 1/L1
         Vertex V




?  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)
BETTER APPROACH

                                                Light 1
    Light 0       W0 = 1/L0


                                    W1 = 1/L1
       Vertex V




? Step3 - multiply relative vectors by weights to go
  to direction domain
? Step4 - Add up light directions
BETTER APPROACH
                                                  Light 1
    Light 0


                                  W0 = 1/L0

       Vertex V       Wtotal      +
                                      W1 = 1/L1



? 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
BETTER APPROACH

                                                     Light 1
      Light 0




         Vertex V




?   Step7 - Add vertex world position to it to get
    world position of the aggregate light
BETTER APPROACH

                                                                       Light 0
                                                ( Li V )
                                             Wi
                               i   [ 0.. n ]      Li V
                 Lagg                                             V
                                                  Wi                      Vertex V
                                    i [ 0.. n ] Li   V
   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
BETTER APPROACH

                                                ( Li V )               Light 0
                                             Wi
                               i   [ 0.. n ]      Li V
                 Lagg                                             V
                                                  Wi
                                                                          Vertex V
                                    i [ 0.. n ] Li   V
   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
BETTER APPROACH

                                                ( Li V )               Light 0
                                             Wi
                               i   [ 0.. n ]      Li V
                 Lagg                                             V
                                                  Wi
                                                                          Vertex V
                                    i [ 0.. n ] Li   V
   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
BETTER APPROACH

                                                ( Li V )               Light 0
                                             Wi
                               i   [ 0.. n ]      Li V
                 Lagg                                             V
                                                  Wi
                                                                          Vertex V
                                    i [ 0.. n ] Li   V
   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
BETTER APPROACH

                                                ( Li V )               Light 0
                                             Wi
                               i   [ 0.. n ]      Li V
                 Lagg                                             V
                                                  Wi
                                                                          Vertex V
                                    i [ 0.. n ] Li   V
   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
BETTER APPROACH

                                                ( Li V )               Light 0
                                             Wi
                               i   [ 0.. n ]      Li V
                 Lagg                                             V
                                                  Wi
                                                                          Vertex V
                                    i [ 0.. n ] Li   V
   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
AGGREGATE LIGHT COLOR
? Calculate aggregate light
  position
? Calculate normalized
  light directions
? Calculate dot products




      x     +          x      =
AGGREGATE LIGHT COLOR
                                      ?     ?
       C agg                  Ci   (( L i   L agg ))
                    i [ 0 .. n ]

  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
AGGREGATE LIGHT COLOR
                                         ?     ?
          C agg                  Ci   (( L i   L agg ))
                       i [ 0 .. n ]

     Cagg is aggregate light color at the
     Vertex V
     Ci is color of Light i                         x     +   x   =
     Li is direction to Light i at Vertex
     V
     Lagg is direction to aggregate light



How well does this approximate actual lighting
by several lights?
WHY THIS WORKS
?   This is what is tried to approximate
                      ?    ?
              ? ?
                     (N    Li )ci
          i ( N Li 0 )


?   Assume lights have a single scalar luminance
    value and no color.
                      ?     ?
              ? ?
                     (N     Li )li
          i ( N Li   0)
WHY THIS WORKS
 Aggregate light approximation (with luminances)

                ?   ?          ?   ?
               (N   Li ) li   (N   L Agg ) l Agg
        ? ?
    i ( N Li   0)



                                    Our approximation

Exact luminance calculation
WHY THIS WORKS

               ?   ?            ?         ?
       ? ?
              (N   Li )li       N (   l i Li )
   i ( N Li   0)


                                          ?
                                          X
                           ?      ?
                       l i Li     X
WHY THIS WORKS


                                                 Light 0

                               ( Lposi V )
                          Wi
            i [ 0.. n ]          Lposi V
  Lposagg                                    V      Vertex V
                                  Wi
               i [ 0.. n ]     Lposi V

  li
WHY THIS WORKS

                                                   Light 0

                                 ( Lposi V )
                            li
              i [ 0.. n ]          Lposi V
    Lposagg                                    V      Vertex V
                                     li
                i [ 0.. n ]      Lposi V


      Lrelagg
WHY THIS WORKS

                                                               Light 0

                                 ( Lposi V )
                            li
              i [ 0.. n ]          Lposi V                                    Lagg
    Lrelagg                                                        Vertex V
                                     li
                i [ 0.. n ]      Lposi V



 Lagg                                          li
                                                    ( Lposi   V)
                                 i [ 0.. n ]          Lposi   V
WHY THIS WORKS


                                            Light 0

                             ( Lposi   V)
                        li
          i [ 0.. n ]          Lposi   V                  Lagg
   Lagg                                        Vertex V
                             ( Lposi   V)
                        li
          i [ 0.. n ]          Lposi   V

                                            Li
WHY THIS WORKS


                                      Light 0
                          li Li
                 i [ 0.. n ]
       Lagg                                         Lagg
                                         Vertex V

                          li Li
                 i [ 0.. n ]

                                  ?
                                  X
WHY THIS WORKS
                           ?   ?          ?   ?
        ?          ? ?
                          (N   Li ) li   (N   L Agg ) l Agg
        X      i ( N Li   0)
Lagg    ?                           ?     ?
        X                       l i Li    X



                          ?
            lagg          X
VECTOR ARITHMETIC
                     Adding multiple vectors

                     Length of the result
                      is equal to the sum of projections
      V2




                V1


           V0
WHY THIS WORKS C THE LAST STEP




        ?
l Agg   X
WHY THIS WORKS C THE LAST STEP




         ?              ?
 l Agg   X           li Li
             i   n
WHY THIS WORKS C THE LAST STEP



                                                           ?
                                                       l j Lj
          ?              ?                    ?    j   n
  l Agg   X           li Li              li   Li
              i   n              i   n                     ?
                                                       l j Lj
                                                   j   n




                              LAgg
WHY THIS WORKS C THE LAST STEP
                              ?    ?
             l Agg       li ( Li   LAgg )
                     i
      For luminance our approximation is exact

Extending to RGB:
                              ?     ?
            C Agg        Ci ( Li    LAgg )
                     Which is what this method use
RESULT




God Of War III Runs Natively At 720p With 1080p Upscaling, and
stable 60fps most of the time

More Related Content

Dynamic lighting in GOW3

  • 1. 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
  • 2. INTRODUCTION ? Three major issues for console games ? Modeling Mesh Color ? Lighting Today?s emphasis ? 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
  • 3. TRADITIONAL METHOD ? ? (N Li )li ? ? i ( N Li 0 ) ? Li : Light direction li : Luminance Light Light Light Light
  • 4. THIS METHOD ? ? (N L Agg ) l Agg ? L Agg : Aggregate Light direction l Agg : Aggregate Luminance Light
  • 5. 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
  • 7. INTERPOLATING DIRECTION Light A L=(?LA+?LB) B
  • 8. INTERPOLATING DIRECTION WRONG A L=normalize(?LA+?LB) B
  • 10. INTERPOLATING POSITION Light A B L = Light_Pos?(?A+?B)
  • 11. INTERPOLATING POSITION BETTER Light A B Normalize(Light_Pos?(?A+?B))
  • 12. BUT STILL NOT SO GOOD Ideal Aggregate aggregate light light Light 1 Light 0 Vertex V ? Light with falloff in real world, but light weights will both set to 1 here ? Resulting lighting will over-emphasize Light 1
  • 13. BETTER APPROACH Light 1 Light 0 W0 = 1/L0 L0 L1 W1 = 1/L1 Vertex V ? 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)
  • 14. BETTER APPROACH Light 1 Light 0 W0 = 1/L0 W1 = 1/L1 Vertex V ? Step3 - multiply relative vectors by weights to go to direction domain ? Step4 - Add up light directions
  • 15. BETTER APPROACH Light 1 Light 0 W0 = 1/L0 Vertex V Wtotal + W1 = 1/L1 ? 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
  • 16. BETTER APPROACH Light 1 Light 0 Vertex V ? Step7 - Add vertex world position to it to get world position of the aggregate light
  • 17. BETTER APPROACH Light 0 ( Li V ) Wi i [ 0.. n ] Li V Lagg V Wi Vertex V i [ 0.. n ] Li V 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
  • 18. BETTER APPROACH ( Li V ) Light 0 Wi i [ 0.. n ] Li V Lagg V Wi Vertex V i [ 0.. n ] Li V 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
  • 19. BETTER APPROACH ( Li V ) Light 0 Wi i [ 0.. n ] Li V Lagg V Wi Vertex V i [ 0.. n ] Li V 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
  • 20. BETTER APPROACH ( Li V ) Light 0 Wi i [ 0.. n ] Li V Lagg V Wi Vertex V i [ 0.. n ] Li V 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
  • 21. BETTER APPROACH ( Li V ) Light 0 Wi i [ 0.. n ] Li V Lagg V Wi Vertex V i [ 0.. n ] Li V 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
  • 22. BETTER APPROACH ( Li V ) Light 0 Wi i [ 0.. n ] Li V Lagg V Wi Vertex V i [ 0.. n ] Li V 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
  • 23. AGGREGATE LIGHT COLOR ? Calculate aggregate light position ? Calculate normalized light directions ? Calculate dot products x + x =
  • 24. AGGREGATE LIGHT COLOR ? ? C agg Ci (( L i L agg )) i [ 0 .. n ] 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
  • 25. AGGREGATE LIGHT COLOR ? ? C agg Ci (( L i L agg )) i [ 0 .. n ] Cagg is aggregate light color at the Vertex V Ci is color of Light i x + x = Li is direction to Light i at Vertex V Lagg is direction to aggregate light How well does this approximate actual lighting by several lights?
  • 26. WHY THIS WORKS ? This is what is tried to approximate ? ? ? ? (N Li )ci i ( N Li 0 ) ? Assume lights have a single scalar luminance value and no color. ? ? ? ? (N Li )li i ( N Li 0)
  • 27. WHY THIS WORKS Aggregate light approximation (with luminances) ? ? ? ? (N Li ) li (N L Agg ) l Agg ? ? i ( N Li 0) Our approximation Exact luminance calculation
  • 28. WHY THIS WORKS ? ? ? ? ? ? (N Li )li N ( l i Li ) i ( N Li 0) ? X ? ? l i Li X
  • 29. WHY THIS WORKS Light 0 ( Lposi V ) Wi i [ 0.. n ] Lposi V Lposagg V Vertex V Wi i [ 0.. n ] Lposi V li
  • 30. WHY THIS WORKS Light 0 ( Lposi V ) li i [ 0.. n ] Lposi V Lposagg V Vertex V li i [ 0.. n ] Lposi V Lrelagg
  • 31. WHY THIS WORKS Light 0 ( Lposi V ) li i [ 0.. n ] Lposi V Lagg Lrelagg Vertex V li i [ 0.. n ] Lposi V Lagg li ( Lposi V) i [ 0.. n ] Lposi V
  • 32. WHY THIS WORKS Light 0 ( Lposi V) li i [ 0.. n ] Lposi V Lagg Lagg Vertex V ( Lposi V) li i [ 0.. n ] Lposi V Li
  • 33. WHY THIS WORKS Light 0 li Li i [ 0.. n ] Lagg Lagg Vertex V li Li i [ 0.. n ] ? X
  • 34. WHY THIS WORKS ? ? ? ? ? ? ? (N Li ) li (N L Agg ) l Agg X i ( N Li 0) Lagg ? ? ? X l i Li X ? lagg X
  • 35. VECTOR ARITHMETIC Adding multiple vectors Length of the result is equal to the sum of projections V2 V1 V0
  • 36. WHY THIS WORKS C THE LAST STEP ? l Agg X
  • 37. WHY THIS WORKS C THE LAST STEP ? ? l Agg X li Li i n
  • 38. WHY THIS WORKS C THE LAST STEP ? l j Lj ? ? ? j n l Agg X li Li li Li i n i n ? l j Lj j n LAgg
  • 39. WHY THIS WORKS C THE LAST STEP ? ? l Agg li ( Li LAgg ) i For luminance our approximation is exact Extending to RGB: ? ? C Agg Ci ( Li LAgg ) Which is what this method use
  • 40. RESULT God Of War III Runs Natively At 720p With 1080p Upscaling, and stable 60fps most of the time