Record Class SurfaceOutputs
baseColor (vec4, linear rgb + alpha), metallic and
roughness (floats), emissive (vec3, linear) and normal,
the shading normal in world space. AO joins in a later phase.
normal may be null, meaning "shade with the interpolated
geometric normal". A tangent-space map becomes a world normal through the
framework helper normalMapToWorld(tangentNormal, scale), which builds a
per-pixel frame from the screen-space derivatives of the world position and the
UVs, so no mesh tangent attribute is required and the vertex stage is
untouched. That is not only convenient: nothing in this toolkit produces
tangents (neither the primitives nor the glTF loader), so a surface that
demanded them would shade most meshes from a zero-length frame.
The diffuse response
diffuseResponse is the one output evaluated inside the light loop,
once per light rather than once per fragment. It replaces the max(dot(N, L), 0)
that scales the diffuse lobe, and it may read two framework locals the other
expressions cannot see:
L: avec3, the unit vector from the surface toward the light, in world space, with the light's type and attenuation already resolved;NdotL: afloat, the value this expression is replacing, so a surface that wants to blend with the standard term does not have to rebuild it.
Null means the standard term, and null is not merely the default: it is a
different generated line. With no response the backend emits the factored
form it always emitted, (kd * albedo / PI + specular) * radiance * NdotL;
with one it has to distribute the NdotL across the two lobes so the diffuse
half can escape it. Those two are equal in real arithmetic and not in IEEE, so a
surface that supplied NdotL back verbatim would still shift the last bits of
every lit pixel. Keeping the null path byte-identical is what lets a material adopt
this without re-pinning a single existing image.
Why the diffuse lobe only. Specular is a mirror about the normal and stays
on NdotL: a response is a statement about how light is scattered by the
surface, not about where it reflects. Wrap lighting, toon ramps, a cloth or hair term,
and the six-way directional response a volumetric billboard wants are all the diffuse
half; none of them wants the highlight moved.
To turn L into the same tangent frame normalMapToWorld shades in,
use the framework helper worldToTangent(v).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thebaseColorrecord component.Returns the value of thediffuseResponserecord component.emissive()Returns the value of theemissiverecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.metallic()Returns the value of themetallicrecord component.normal()Returns the value of thenormalrecord component.static SurfaceOutputsA surface shaded by its geometric normal.Returns the value of theroughnessrecord component.final StringtoString()Returns a string representation of this record class.withDiffuseResponse(Expr diffuseResponse) A copy whose diffuse lobe is scaled bydiffuseResponseinstead of bymax(dot(N, L), 0).withNormal(Expr normal) A copy whose surface normal comes fromnormal, in tangent space.
-
Constructor Details
-
SurfaceOutputs
A surface shaded by the standardN·Ldiffuse response. -
SurfaceOutputs
public SurfaceOutputs(Expr baseColor, Expr metallic, Expr roughness, Expr emissive, Expr normal, Expr diffuseResponse) Creates an instance of aSurfaceOutputsrecord class.- Parameters:
baseColor- the value for thebaseColorrecord componentmetallic- the value for themetallicrecord componentroughness- the value for theroughnessrecord componentemissive- the value for theemissiverecord componentnormal- the value for thenormalrecord componentdiffuseResponse- the value for thediffuseResponserecord component
-
-
Method Details
-
of
A surface shaded by its geometric normal. -
withNormal
A copy whose surface normal comes fromnormal, in tangent space. -
withDiffuseResponse
A copy whose diffuse lobe is scaled bydiffuseResponseinstead of bymax(dot(N, L), 0). The expression is evaluated once per light and may reference the framework localsLandNdotL. -
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). -
baseColor
Returns the value of thebaseColorrecord component.- Returns:
- the value of the
baseColorrecord component
-
metallic
Returns the value of themetallicrecord component.- Returns:
- the value of the
metallicrecord component
-
roughness
Returns the value of theroughnessrecord component.- Returns:
- the value of the
roughnessrecord component
-
emissive
Returns the value of theemissiverecord component.- Returns:
- the value of the
emissiverecord component
-
normal
Returns the value of thenormalrecord component.- Returns:
- the value of the
normalrecord component
-
diffuseResponse
Returns the value of thediffuseResponserecord component.- Returns:
- the value of the
diffuseResponserecord component
-