Camera settings
By default, Varjo software adjusts cameras for optimal brightness and color tone. However, you can override those values. Through the API, you can change:
- Exposure
- Auto exposure behaviour
- ISO/gain
- White balance
- Flicker compensation
- Sharpness (not available for XR-4)
- Eye reprojection
Changing the camera settings
First, lock the camera config:
bool locked = VarjoMixedReality.LockCameraConfig();
Only one application can lock the config at a time, so it is possible that your application can’t obtain the lock in case someone else is currently holding it. If the configuration can’t be locked, any attempts to change the camera properties will fail.
When you are holding the lock, you can e.g. change the operating mode to manual and change the manual setting.
VarjoMixedReality.SetCameraPropertyMode(VarjoCameraPropertyType type, VarjoCameraPropertyMode mode);
VarjoMixedReality.SetCameraPropertyValue(VarjoCameraPropertyType type, VarjoCameraPropertyValue value);
You can determine the supported modes and values with:
VarjoMixedReality.GetCameraPropertyModes(VarjoCameraPropertyType type, out List<VarjoCameraPropertyMode> modes);
VarjoMixedReality.GetCameraPropertyValues(VarjoCameraPropertyType type, out List<VarjoCameraPropertyValue> values);
Currently active mode and value for each camera property can be checked with:
VarjoMixedReality.GetCameraPropertyMode(VarjoCameraPropertyType type, out VarjoCameraPropertyMode mode);
VarjoMixedReality.GetCameraPropertyValue(VarjoCameraPropertyType type, out VarjoCameraPropertyValue value);
Unlock the camera config once you are done. Alternatively, if you want to prevent other applications from changing the camera properties, you can leave the configuration locked.
VarjoMixedReality.UnlockCameraConfig();
A camera property can be reseted to default mode and value with:
VarjoMixedReality.ResetCameraProperty(VarjoCameraPropertyType type);
Or reset all properties to defaults:
VarjoMixedReality.ResetCameraProperties();
Example
As an example, here is how one could manually increase the exposure time.
// Start by locking the camera config
bool locked = VarjoMixedReality.LockCameraConfig();
if (locked)
{
// By default the exposure time is adjusted automatically. Let's change it to manual mode.
// Use VarjoMixedReality.GetCameraPropertyModes(VarjoCameraPropertyType type, out List<VarjoCameraPropertyMode> modes)
// to check supported modes. Exposure time supports modes VarjoCameraPropertyMode.Auto and VarjoCameraPropertyMode.Manual.
VarjoMixedReality.SetCameraPropertyMode(VarjoCameraPropertyType.ExposureTime, VarjoCameraPropertyMode.Manual);
// Get the possible exposure time values
List<VarjoCameraPropertyValue> exposureTimeValues = new List<VarjoCameraPropertyValue>();
VarjoMixedReality.GetCameraPropertyValues(VarjoCameraPropertyType.ExposureTime, out exposureTimeValues);
// Get the current exposure time value
VarjoCameraPropertyValue currentValue;
VarjoMixedReality.GetCameraPropertyValue(VarjoCameraPropertyType.ExposureTime, out currentValue);
// Get the index of the current value in the list of supported values
int valueIndex = exposureTimeValues.IndexOf(currentValue);
// If current value is found from the list and there are bigger supported values, set the next value from the list
if (valueIndex != -1 && valueIndex < exposureTimeValues.Count - 2)
{
VarjoMixedReality.SetCameraPropertyValue(VarjoCameraPropertyType.ExposureTime, exposureTimeValues[valueIndex + 1]);
}
//Finally, unlock the camera config
VarjoMixedReality.UnlockCameraConfig();
// Let's print out the updated value
// The data type of the value can be checked from VarjoCameraPropertyValue.type
VarjoMixedReality.GetCameraPropertyValue(VarjoCameraPropertyType.ExposureTime, out currentValue);
Debug.Log($"Current exposure time: {currentValue.doubleValue}");
}