ARKit : Lighting and Materials Part II

Oscar de la Hera
AR Tips And Tricks
Published in
3 min readJan 7, 2019

Last post, we covered how to get basic lighting setup. Today, we will cover Lighting Models and Physically Based Rendering Properties.

Download an AR camera starter project here.

Recommended Reading

The following post is based on the following documentation:

Outline

ARKit creates a material for a model using the SCNMaterial object. It does this via a lighting model and a set of visual properties, each of which ultimately defines how it will behave in SceneKit’s shading and lighting process.

Lighting Model

The lighting model is the property that Scenekit uses to determine the visual properties of your model with the lights in the scene, to produce the final pixel color for each pixel.

Apple’s Lighting Model Sample

Physically Based Rendering

Shading based on a realistic abstraction of physical lights and materials.

Blinn

Shading that incorporates ambient, diffuse, and specular properties, where specular highlights are calculated using the Blinn-Phong formula.

Constant

Uniform shading that incorporates ambient lighting only.

Lambert

Shading that incorporates ambient and diffuse properties only.

Phong

Shading that incorporates ambient, diffuse, and specular properties, where specular highlights are calculated using the Phong formula.

Visual Properties: Physically Based Rendering

Diffuse

Diffuse shading describes the amount and color of light reflected equally in all directions from each point on the material’s surface. The diffuse color of a pixel is independent of the point of view, so it can be thought of as a material’s “base” color or texture.

By default, the diffuse property’s contents object is a white color. The figure below shows the effect of setting the diffuse property’s contents to a texture image on a material whose other properties have default contents.

The material’s lightingModel property determines the formula SceneKit uses to combine its diffuse color and other visual properties with lights and other contents in a scene to produce the final color for each rendered pixel in the rendered scene. For details, see Lighting Models.

- Apple Documentation

To break this down using the image below. Depending on how the lights affect an object, there will be more or less light at each point on the surface — essentially saying which parts are “light”/white or “dark”/black.

Apple Diffuse Image Sample

If you were then to then map an image on top of this color, it would have to be affected in a way that matches the light and dark areas.

Metalness

This property measures only the total intensity of color values; texture contents are best defined in grayscale.

This property generally approximates aspects of a physical surface — such as index of refraction, tendency to produce sharp reflections, and tendency to produce Fresnel reflections at grazing angles — that together produce an overall metallic or nonmetallic (also called dielectric) appearance. Lower values (darker colors) cause the material to appear more like a dielectric surface. Higher values (brighter colors) cause the surface to appear more metallic.

This property applies only when the material’s lightingModel value is physicallyBased.

- Apple Documentation

To break this one down:

  • Use a grayscale color to define this property.
  • The darker, the more ‘non-metallic’.
  • The lighter, the more ‘metallic’.

Roughness

This property measures only the total intensity of color values; texture contents are best defined in grayscale.

This property approximates the level of microscopic detail — for example tiny bumps and cracks — in a surface. By approximating these “microfacets” as a single term, this property helps produce lighting calculations that resemble the energy-conserving laws of real-world physics, resulting in more realistic variation between matte and shiny surfaces. Lower values (darker colors) cause the material to appear shiny, with well-defined specular highlights. Higher values (brighter colors) cause specular highlights to spread out and the diffuse color of the material to become more retroreflective.

This property applies only when the material’s lightingModel value is physicallyBased.

- Apple Documentation

To break this one down:

  • Use a grayscale color to define this property.
  • The darker, the more ‘shiny’.
  • The lighter, the more ‘matte’.

That’s all for now.

Oscar

--

--

Oscar de la Hera
AR Tips And Tricks

Oscar is an award-winning Spanish Inventor whose work impacts lives through brands that include Nike, MoMA and Samsung.