Package limn.render3d

Interface Material

All Known Implementing Classes:
Material.Pbr, Material.Raw, Material.SimpleLit, Material.Surface, Material.Unlit

public sealed interface Material permits Material.Unlit, Material.SimpleLit, Material.Pbr, Material.Surface, Material.Raw
How a surface is shaded. Ships built-in Material.Unlit, Material.SimpleLit and physically-based Material.Pbr models, generated from the neutral shader IR, plus two ways for an application to shade something the built-ins cannot express.

The two are not interchangeable and the choice is usually easy. Material.Surface supplies the four surface expressions in the same neutral IR the built-ins are written in: it is lit by the engine (every light on the pass, the shadow map, the environment), and it compiles to every TargetProfile the toolkit supports. Material.Raw is hand-written GLSL that replaces the whole program: it sees no lights and no textures, and it is, by definition, non-portable.

Reach for Surface for a material; reach for Raw for something that is not one.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final record 
    A tangent-space normal map and how far to lean on it.
    static final record 
    Metallic-roughness PBR (Cook-Torrance GGX), lit by every Light on the pass plus a flat ambient term.
    static final record 
    Custom GLSL.
    static final record 
    Lambert diffuse from the pass's single directional light, over a base color.
    static final record 
    A surface the application builds itself, out of the same neutral shader IR the built-in materials are generated from, and lit by the same core.
    static final record 
    A flat/vertex color, unaffected by lights.
  • Method Summary

    Modifier and Type
    Method
    Description
    default BlendMode
    How this surface composites with what is already in the target, or null (the default) for an opaque one.
    default boolean
    Whether this surface writes depth and casts shadows, i.e.
  • Method Details

    • blend

      default BlendMode blend()
      How this surface composites with what is already in the target, or null (the default) for an opaque one.

      Opaque draws are issued first, in submission order; they write depth and cast shadows. Blended draws follow, also in submission order, and they test depth but do not write it, so overlapping transparent surfaces all show instead of the nearest one hiding the rest. Nothing sorts them: a pass places every mesh exactly where the caller put it, and back-to-front order (where it matters, which is BlendMode.NORMAL and not BlendMode.ADDITIVE) is the caller's to arrange, inside its own geometry as much as between draws.

      The modes and their equations are the 2D canvas's (BlendMode): an additive 3D surface and an additive 2D sprite composite identically, because both pipelines are premultiplied.

      There is deliberately no alpha-test mode. Cutout foliage stays opaque (depth-writing and shadow-casting) and discards in its surface function.

    • isOpaque

      default boolean isOpaque()
      Whether this surface writes depth and casts shadows, i.e. blend() is unset.