Function setSprite2DCoverageGamma
-
Parameters
- layer: Sprite2DLayer
The sprite layer to configure.
- gamma: number
Coverage gamma. Typical text values are ~1.8–2.2;
1disables the effect.
Returns void
- layer: Sprite2DLayer
The sprite layer to configure.
Coverage gamma. Typical text values are ~1.8–2.2; 1 disables the effect.
Enable (or update) coverage gamma on a sprite layer for anti-aliased glyph "stem darkening".
Coverage gamma raises the layer's sampled texture alpha to
1/coverageGammain the fragment shader, thickening anti-aliased edges to mimic the gamma-space blending of native text rasterizers (DirectWrite/CoreText). Intended for glyph-atlas (bitmap text) layers drawn into an sRGB (linear-blended) surface, where correct linear AA otherwise makes text look lighter/thinner. Values> 1thicken;1is a no-op (identity) and disables the effect. Non-finite or non-positive values (0, negatives,NaN,Infinity) are also treated as disabled (the base shader is used).Opt-in & tree-shakable: importing this function is what pulls the coverage-gamma shader permutation and UBO writer into the bundle. Sprite scenes that never call it ship zero gamma bytes. The gamma value is stored internally on the layer and is only settable through this function — there is no create-time option and no public field, so a value can never be written that the renderer would silently ignore. Call it before
createSpriteRenderer/addDepthHostedSpriteLayerso the layer's first pipeline is built with the gamma permutation; calling it later is also safe — the renderer re-fetches the pipeline each frame and rebuilds it with the gamma permutation on the next frame.