Record Class Material.Surface
- Record Components:
key- the program cache key; equal keys must mean equaloutputsoutputs- the surface expressions, in the neutral IRtextures- named samplers the IR may reference, bound in ordervalues- namedvec4uniforms the IR may referenceblend-nullfor an opaque surface
- All Implemented Interfaces:
Material
- Enclosing interface:
Material
This is the difference from Material.Raw, and it is the whole point.
Raw GLSL is a shortcut past the engine: it sees no lights, no shadow map, no
environment, and it is one shading language forever. A Surface is
spliced into the same main() the built-in metallic-roughness material
is, so it reaches every light on the pass, the shadow map and the IBL, and it
compiles to every TargetProfile the toolkit
supports. What it replaces is only the four surface expressions: base colour,
metallic, roughness and emissive, plus the shading normal.
Reach for it when the built-in material cannot express what a surface *is*: a sprite sheet cross-fading between two cells, an erosion driven by a mask, a scrolling flow map. Not for a different lighting model: the BRDF belongs to the engine, and a material that wanted its own would be describing a different renderer.
Inputs are named, and the names are the contract. Each
Material.Surface.Texture and Material.Surface.Value is declared to the generated shader under its
own name, and the surface's IR reaches it with an Expr.Ref
carrying that name and the matching type. A name that is declared and never
referenced is harmless; a name referenced and never declared fails to compile,
which is the right moment to find out.
key identifies the program, not the material. Two surfaces
with the same key must generate the same shader: the key is what the compiled
program is cached under, and the values and textures are free to differ per
draw. Getting this wrong shows up as a material silently rendering with another
one's shader. Note it is deliberately not the record's identity:
Material.Raw caches by identity, so an application that rebuilds its material
record every frame links a fresh program every frame, and this must not repeat
that.
Per-vertex data beyond position, normal, UV and colour reaches a surface
through VertexAttribute.UV1, VertexAttribute.PARAMS and
VertexAttribute.PARAMS1, as v_uv1, v_params and
v_params1. The framework also declares v_worldPos,
v_normal, v_uv and v_color. Fill PARAMS before
reaching for PARAMS1: two half-used streams cost bandwidth one full one
does not.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA named sampler.static final recordA namedvec4uniform.Nested classes/interfaces inherited from interface limn.render3d.Material
Material.NormalMap, Material.Pbr, Material.Raw, Material.SimpleLit, Material.Surface, Material.Unlit -
Constructor Summary
ConstructorsConstructorDescriptionSurface(String key, SurfaceOutputs outputs, List<Material.Surface.Texture> textures, List<Material.Surface.Value> values, BlendMode blend) Creates an instance of aSurfacerecord class. -
Method Summary
Modifier and TypeMethodDescriptionblend()Returns the value of theblendrecord component.nullrestores opaque.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.key()Returns the value of thekeyrecord component.static Material.Surfaceof(String key, SurfaceOutputs outputs) An opaque surface with no inputs of its own.outputs()Returns the value of theoutputsrecord component.textures()Returns the value of thetexturesrecord component.final StringtoString()Returns a string representation of this record class.values()Returns the value of thevaluesrecord component.with(List<Material.Surface.Texture> textures, List<Material.Surface.Value> values) A copy with different inputs; the key and therefore the program are unchanged.
-
Constructor Details
-
Surface
public Surface(String key, SurfaceOutputs outputs, List<Material.Surface.Texture> textures, List<Material.Surface.Value> values, BlendMode blend) Creates an instance of aSurfacerecord class.
-
-
Method Details
-
of
An opaque surface with no inputs of its own. -
with
public Material.Surface with(List<Material.Surface.Texture> textures, List<Material.Surface.Value> values) A copy with different inputs; the key and therefore the program are unchanged. -
blend
nullrestores opaque. -
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. -
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. -
equals
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. All components in this record class are compared withObjects::equals(Object,Object). -
key
Returns the value of thekeyrecord component.- Returns:
- the value of the
keyrecord component
-
outputs
Returns the value of theoutputsrecord component.- Returns:
- the value of the
outputsrecord component
-
textures
Returns the value of thetexturesrecord component.- Returns:
- the value of the
texturesrecord component
-
values
Returns the value of thevaluesrecord component.- Returns:
- the value of the
valuesrecord component
-
blend
Returns the value of theblendrecord component.
-