Interface Expr

All Known Implementing Classes:
Expr.Binary, Expr.Call, Expr.Construct, Expr.Lit, Expr.Loop, Expr.Raw, Expr.Ref, Expr.Sample, Expr.Swizzle

A node in the neutral, typed shader-expression DAG. A material contributes a SurfaceOutputs built from these; a backend code generator walks the DAG to emit target GLSL (or, later, SPIR-V/MSL). Every node exposes its ShaderType so the generator can type-check and construct correctly.

The set is deliberately small (enough for the standard metallic-roughness surface and custom surfaces, iterative ones included through Expr.Loop), with Expr.Raw as a per-target escape.

A node used twice is computed once. The IR is a value: two nodes are the same computation when their kinds, fields and children are, whether they are one Java object or two built apart, and equals and hashCode say so. The generator writes such a node once and reads it wherever it is used, so a Java method that builds a sub-expression is as cheap to call twice as once, and a variable reused in a long chain does not multiply the shader's size. Comparing, hashing and toString visit a node shared by many parents once; toString writes such a node the first time as #1=… and then as #1.

A 1.x minor release may add node types: a switch over an Expr needs a default branch.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final record 
    Binary arithmetic; result type follows GLSL scalar/vector promotion.
    static final record 
    A built-in or engine helper call with a declared result type.
    static final record 
    A constructor like vec4(rgb, a) or vec3(x).
    static final record 
    A numeric literal, scalar or vector by value count.
    static final record 
    A value computed by a bounded loop: a state of one value or several, their initial values, and the state after one turn, taken at most maxIterations times.
    static enum 
    Arithmetic operators.
    static final record 
    Non-portable inline GLSL, valid only for target.
    static final record 
    A named value: an input the framework or the surface declares (a UBO member, a varying, a sampler, a Material.Surface input), or the state of the Expr.Loop it is read in, which Expr.Loop.of(limn.render3d.shader.Expr, int, java.util.function.Function<? super limn.render3d.shader.Expr, ? extends limn.render3d.shader.Expr>) hands the loop's turn.
    static final record 
    Samples sampler at uv → vec4.
    static final record 
    Component selection, e.g.
  • Method Summary

    Modifier and Type
    Method
    Description