Interface BakedNormals

All Known Implementing Classes:
BakedNormals.PerQuad, BakedNormals.PerVertex

public sealed interface BakedNormals permits BakedNormals.PerQuad, BakedNormals.PerVertex
Holds pre-computed normals, either for the entire quad or for each vertex.

The normal values are quantized to an integer between -127 and 127, truncated to a byte and packed into an int, leaving the MSB unused.

Normals can also be unspecified. In that case, rendering will use the normal implied by BakedQuad.direction(), while a face normal will be computed for the purposes of AO calculations.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final record 
     
    static final record 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final BakedNormals
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    computeQuadNormal(Vector3fc position0, Vector3fc position1, Vector3fc position2, Vector3fc position3)
    Computes the packed normal of a quad based on the given vertex positions.
    static boolean
    isUnspecified(int packedNormal)
    Returns true if the packed normal represents an unspecified normal.
    int
    normal(int vertex)
    Returns The packed normal of the given vertex.
    of(int normal)
     
    of(int normal0, int normal1, int normal2, int normal3)
     
    static int
    pack(float x, float y, float z)
    Returns a packed representation of the given normal.
    static int
    pack(Vector3fc normal)
    Returns a packed representation of the given normal.
    static Vector3fc
    unpack(int packedNormal, @Nullable Vector3f destination)
     
    static float
    unpackComponent(int packedNormal, int axis)
    Returns the component of the given packed normal.
    static float
    unpackX(int packedNormal)
    Returns the x component of the given packed normal.
    static float
    unpackY(int packedNormal)
    Returns the y component of the given packed normal.
    static float
    unpackZ(int packedNormal)
    Returns the z component of the given packed normal.
  • Field Details

  • Method Details

    • normal

      int normal(int vertex)
      Returns The packed normal of the given vertex. It can also be unspecified.
      Returns:
      The packed normal of the given vertex
      See Also:
    • of

      static BakedNormals of(int normal0, int normal1, int normal2, int normal3)
      Parameters:
      normal0 - The normal of the first vertex, packed using pack(float, float, float).
      normal1 - The normal of the second vertex, packed using pack(float, float, float).
      normal2 - The normal of the third vertex, packed using pack(float, float, float).
      normal3 - The normal of the fourth vertex, packed using pack(float, float, float).
    • of

      static BakedNormals of(int normal)
      Parameters:
      normal - The face normal, packed using pack(float, float, float).
    • pack

      static int pack(float x, float y, float z)
      Returns a packed representation of the given normal.
      Returns:
      a packed representation of the given normal
    • pack

      static int pack(Vector3fc normal)
      Returns a packed representation of the given normal.
      Returns:
      a packed representation of the given normal
    • unpackComponent

      static float unpackComponent(int packedNormal, int axis)
      Returns the component of the given packed normal.
      Parameters:
      axis - Pass 0 to extract the x component, 1 for y and 2 for z.
      Returns:
      the component of the given packed normal
      See Also:
    • unpackX

      static float unpackX(int packedNormal)
      Returns the x component of the given packed normal.
      Returns:
      the x component of the given packed normal
      See Also:
    • unpackY

      static float unpackY(int packedNormal)
      Returns the y component of the given packed normal.
      Returns:
      the y component of the given packed normal
      See Also:
    • unpackZ

      static float unpackZ(int packedNormal)
      Returns the z component of the given packed normal.
      Returns:
      the z component of the given packed normal
      See Also:
    • unpack

      static Vector3fc unpack(int packedNormal, @Nullable Vector3f destination)
      Parameters:
      destination - The vector to unpack the packed normal into, if null, a new vector will be allocated.
      Returns:
      The vector that the normal was unpacked into.
    • isUnspecified

      static boolean isUnspecified(int packedNormal)
      Returns true if the packed normal represents an unspecified normal.
      Returns:
      true if the packed normal represents an unspecified normal
    • computeQuadNormal

      static int computeQuadNormal(Vector3fc position0, Vector3fc position1, Vector3fc position2, Vector3fc position3)
      Computes the packed normal of a quad based on the given vertex positions.
      Returns:
      The packed representation of the computed normal.