Class Material

Represents a physically-based material for rendering surfaces.

class Material
  : dlib.core.ownership.Owner;

Constructors

NameDescription
this (owner) Constructs a new material with default parameters.

Fields

NameTypeDescription
alphaTestThreshold floatAlpha test threshold (for masked transparency).
baseColorFactor dlib.image.color.Color4fBase color factor (albedo color). Used if baseColorTexture is not specified
baseColorTexture TextureBase color (albedo) texture.
blendMode intBlending mode (opaque, transparent, additive).
celShading boolEnables cel shading (pipeline-specific)
colorWrite boolIf false, disables writing to the color buffer.
depthWrite boolIf false, disables writing to the depth buffer.
emissionEnergy floatEmission energy multiplier.
emissionFactor dlib.image.color.Color4fEmission factor. Multiplied with emissionTexture or used directly if emissionTexture is not specified
emissionTexture TextureEmission texture.
heightFactor floatHeight factor. Used if heightTexture is not specified
heightTexture TextureHeight map texture (for parallax mapping).
invertNormalY boolIf true, invert the Y channel of the normal map.
linearColor boolDoes the baseColor in linear RGB space (true), or in sRGB (false)
maskFactor floatAlpha mask factor (for terrain texturing layer material). Used if maskTexture is not specified
maskTexture TextureAlpha mask texture (for terrain texturing layer material).
metallicFactor floatSurface metallic factor (0 = dielectric, 1 = metal). Used if roughnessMetallicTexture is not specified
name stringThe material name (for identification).
normalFactor dlib.math.vector.Vector!(float,3)Tangent-space normal vector. Used if normalTexture is not specified
normalTexture TextureTangent-space normal map texture.
opacity floatOpacity (alpha value, 0.0 = fully transparent, 1.0 = fully opaque).
outputColor boolIf false, disables G-buffer color output.
outputEmission boolIf false, disables G-buffer emission output.
outputNormal boolIf false, disables G-buffer normal output.
outputPBR boolIf false, disables G-buffer PBR output.
parallaxBias floatParallax mapping bias.
parallaxMode intParallax mapping mode.
parallaxScale floatParallax mapping scale.
rimLight boolEnables rim light (pipeline-specific)
roughnessFactor floatSurface roughness factor (0 = smooth, 1 = rough). Used if roughnessMetallicTexture is not specified
roughnessMetallicTexture TextureRoughness/metallic texture.
shadeless boolIf true, disables all shading (renderer-specific option).
shader ShaderOptional shader used for rendering this material.
shadowFilter intShadow filtering mode.
specularity floatSpecularity factor.
sphericalNormal boolIf true, use spherical normal mapping.
subsurfaceScattering floatSubsurface scattering factor.
sun LightOptional main directional light (sun) affecting this material.
textureMappingMode intTexture mapping mode.
textureTransformation dlib.math.matrix.Matrix!(float,3L)Texture transformation matrix.
useCulling boolIf true, enable backface culling.
useFog boolIf true, the surface is fogged according to Environment object settings
useShadows boolIf true, the surface receives shadows.
textureOffsetInternal dlib.math.vector.Vector!(float,2)Internal texture offset (for UV translation).
textureScalingInternal dlib.math.vector.Vector!(float,2)Internal texture scaling (for UV scaling).

Methods

NameDescription
bind (state) Binds the material and sets all relevant graphics state for rendering.
isTransparent () Returns true if the material is transparent (blend mode is not opaque).
setSprite (uvSize, uvPosition) Sets the sprite UV size and position for texture atlases.
textureOffset () Gets the current texture offset (UV translation).
textureOffset (v) Sets the texture offset (UV translation).
textureScale () Gets the current texture scaling (UV scaling).
textureScale (s) Sets the texture scaling (UV scaling).
unbind (state) Unbinds the material and restores graphics state.

Description

The Material class encapsulates all parameters and resources needed for PBR, including textures, colors, blending, parallax, shadow filtering, and shader/material flags. Materials are used to control how surfaces are shaded, blended, and rendered in the engine.