Home
Products
Community
Manuals
Contact
Login or Signup

Blitz3D Docs -> 3D - A-Z -> L -> LightRange

LightRange light,range#

Parameters:

light - light handle
range# - range of light (default: 1000.0)

Description:

Sets the range of a light.

The range of a light is how far it reaches. Everything outside the range of the light will not be affected by it.

The value is very approximate, and should be experimented with for best results.

See also: CreateLight, LightColor, LightConeAngles.

Example:

Graphics3D 640,480

camera = CreateCamera()
MoveEntity camera,0,0,-3

ball = CreateSphere()

lite = CreateLight(2) ; try different lights 1 to 3
MoveEntity lite,5,0,-5
PointEntity lite,ball

range# = 0.5
LightRange lite,range

While Not KeyDown(1)
RenderWorld:Flip
If KeyHit(57) Then ; hit SPACEBAR to increase light range
range = range + 0.5
LightRange lite,range
EndIf
Wend
End

Comments

DJWoodgate(Posted 1+ years ago)
This is an old forum post by SSwift. Thought it was worthwhile copying it here because the above info is a bit misleading.


This is the equation Blitz uses for lighting. It might come in handy if you want to mimic it's lights with your own vertex lighting.

This is the DX lighting equation:
a = 1 / (c0 + c1*d + c2*d*d)

In Blitz c0 and c2 are 0, and c1 is 1.

This gives a falloff like this:
mathworld.wolfram.com/GabrielsHorn.html

Where at a radius of 1, a = 1, beyond that radius it falls off quickly, expoentially I beleive it's called, and inside that radius it increases until it reaches infinity where d = 0.

Since c0 and c2 = 0 the lighting equation can be simplified to:

a = 1 / d

And then we add the light radius like so:

a = r / d

And then once you calculate that for a particular light, you just multiply the light RGB by a.

(All of those should be floats btw.)


So:

Light_Falloff# = Light_Min_Radius# / Vertex_Distance#
Vertex_R# = Light_R# * Light_Falloff#


Also note that the help file is mistaken on the light radius when it says that is approximately where the light falls off to 0. In actuality, the light falls off to 1 at 255*Light_Radius.

It falls off to 0 at infinity, but because colors are clamped to integers, the point where it goes below 1 is where it gets clamped to 0.

So for a light radius of 20, the light falls off to 0 at a distance of 5100! Ouch. :-)

It falls off to less than that much closer though.



BTW. DX does allow you to specify an absolute range for point and spot lights where the light no longer effects anything, but Blitz does not currently support that feature.


Blitz3D Manual Forum

BlitzPlus Equivalent Command