Blitz3D+ Command Reference

EntityDitherRange entity,near#,far#

Parameters

entity - model whose surface coverage fades with camera distance

near# - world distance up to which the distance contribution stays 1; at least 0
far# - world distance at which the contribution reaches 0; must be greater than near#

Passing 0 for both disables the range.

Description

Fades an entity's surface coverage as its origin moves away from the camera.

Up to near, the distance contribution is 1; at far it is 0. The contribution falls linearly between them and multiplies EntityDitherFade's manual coverage. Both zero disable this range. Invalid or non-finite ranges are errors.

Use this for a streaming or visibility band. Unlike AddEntityLOD, distance is measured to the entity origin rather than its bounding box. Each view uses its own camera; shadows use the source camera's fade amount, not distance to the light.

Enabling a nonzero range disables an earlier EntityAutoFade alpha range. Calling EntityAutoFade afterwards disables the dither range. Disabling EntityDitherRange with both zero does not enable an old alpha range. Manual EntityAlpha and EntityDitherFade remain independent. CopyEntity copies the range. This affects the entity's own supported surfaces; children require separate calls.

See EntityDitherFade for material support and the visible grain of this effect without temporal antialiasing. Existing commands remain useful: use EntityAutoFade when you want ordinary alpha transparency.

Requires Extended mode.

See also: EntityDitherFade, EntityAutoFade, EntityLODTransition, AddEntityLOD.

Example

; Extended mode: the line of props fades with distance from the moving camera.
Graphics3D 800,600,0,2:SetBuffer BackBuffer()
camera=CreateCamera():PositionEntity camera,0,1,-5:CameraRange camera,.1,60
light=CreateLight():RotateEntity light,35,-25,0
For i=0 To 12
    prop=CreateCylinder(10):PositionEntity prop,(i Mod 2)*4-2,0,i*3
    EntityColor prop,45+i*12,140,180:EntityDitherRange prop,16,24
Next
lastTime=MilliSecs()
While Not KeyHit(1)
    now=MilliSecs():elapsed#=Float(now-lastTime)/1000:lastTime=now
    MoveEntity camera,0,0,(KeyDown(200)-KeyDown(208))*elapsed*8
    RenderWorld:Color 255,255,255:Text 12,12,"Up/down: move | Esc: exit"
    Flip
Wend
End

Index