Proximity light — MRTK2

A ProximityLight is a Fluent Design System paradigm that mimics a "gradient inverse point light" hovering near the surface of an object. Often used for near interactions, the application can control the properties of a Proximity Light via the ProximityLight component.

For a material to be influenced by a ProximityLight the Mixed Reality Toolkit/Standard shader must be used and the Proximity Light property must be enabled.

Note

Up to two ProximityLights are supported by default.

Examples

Most scenes within MRTK utilize a ProximityLight. The most common use case can be found on the MRTK/SDK/Features/UX/Prefabs/Cursors/FingerCursor.prefab

Advanced Usage

By default only two ProximityLights can illuminate a material at a time. If your project requires more than two ProximityLights to influence a material the sample code below demonstrates how to achieve this.

Note

Having many ProximityLights illuminate a material will increase pixel shader instructions and will impact performance. Please profile these changes within your project.

How to increase the number of available ProximityLights from two to four.

// 1) Within MRTK/Core/StandardAssets/Shaders/MixedRealityStandard.shader change:

#define PROXIMITY_LIGHT_COUNT 2

// to:

#define PROXIMITY_LIGHT_COUNT 4

// 2) Within MRTK/Core/Utilities/StandardShader/ProximityLight.cs change:

private const int proximityLightCount = 2;

// to:

private const int proximityLightCount = 4;

Note

If Unity logs a warning similar to below then you must restart Unity before your changes will take effect.

Property (_ProximityLightData) exceeds previous array size (24 vs 12). Cap to previous size.

See also