LightRange light,range#
Parameters
|
light - light handle range# - range of light; 1000 (default) |
Description
|
Sets the range of a light - how far it reaches. Everything outside the range of the light is unaffected by it. Range matters for point and spot lights, which fade with distance: a candle might light a range of 5, a street lamp 30. The default range of 1000 usually means 'lights everything', so setting a sensible range is the first thing to do after creating a point light. Directional lights have infinite reach, so range does not apply to them. Lighting in Blitz3D is per vertex, so the value is approximate in practice - a small pool of light falling between the vertices of a large, low-polygon floor can appear to do nothing. Experiment for best results, and give big floors and walls more vertices (or use a subdivided CreatePlane) if lights seem patchy. See also: CreateLight, LightColor, LightConeAngles. |
Example
; LightRange Example ; ------------------ Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,6,-14 RotateEntity camera,20,0,0 ; Keep ambient light low so the point light's reach is obvious AmbientLight 16,16,16 ; Point lights need well-tessellated geometry to show up, so use a ; subdivided plane and a high-segment sphere ground=CreatePlane(16) statue=CreateSphere(24) PositionEntity statue,0,1,0 ; A point light circling the statue light=CreateLight(2) ; A small full-bright marker sphere rides on the light so we can see it marker=CreateSphere(8,light) ScaleEntity marker,0.2,0.2,0.2 EntityFX marker,1 EntityColor marker,255,255,0 range#=6 angle#=0 While Not KeyDown(1) ; Press [ / ] to shrink or grow the light's range If KeyDown(26) And range>1 Then range=range-0.1 If KeyDown(27) And range<40 Then range=range+0.1 ; Apply the range - geometry beyond it receives no light at all LightRange light,range ; Circle the light around the statue angle=angle+1 PositionEntity light,Cos(angle)*5,3,Sin(angle)*5 ; Arrow keys move the camera If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,0,-0.1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 RenderWorld Text 0,0,"[ / ]: change light range Arrow keys: move camera Esc: exit" Text 0,20,"LightRange light,"+range Flip Wend End
Index