materialOpacity
Provides the material's final opacity, with built-in logic to multiply the `.opacity` property by the `.alphaMap` texture.
Core Advantages
Its core advantage is automatic combination: it fully encapsulates the common pattern of 'multiplying a base opacity by a map' and seamlessly integrates with standard material properties, greatly simplifying the implementation of transparency and cutout effects.
Common Uses
Creating translucent materials like glass or water.
Creating hard-edged cutout effects like leaves or fences in conjunction with `alphaTest`.
Achieving fade-in/fade-out effects by animating the `material.opacity` property in JS.
As a mask to modulate the intensity of other effects, like determining emissive strength based on opacity.
How to adjust
In JavaScript, first set `material.transparent = true`. Then, control the global opacity with `material.opacity` (0-1). If `material.alphaMap` is provided, the final opacity is `opacity * map_value`, enabling localized transparency variations.
Code Examples
1// In the shader, the final calculated color is blended with materialOpacity
2// (This is usually handled automatically by TSL; the user just sets output.opacity)
3output.color = vec4( finalRGB, materialOpacity );