|
light - light handle mode - how its light fades with distance: LIGHT_FALLOFF_CLASSIC (0): range divided by distance, as Blitz3D always has (default) LIGHT_FALLOFF_PHYSICAL (1): inverse square, as real light fades, reaching nothing beyond the light's range |
|
Chooses how a point or spot light's light fades with distance. Classic light stays strong for a long way and never quite reaches zero, which is why old scenes keep their look. Physical light is bright close to the light and falls away quickly, which makes rooms look real and keeps bakes quick, as each light reaches only so far; give it a higher LightIntensity. Realtime lighting and bakes use the same falloff, so baking a light never changes how bright it looks. See also: LightIntensity, LightRange, LightBakeMode, CreateLight. |
; LightBakeMode Example
; ---------------------
Graphics3D 640,480,0,2
SetBuffer BackBuffer()
camera=CreateCamera()
PositionEntity camera,0,3,-5
RotateEntity camera,30,0,0
AmbientLight 12,12,18
; A floor and three pillars to cast shadows
ground=CreateCube()
ScaleEntity ground,4,0.1,4
For pillar_number=0 To 2
pillar=CreateCube()
ScaleEntity pillar,0.2,0.8,0.2
PositionEntity pillar,pillar_number*1.2-1.2,0.8,1
Next
; A ball rolling across the front: it moves, so probes light it
ball=CreateSphere(16)
ScaleEntity ball,0.3,0.3,0.3
EntityLightmap ball,LIGHTMAP_OFF
lamp=CreateLight(2)
PositionEntity lamp,0,2.2,-0.5
LightRange lamp,6
LightColor lamp,255,230,200
; Physical falloff fades as real light does, so the lamp needs an intensity
falloff=LIGHT_FALLOFF_PHYSICAL
LightFalloff lamp,falloff
LightIntensity lamp,8
mode=LIGHT_MIXED
radius#=0.2
intensity#=8
LightBakeQuality 0
bake=BakeLighting()
While Not KeyDown(1)
; 1, 2 and 3 choose how the lamp bakes; [ / ] soften its baked shadows;
; - / = change its brightness; Space bakes with the new settings
If KeyHit(2) Then mode=LIGHT_REALTIME
If KeyHit(3) Then mode=LIGHT_MIXED
If KeyHit(4) Then mode=LIGHT_BAKED
If KeyHit(26) And radius>0 Then radius=radius-0.1
If KeyHit(27) Then radius=radius+0.1
If KeyDown(12) And intensity>0.2 Then intensity=intensity-0.1
If KeyDown(13) Then intensity=intensity+0.1
LightBakeMode lamp,mode
LightBakeRadius lamp,radius
LightIntensity lamp,intensity
; F switches between classic and physical falloff
If KeyHit(33) Then
falloff=1-falloff
LightFalloff lamp,falloff
EndIf
If KeyHit(57) And bake=0 Then bake=BakeLighting()
If bake<>0 Then
If LightBakeState(bake)<>LIGHT_BAKE_RUNNING Then
FreeLightBake bake
bake=0
EndIf
EndIf
PositionEntity ball,Sin(MilliSecs()/15.0)*2.5,0.3,-1
; 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
If mode=LIGHT_REALTIME Then mode_name$="realtime only"
If mode=LIGHT_MIXED Then mode_name$="mixed"
If mode=LIGHT_BAKED Then mode_name$="baked only"
Text 0,0,"Arrow keys: move camera Space: bake with the new settings Esc: exit"
Text 0,20,"1 / 2 / 3: mode [ / ] : soft shadow size - / = : intensity F: falloff"
Text 0,40,"LightBakeMode lamp,"+mode+" ("+mode_name+")"
Text 0,60,"LightBakeRadius lamp,"+radius+" LightIntensity lamp,"+intensity+" LightFalloff lamp,"+falloff
If bake<>0 Then Text 0,80,"Baking: "+(LightBakeProgress(bake)/10)+"%" Else Text 0,80,BakedLightingStatus()
Flip
Wend
End