Docsv2.12.12
Back to API Reference
Class

EffectModifier

abstract
Inherits:BaseModifier

Base class for modifiers that append duplicate glyph geometry behind or in front of the face (outline, shadow, extrude, glow, custom effects).

Remarks

Contract: During onGlyph, the subclass's OnGlyphEffect decides whether the current glyph needs an effect quad and, if so, calls EnqueueDuplicate with an arbitrary payload integer — typically an index into the modifier's own per-emit data table. The currentEffectPass in effect at enqueue time is captured and decides whether the duplicate lands before or after the face block. At onMainPassFinalize, the per-modifier emit queue is flushed via OnFlush. The default implementation reserves 4 vertices and 6 indices for each pending emit (copying source geometry, queueing triangles) and then calls OnEmitQuad so the subclass can fill colour, UV2, offsets — anything the effect needs. Multi-layer effects override OnFlush to flush per-layer buffers in layer-major order. Painter order is preserved by per-modifier grouping: onMainPassFinalize flushes each modifier in registration order, so all of one modifier's quads land contiguously in the index buffer ahead of the next modifier's quads, ahead of the face block (or after, when PostFace was active). The base class deliberately knows nothing about colour, dilate, softness, offsets, gradients, or any effect-specific parameter. Those live entirely inside the subclass. Common write patterns (solid colour + UV2, per-vertex gradient, offset, expand) are exposed via the static EffectQuadOps helpers so subclasses share the implementation without sharing the data layout.

Derived Types(3)

Types that inherit from EffectModifier.

protected abstract void OnGlyphEffect()

Called once per glyph during mesh generation. The subclass decides whether the current glyph (currentCluster) needs an effect quad and invokes EnqueueDuplicate if so. Emoji glyphs must be skipped (uniText.MeshGenerator.font.IsColor).

protected abstract void OnEmitQuad(int sourceBaseIdx, int destBaseIdx, int payload)

Writes the actual per-vertex data into a reserved effect-quad slot. The base has already copied geometry (positions, UV0, UV1) from the source face quad and queued the triangle indices; destBaseIdx points at the first of the four duplicate vertices. The subclass writes Colors, Uvs2, and (if needed) re-positions Vertices through EffectQuadOps helpers.

protected override void OnEnable()
protected override void OnDisable()
protected override void OnDestroy()
protected virtual void ResetOwnRequests()

Resets per-cycle emit state. Subclasses with extra buffers (e.g. multi-layer effects) override and chain to clear their own storage.

protected void EnqueueDuplicate(int sourceBaseIdx, int payload)

Queues a duplicate of the given face quad for emission at onMainPassFinalize. The duplicate will land in the index buffer according to the current currentEffectPass.

protected virtual void OnFlush()

Flushes the pending emit queue. Default implementation processes emits in the order they were enqueued — correct for single-layer effects. Multi-layer effects (e.g. extrude) override and iterate their own per-layer buffers in layer-major order, calling ReserveQuad + OnEmitQuad directly.

protected static int ReserveQuad()

Reserves a 4-vertex / 6-index effect-quad slot: copies positions, UV0 and UV1 from the source quad, queues a triangle pair into the shared pre/post-face buffer matching pass, and advances vertexCount.