Package limn.graphics

Class ScenePixels

java.lang.Object
limn.graphics.ScenePixels

public final class ScenePixels extends Object
Scene-referred pixels read back from a ReadableSurface: RGBA floats, linear light, premultiplied alpha, row-major, row 0 at the top. These are the numbers the renderer wrote, with no display transform applied (no exposure, no tonemap, no sRGB encode), and channels may exceed 1.0.

Deliberately not an Image, and this is the whole point of the type. Image is eight bits per channel of display-encoded colour; putting scene-referred light into one would clip every highlight and mislabel what survived, and the clip would be invisible until someone looked at a washed-out sky and blamed a shader. Because this is a distinct type, no encoder accepts it: there is no path from here to a PNG that silently loses the range. Use ReadableSurface.readDisplayReferred() for anything a person will look at.

What this is for: comparing a render against a reference with a tolerance, feeding pixels to something that applies its own display transform, or asserting in a test what a pass actually wrote.

Alpha is premultiplied, exactly as the target stores it, so no channel is divided and the question of what alpha == 0 means never arises here: it means the pixel contributes nothing, and RGB may still be non-zero (additive radiance over a transparent background).

Four floats per pixel: a 4K frame is about 132 MB. Read a sub-rectangle when a sub-rectangle is what you need.

  • Constructor Details

    • ScenePixels

      public ScenePixels(int width, int height, float[] rgba)
      Parameters:
      width - pixels
      height - pixels
      rgba - width*height*4 floats, linear light, premultiplied, top-down
  • Method Details

    • width

      public int width()
      Returns:
      width in pixels
    • height

      public int height()
      Returns:
      height in pixels
    • channels

      public float[] channels()
      Returns:
      the raw float channels, four per pixel (do not mutate)
    • channel

      public float channel(int x, int y, int channel)
      Parameters:
      x - column, 0 at the left
      y - row, 0 at the top
      channel - 0 = red, 1 = green, 2 = blue, 3 = alpha
      Returns:
      the linear, premultiplied channel value; may exceed 1
      Throws:
      IndexOutOfBoundsException - if the coordinates or channel are outside the buffer