Record Class Material.NormalMap
- Enclosing interface:
Material
scale without a
texture would mean nothing, so they travel together; 1 is full strength
(glTF's normalTexture.scale default), 0 is the geometric normal, and
values above 1 exaggerate.
The texture must be uploaded from ColorSpace.LINEAR data (see
TextureData.normalMap(int, int, byte[])) because the shader does not gamma-decode it.
Feed it an sRGB-tagged buffer and the surface tilts subtly and consistently
wrong, which looks like a lighting bug rather than an authoring one.
Orientation: green points up. The map is tangent-space with +X toward the right of the image and +Y toward the top of the image, the OpenGL convention, which is what glTF mandates and what art tools export under that name. A map exported as "DirectX" has its green channel inverted and must be flipped before it gets here.
This is worth stating because the frame the shader builds does not enforce it by itself. There is no TANGENT attribute; the frame comes from screen-space derivatives, whose bitangent naturally runs along increasing v, which is down an image. The shader negates it for exactly this reason. Getting the sign wrong lights every surface from the wrong vertical direction and looks like a misplaced light rather than a texture problem, so it is expensive to find.
-
Constructor Summary
ConstructorsConstructorDescriptionNormalMap(GpuTexture texture, float scale) Creates an instance of aNormalMaprecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static Material.NormalMapof(GpuTexture texture) Full strength.floatscale()Returns the value of thescalerecord component.texture()Returns the value of thetexturerecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
NormalMap
Creates an instance of aNormalMaprecord class.- Parameters:
texture- the value for thetexturerecord componentscale- the value for thescalerecord component
-
-
Method Details
-
of
Full strength. -
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
texture
Returns the value of thetexturerecord component.- Returns:
- the value of the
texturerecord component
-
scale
public float scale()Returns the value of thescalerecord component.- Returns:
- the value of the
scalerecord component
-