Package limn.render3d

Enum Class ColorSpace

java.lang.Object
java.lang.Enum<ColorSpace>
limn.render3d.ColorSpace
All Implemented Interfaces:
Serializable, Comparable<ColorSpace>, Constable

public enum ColorSpace extends Enum<ColorSpace>
How the channel values of a color or texture are encoded. Authoring happens in SRGB (what image editors and hex colors give you); lighting must run in LINEAR. The 3D pipeline decodes sRGB inputs to linear in the shader and lights in linear; the render target stays linear, scene-referred, and the re-encode to sRGB happens once in the 2D composite, as the tail of the display transform (exposure, ACES, encode), when the target is drawn. It never relies on GL sRGB texture formats, kept portable to GLSL ES.

The static helpers are the CPU reference for the same piecewise transfer function the shaders implement (IEC 61966-2-1): the decode in the 3D pass, the encode in the composite; they exist so the conversion can be unit-tested headless and reused where a color must be linearized on the CPU.

  • Enum Constant Details

    • SRGB

      public static final ColorSpace SRGB
      Gamma-encoded (perceptual). Base-color textures and authored colors live here.
    • LINEAR

      public static final ColorSpace LINEAR
      Physically linear. Lighting math and render targets accumulate here.
  • Method Details

    • values

      public static ColorSpace[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ColorSpace valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • srgbToLinear

      public static float srgbToLinear(float c)
      Decodes one sRGB-encoded channel in [0,1] to linear light.
    • linearToSrgb

      public static float linearToSrgb(float c)
      Encodes one linear-light channel in [0,1] back to sRGB (the display OETF).
    • tonemapAces

      public static float tonemapAces(float x)
      The ACES filmic curve (Narkowicz's fit), clamped to [0,1], the shoulder that maps unbounded scene-referred light onto a display's range. Input is linear light with exposure already applied.
    • displayTransform

      public static float displayTransform(float linear, float exposure)
      The whole display transform for one channel: exposure, then tonemapAces(float), then linearToSrgb(float). Scene-referred linear light in, display-referred sRGB out.

      This is the CPU mirror of the transform the 2D composite applies when a render target is drawn, and it exists so that reading a target back produces the picture that was on screen rather than an approximation of it. The two implementations must agree: changing the curve on one side and not the other makes an exported image differ from the window it came from, with nothing to point at.

      Parameters:
      linear - one linear-light channel, straight (not premultiplied); may exceed 1
      exposure - the exposure the pass was given