ArcBasicDocs
3DShadowsArcBasic extension

LightShadows

Makes a light cast shadows.

LightShadows light[,enable]

Parameters

light
light handle
enable (optional)
True to cast shadows, False to stop. Defaults to True.

Description

Makes a light cast real-time shadows. : lights do not cast shadows unless you ask for them, so older programs look exactly as they always have.

All light types can cast shadows. A directional light (type 1, the default) behaves like the sun: its shadows reach as far as the camera can see (its CameraRange, up to 3000 units). Point lights (type 2) and spot lights (type 3) cast shadows within their LightRange.

Shadows cost rendering time, especially from point lights, so give shadows to the lights that matter most - usually just one sun.

Which entities cast and receive shadows can be changed with EntityShadows, and the shadow detail with ShadowQuality.

Example

LightShadows.absOpen in editor
; Shadows example (an ArcBasic extension); S toggles shadows, Q changes the shadow quality, Escape quitsGraphics3D 640,480SetBuffer BackBuffer()camera=CreateCamera()PositionEntity camera,0,6,-12TurnEntity camera,25,0,0AmbientLight 70,70,80; the sun: a directional light, pointing down at an anglesun=CreateLight(1)RotateEntity sun,50,30,0LightShadows sunground=CreatePlane()EntityColor ground,120,160,120cube=CreateCube()PositionEntity cube,-2,1,0EntityColor cube,200,80,80ball=CreateSphere(16)PositionEntity ball,2,1.5,1EntityColor ball,80,120,220; this cube neither casts nor receives shadowsghost=CreateCube()PositionEntity ghost,0,1,3EntityColor ghost,240,240,120EntityShadows ghost,False,Falseshadows=Truequality=2While Not KeyDown(1)	If KeyHit(31) ; S		shadows=Not shadows		LightShadows sun,shadows	EndIf	If KeyHit(16) ; Q		quality=(quality+1) Mod 4		ShadowQuality quality	EndIf	TurnEntity cube,0,1,0	RenderWorld	Text 0,0,"Shadows: "+shadows+"  Quality: "+quality+"  (S / Q)"	FlipWendEnd

See also