Often for luminance or contrast displays you need more than 8 bit color depth (for example, if contrast thresholds are under 1%, you need finer color resolution to show gratings). You can set color modes for higher bit depth with the following function:
mglMetalSetViewColorPixelFormat
For example, you can set to a 10 bit format (e.g. MTLPixelFormatRGB10A2Unorm). This will allow all mgl functions that specify colors as floating point values between 0 and 1 to have 10 bit resolution. Note that the monitor has to support high color bit modes (usually specified in the specs as supporting HDR10 or 1.07 billion colors or more), have a graphics card that also supports these modes and connect through an interface (HDMI or USB-C) that allows for high bit depth modes.
Below is an example of trying to increase luminance in increments of 1/1024 from gray with an 8 bit pixel format on the left and a 10 bit pixel format on the right. Where the y-axis shows you the measurement from a photometer (PR-650). You can see the step function of luminance every 1/256 for the 8 bit format is now completely linear for the 10 bit format.