message: Eliminate conditionals related to monochrome display.
diff: import { FragmentShaderBuilder, FragmentShaderComponent, VariableType } from "../ShaderBuilder";
  import { FloatRgba } from "../FloatRGBA";
  +// The alpha component of the mono color is 1.0 if lit, 0.0 if unlit.
  +// Unlit stuff (edges, polylines) uses the mono color directly in order for white-on-white reversal to work correctly.
  const applyMonochromeColor = `
  - if (!isShaderBitSet(kShaderBit_Monochrome))
  - return baseColor;
  + // Compute lit monochrome color
  + vec3 litRgb = baseColor.rgb;
  + litRgb /= max(0.0001, baseColor.a); // un-premultiply alpha
  + litRgb = vec3(dot(litRgb, vec3(.222, .707, .071)));
  + litRgb *= u_monoRgb.rgb;
  - // The alpha component of the mono color = 1.0 if lit, 0.0 if unlit
  - // We need to use the mono color directly for unlit stuff (i.e. edges, polylines) in order for white-on-white reversal to work correctly.
  - // But it looks terrible for lit surfaces.
  - if (u_monoRgb.a > 0.5) {
  - // Preserve translucency...
  - if (baseColor.a > 0.0)
  - baseColor.rgb /= baseColor.a;
  + // Select lit or unlit based on u_monoColor.a
  + vec4 monoColor = vec4(mix(u_monoRgb.rgb, litRgb, u_monoRgb.a), baseColor.a);
  + monoColor.rgb *= monoColor.a;
  - baseColor.rgb = vec3(dot(baseColor.rgb, vec3(.222, .707, .071)));
  - baseColor.rgb *= u_monoRgb.rgb;
  - } else {
  - baseColor.rgb = u_monoRgb.rgb;
  - }
  -
  - baseColor.rgb *= baseColor.a;
  - return baseColor;
  + // Select monochrome or element color based on shader flag
  + return mix(baseColor, monoColor, extractShaderBit(kShaderBit_Monochrome));
  `;
  export function addMonochrome(frag: FragmentShaderBuilder): void {
  