Use this entry point to provide a custom lighting equation.
- iOS 8.0+
- macOS 10.9+
- tvOS 9.0+
- watchOS 2.0+
Shader modifiers for this entry point may execute in either the vertex or fragment processing stage. If the litPerPixel property of a material affected by the shader modifier is
YES, the snippet executes in the fragment processing stage; otherwise the snippet executes in the vertex processing stage.
The surface entry point defines the following structures:
When rendering a fragment, SceneKit executes this shader modifier once for each active light in the scene. Your shader modifier reads from the
_light structure and accumulates the results of your lighting computations into the
_lighting structure. After your shader modifier completes, SceneKit’s shader program combines the lighting contribution with the surface properties to determine the fragment’s color.
All fields in the
_lighting structure and the
intensity field in the
_light structure are colors. The
direction field is expressed in view space.
The shader modifier below wraps diffuse lighting—that is, it increases all input lighting values by
0, and if the resulting value is greater than
1 it “wraps around” back to