Enables distance-based alpha fading (LOD, fog, smooth transitions). Takes entity (entity handle), nearDist (distance where fully visible), farDist (distance where fully transparent). Returns nothing. Validates entity exists, sets entity.autoFadeEnabled=true, stores entity.autoFadeNear=nearDist and entity.autoFadeFar=farDist, special case: if both distances=0.0 disables auto fade (sets autoFadeEnabled=false). Automatic opacity adjustment based on camera distance.
This function enables distance-based fading.
Enables distance-based alpha fading (LOD, fog, smooth transitions). Takes entity (entity handle), nearDist (distance where fully visible), farDist (distance where fully transparent). Returns nothing. Validates entity exists, sets entity.autoFadeEnabled=true, stores entity.autoFadeNear=nearDist and entity.autoFadeFar=farDist, special case: if both distances=0.0 disables auto fade (sets autoFadeEnabled=false). Automatic opacity adjustment based on camera distance.
This function enables distance-based fading. Auto fade behavior: during rendering, calculates distance from camera to entity, interpolates alpha/opacity based on distance relative to near/far thresholds, nearDist: entity fully opaque (alpha=1.0) at this distance or closer, farDist: entity fully transparent (alpha=0.0) at this distance or farther, between nearDist and farDist: alpha linearly interpolated (smooth fade-out). Distance calculation: measures from camera position to entity position (world space distance), typically uses entity center or pivot point (not bounding box, simple distance check). Alpha interpolation: alpha = 1.0 - (distance - nearDist) / (farDist - nearDist), clamped to 0.0-1.0 range, applied to entity material alpha (multiplies with existing alpha, preserves transparency). Disabling: nearDist=0 AND farDist=0 disables auto fade (autoFadeEnabled=false), restores entity to full opacity (alpha not modified by distance), useful for toggling fade on/off. Use cases: (1) LOD fade-out (fade distant objects before culling for smooth transitions), (2) Fog effect (distant objects fade into background), (3) Particle systems (fade particles at distance), (4) Draw distance (soft culling instead of hard cutoff), (5) Ghosting effect (fade objects for x-ray or hologram effects). Common pattern: b3dEntityAutoFade(entity, 50, 100) fades between 50-100 units distance, b3dEntityAutoFade(tree, 200, 250) fades trees at distance for performance. Typical usage: set fade distances based on entity size/importance (large objects fade farther, small details fade closer), combine with frustum culling for complete LOD system. Performance: distance calculation per entity per frame (sqrt for distance, moderate cost), alpha interpolation is fast (simple math), fading doesn't reduce geometry processing (vertices still transformed, use actual LOD or culling for performance). Rendering: fade affects material alpha channel (blending mode must support transparency, opaque materials won't fade, use alpha blending), faded entities still rendered (alpha=0 still draws, use visibility or culling to skip rendering). Parameter validation: no validation on distance values (negative values allowed but may cause unexpected behavior, nearDist > farDist swaps fade direction - fully transparent near, fully opaque far, unusual but valid). Related: entity.autoFadeEnabled/Near/Far fields store settings, rendering system applies fade during draw, b3dHideEntity for instant visibility toggle, material alpha for base transparency.