Package limn.render3d

Record Class TextureData

java.lang.Object
java.lang.Record
limn.render3d.TextureData

public record TextureData(int width, int height, byte[] rgba8, ColorSpace colorSpace) extends Record
CPU-side pixels for a 2D texture: tightly packed 8-bit RGBA, row-major from the top-left, tagged with the ColorSpace the values are authored in. Upload once with Graphics3D.uploadTexture(data, sampler) to get a GpuTexture. Base-color maps are normally ColorSpace.SRGB (the shader linearizes them); data maps (normal/metallic/roughness, added later) are ColorSpace.LINEAR.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TextureData(int width, int height, byte[] rgba8, ColorSpace colorSpace)
    Creates an instance of a TextureData record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the colorSpace record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    int
    Returns the value of the height record component.
    normalMap(int width, int height, byte[] rgba8)
    A tangent-space normal map: rgb encoding n × 0.5 + 0.5, tagged ColorSpace.LINEAR so nothing gamma-decodes it.
    rgba(int width, int height, byte[] rgba8, ColorSpace colorSpace)
    Convenience for a solid or generated buffer already in RGBA byte order.
    byte[]
    Returns the value of the rgba8 record component.
    final String
    Returns a string representation of this record class.
    int
    Returns the value of the width record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • TextureData

      public TextureData(int width, int height, byte[] rgba8, ColorSpace colorSpace)
      Creates an instance of a TextureData record class.
      Parameters:
      width - the value for the width record component
      height - the value for the height record component
      rgba8 - the value for the rgba8 record component
      colorSpace - the value for the colorSpace record component
  • Method Details

    • rgba

      public static TextureData rgba(int width, int height, byte[] rgba8, ColorSpace colorSpace)
      Convenience for a solid or generated buffer already in RGBA byte order.
    • normalMap

      public static TextureData normalMap(int width, int height, byte[] rgba8)
      A tangent-space normal map: rgb encoding n × 0.5 + 0.5, tagged ColorSpace.LINEAR so nothing gamma-decodes it. Because the pipeline decodes sRGB in the shader and never uses a GL sRGB internal format, that tag is the only thing separating a data map from a colour map, which is why it is worth a named factory rather than a fourth argument somebody gets wrong.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • width

      public int width()
      Returns the value of the width record component.
      Returns:
      the value of the width record component
    • height

      public int height()
      Returns the value of the height record component.
      Returns:
      the value of the height record component
    • rgba8

      public byte[] rgba8()
      Returns the value of the rgba8 record component.
      Returns:
      the value of the rgba8 record component
    • colorSpace

      public ColorSpace colorSpace()
      Returns the value of the colorSpace record component.
      Returns:
      the value of the colorSpace record component