Package limn.render3d

Record Class Material.NormalMap

java.lang.Object
java.lang.Record
limn.render3d.Material.NormalMap
Enclosing interface:
Material

public static record Material.NormalMap(GpuTexture texture, float scale) extends Record
A tangent-space normal map and how far to lean on it. scale without a texture would mean nothing, so they travel together; 1 is full strength (glTF's normalTexture.scale default), 0 is the geometric normal, and values above 1 exaggerate.

The texture must be uploaded from ColorSpace.LINEAR data (see TextureData.normalMap(int, int, byte[])) because the shader does not gamma-decode it. Feed it an sRGB-tagged buffer and the surface tilts subtly and consistently wrong, which looks like a lighting bug rather than an authoring one.

Orientation: green points up. The map is tangent-space with +X toward the right of the image and +Y toward the top of the image, the OpenGL convention, which is what glTF mandates and what art tools export under that name. A map exported as "DirectX" has its green channel inverted and must be flipped before it gets here.

This is worth stating because the frame the shader builds does not enforce it by itself. There is no TANGENT attribute; the frame comes from screen-space derivatives, whose bitangent naturally runs along increasing v, which is down an image. The shader negates it for exactly this reason. Getting the sign wrong lights every surface from the wrong vertical direction and looks like a misplaced light rather than a texture problem, so it is expensive to find.

  • Constructor Summary

    Constructors
    Constructor
    Description
    NormalMap(GpuTexture texture, float scale)
    Creates an instance of a NormalMap record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    of(GpuTexture texture)
    Full strength.
    float
    Returns the value of the scale record component.
    Returns the value of the texture record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

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

    • NormalMap

      public NormalMap(GpuTexture texture, float scale)
      Creates an instance of a NormalMap record class.
      Parameters:
      texture - the value for the texture record component
      scale - the value for the scale record component
  • Method Details

    • of

      public static Material.NormalMap of(GpuTexture texture)
      Full strength.
    • 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.
    • texture

      public GpuTexture texture()
      Returns the value of the texture record component.
      Returns:
      the value of the texture record component
    • scale

      public float scale()
      Returns the value of the scale record component.
      Returns:
      the value of the scale record component