What is KeyLightOffset and FillLightOffset?

Regina Henschel 151 Reputation points
2022-02-18T13:59:08.843+00:00

The current [MS-OI29500] "Office Implementation Information for ISO/IEC 29500 Standards Support" has got a table in 2.1.1319 Part 1 Section 20.1.10.30, ST_LightRigType (Light Rig Type).

This table has the columns "KeyLightOffset" and "FillLightOffset". What is the meaning of these columns? There exists no corresponding attribute in RichTextFormat or MS Binary Format.

Kind regards,
Regina

Office Open Specifications
Office Open Specifications
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Open Specifications: Technical documents for protocols, computer languages, standards support, and data portability. The goal with Open Specifications is to help developers open new opportunities to interoperate with Windows, SQL, Office, and SharePoint.
126 questions
{count} votes

Accepted answer
  1. Tom Jebo 1,991 Reputation points Microsoft Employee
    2022-02-23T01:53:24.78+00:00

    @Regina Henschel ,

    Here's the revised and expanded explanation from the graphics team:

    It is challenging to explain how all the properties of lights and shapes are combined to calculate final per-pixel colors seen on the screen. The light “scale and offset” values only affect the diffuse color component for a pixel. This pseudo-code shows how the diffuse color is calculated given a point, the surface normal at that point, the shape’s diffuse color at that point, and a collection of lights:

    // IN: p is the surface point, n is the normal vector at that point, surfaceDiffuseColor is the color of the surface at that point.  
    // OUT: diffuse and specular colors are returned  
    Color CalculateGouraudLighting( const Point3D& p, const Vector3D& n, const Color& surfaceDiffuseColor, const LightArray& lights )  
    {  
       // Init RGBA diffuse color  
       Color diff( 0.0f, 0.0f, 0.0f, 1.0f );  
      
       for( int i = 0; i < lights.Count(); i++ )  
       {  
          // Get this light's colors.  
          const IModelLight& light = lights[ i ];  
          Color lightColor = light.GetColor();  
      
          // Get light direction  
          Vector3D lightDir = light.DirectionToPoint( p );  
      
          // Calc diffuse contribution if needed.  
          if( light.AffectsDiffuse() )  
          {  
             // Calc scalar dot product from surface normal and light direction  
             float dot = -( n * lightDir );  
      
             // Apply scale and offset to adjust light attenuation  
             dot = dot * light.GetWrapScale() + light.GetWrapOffset();  
      
             if( dot >= 1.0f )  
             {  
                // Add in full diffuse contribution  
                diff.r += surfaceDiffuseColor.r * lightColor.r;  
                diff.g += surfaceDiffuseColor.g * lightColor.g;  
                diff.b += surfaceDiffuseColor.b * lightColor.b;  
             }  
             else if ( dot > 0.0 )  
             {  
                // Add in diffuse contribution attenuated by the scalar dot product  
                diff.r += dot * surfaceDiffuseColor.r * lightColor.r;  
                diff.g += dot * surfaceDiffuseColor.g * lightColor.g;  
                diff.b += dot * surfaceDiffuseColor.b * lightColor.b;  
             }  
          }  // end of diffuse calculation  
       }  // end of loop over each light  
      
       return diff;  
    }  
    

    Here is where the scale and offset of individual key & fill lights contribute to the diffuse lighting calculation for a given surface point. Scale values < 1, or negative offset values, make the light illuminate the shape less. Scale values > 1, or positive offset values, make the light illuminate the shape more.

    There are further factors that can affect the color ultimately shown on screen. We use a non-directional ambient light that provides a dim base lighting for the parts of a shape that aren’t facing the light, so they are never totally dark. Lights also contribute specular highlights, too. And if a shape has a metallic surface, the diffuse and specular colors are further blended.

    I hope that is more helpful. Let me know if you have more questions.

    Best regards,
    Tom Jebo
    Sr Escalation Engineer
    Microsoft Open Specifications Support


1 additional answer

Sort by: Most helpful
  1. Tom Jebo 1,991 Reputation points Microsoft Employee
    2022-02-18T23:14:26.46+00:00

    @Regina Henschel ,

    Our graphics team has provided this explanation, please let me know if this is enough information for you:

    The scale and offset values are part of our Gouraud shading equation for calculating the color at any point on a polygon; the scale and offset values can modify the contribution of the shape diffuse color to this equation.

    This old D3D9 article describes the basic concepts of diffuse lighting, with visual examples: Diffuse Lighting (Direct3D 9) - Win32 apps | Microsoft Learn. It doesn’t mention our Office scale or offset values, but those can be thought as modifiers that are pre-applied to the parameter Cd of that article.

    We probably didn’t need to document these Office properties at all, as they always have default values (scale of 1.0, offset of 0.0), so they really have no impact on our lighting equations in practice.

    Best regards,
    Tom Jebo
    Sr Escalation Engineer
    Microsoft Open Specifications Support