Zoom opacity¶
Zoom opacity can fade any mesh or skinned-mesh renderer hierarchy. The Zoom package owns the curve, evaluated ZoomOpacity, and renderer-source references. Section Streaming owns the _DitherStrength material override and renderer application. No army package is required.
Inspector setup¶
- Register
ZoomModuleandSectionStreamingModulein the world, as for map rendering. - Add Stratkit > Zoom > Opacity (
ZoomOpacityAuthoring) to the element root. - Set
Opacities, with one value per zoom state, up to seven states. For example,[1, 1, 0]stays fully visible between states 0 and 1, then fades out between states 1 and 2. - Leave
Renderersempty to include descendant mesh and skinned-mesh renderers, including inactive children. Alternatively, assign the renderers explicitly. Additional submeshes are bound during baking.
An empty curve disables this authoring component. MaximumZoomLevel = -1 evaluates all states. Use this component or the custom-baker API on a source, not both.
The material shader must expose a DOTS-instanced _DitherStrength property. Opaque materials must enable alpha clipping in both the graph and any material overrides. Transparent materials multiply alpha by this property. This binding owns that override; do not use an independent section-fade writer on the same renderer.
Custom baker API¶
Reference Stratkit.Zoom and Stratkit.Zoom.Editor. In an existing Baker<T>:
Entity source = CreateAdditionalEntity(TransformUsageFlags.None);
AddComponent(source, new ZoomContinuousInterpolation {
MaximumLevel = ZoomContinuousInterpolation.NoMaximumLevel,
ScaleMultiplier = 1f,
});
ZoomOpacityBaking.AddSource(this, source, authoring.Opacities);
ZoomOpacityBaking.BindRenderers(this, source, GetComponentsInChildren<Renderer>());
Import Stratkit.Zoom, Stratkit.Zoom.Editor, Unity.Entities, and UnityEngine. The additional entity isolates the opacity curve from transform zoom components on the primary entity, preserving any existing discrete transitions. ZoomOpacityAuthoring uses this isolated controller too. An existing source can be shared only when its transforms already intentionally use continuous interpolation; keep its existing ZoomContinuousInterpolation component in that case. Call each helper once per source. AddSource also supports a persistent controller with no renderers, as used by spawners.
BindRenderers records entity references at bake time and tracks additional renderer entities across incremental bakes. Instantiating a prefab remaps references to its new opacity source. The source must outlive its bound renderers, or be destroyed together with them. When renderer application runs, a missing source applies zero opacity as a safety fallback; the owner must still clean up those renderers.
Visibility and lifetime¶
ZoomOpacity.Value is the current fade, and ZoomOpacity.IsVisible reports whether it is above zero. Read the output after ZoomContinuousInterpolationSystem in your visibility or spawn controller. Reading job-written opacity on the main thread completes its job dependencies. For an authored, nonempty curve, use ZoomOpacities.Evaluate(progress, maximumLevel) to calculate the same opacity from current ZoomLevelStepRatio and authored settings without reading that output. The army spawner uses this path for its persistent configuration. Keep the controller alive when despawning its presentation entities so zooming back in can spawn them again.
Renderer application runs at the end of LateSimulationSystemGroup. It changes material overrides; the element's owner uses IsVisible to hide, pool, or despawn presentation entities. Army graphics uses the same opacity evaluation to destroy complete model hierarchies, including shadows, and prevent spawning while fully faded.
For a manually driven opacity, add only ZoomOpacity to the source, bind its renderers, and update Value in the range [0, 1]. Do not attach ZoomOpacities and ZoomContinuousInterpolation to that source, since the zoom system would overwrite manual values.