lightingContext
Automatically aggregates the lighting contribution from all light sources in the scene (direct and environmental) and computes the final surface color based on a specified lighting model.
Core Advantages
Completely abstracts and automates the complex multi-light calculation process (e.g., light loops, type checking, result accumulation), allowing developers to focus on designing the lighting model itself without handling the underlying light loop logic.
Common Uses
Implementing standard Physically-Based Rendering (PBR).
Creating Non-Photorealistic Rendering (NPR) styles, such as toon shading.
Aggregating the effects of custom lighting models (like Phong) under multiple lights.
Seamlessly combining direct lighting with Image-Based Lighting (IBL) from an environment map.
How to adjust
Its effect is adjusted by changing the input 'lighting model node'. For example, replacing a PhysicalLightingModel with a toon shading model will completely alter the rendering style. Alternatively, keeping the model the same but changing its inputs (e.g., switching the 'roughness' from a constant value to a texture map) can add rich detail and variation to the surface.
Code Examples
1// Apply a lighting model (e.g., PBR) to all light sources
2// and combine with environmental light to get the final color.
3lightingContext( new PhysicalLightingModel( diffuseColor, roughness, metalness ) );