SCNShaderModifierEntryPointLightingModel

Static SCNShaderModifierEntryPointLightingModel 

Source
pub unsafe static SCNShaderModifierEntryPointLightingModel: &'static SCNShaderModifierEntryPoint
Available on crate feature SCNShadable only.
Expand description

This is the entry point to provide custom lighting equation. The fragment will be called for each active light of the scene and will need to accumulate lighting contribution for the vertex or the fragment in the _lightingContribution structure, using the light structure given.

Structures available from the SCNShaderModifierEntryPointLightingModel entry point:

| All the structures available from the SCNShaderModifierEntryPointSurface entry point | | Access: ReadOnly | Stages: Vertex shader and fragment shader

| struct SCNShaderLightingContribution { | float3 ambient; | float3 diffuse; | float3 specular; | } _lightingContribution; | | Access: ReadWrite | Stages: Vertex shader and fragment shader

| struct SCNShaderLight { | float4 intensity; | float3 direction; // Direction from the point on the surface toward the light (L) | } _light; | | Access: ReadOnly | Stages: Vertex shader and fragment shader

Example: Wrap diffuse lighting

GLSL | uniform float WrapFactor = 0.5; | | float dotProduct = (WrapFactor + max(0.0, dot(_surface.normal,_light.direction))) / (1 + WrapFactor); | _lightingContribution.diffuse += (dotProduct * _light.intensity.rgb); | vec3 halfVector = normalize(_light.direction + _surface.view); | dotProduct = max(0.0, pow(max(0.0, dot(_surface.normal, halfVector)), _surface.shininess)); | _lightingContribution.specular += (dotProduct * _light.intensity.rgb);

Metal Shading Language | #pragma arguments | float WrapFactor; | | float dotProduct = (WrapFactor + max(0.0, dot(_surface.normal,_light.direction))) / (1 + WrapFactor); | _lightingContribution.diffuse += (dotProduct * _light.intensity.rgb); | float3 halfVector = normalize(_light.direction + _surface.view); | dotProduct = max(0.0, pow(max(0.0, dot(_surface.normal, halfVector)), _surface.shininess)); | _lightingContribution.specular += (dotProduct * _light.intensity.rgb);

See also Apple’s documentation