Sets light attenuation range in world units (point/spot lights only, directional unaffected).
Takes light (light entity handle), range (attenuation distance in world units, typically 1.0-100.0).
Returns nothing.
3D Graphics
Parameters & Returns
Parameters
lightInt
rangeDouble
Returns
Void
Quick Summary
Sets light attenuation range in world units (point/spot lights only, directional unaffected).
Takes light (light entity handle), range (attenuation distance in world units, typically 1.0-100.0).
Returns nothing.
Technical Exegesis...
Sets light attenuation range in world units (point/spot lights only, directional unaffected). Takes light (light entity handle), range (attenuation distance in world units, typically 1.0-100.0). Returns nothing. Validates entity is ENTITY_LIGHT type, sets light->range=(float)range. Controls how far light reaches before fading to zero.
This function sets light range.
Sets light attenuation range in world units (point/spot lights only, directional unaffected). Takes light (light entity handle), range (attenuation distance in world units, typically 1.0-100.0). Returns nothing. Validates entity is ENTITY_LIGHT type, sets light->range=(float)range. Controls how far light reaches before fading to zero.
This function sets light range. Attenuation: light brightness decreases with distance from source, reaches zero at range distance, follows inverse-square law or custom falloff curve (distance^2 attenuation typical for physical accuracy). Light types: LIGHT_POINT (type=0) and LIGHT_SPOT (type=2) affected by range (local lights with limited reach), LIGHT_DIRECTIONAL (type=1) NOT affected by range (infinite range, simulates distant sun/moon). Range interpretation: surfaces within range are illuminated (brightness decreases with distance), surfaces beyond range receive no light from this source (contribution=0), range is maximum effective distance. Use cases: (1) Small lights (range=5-10 for lamps, candles, close lights), (2) Medium lights (range=20-50 for torches, room lights), (3) Large lights (range=100-500 for searchlights, large fires, explosions), (4) Performance optimization (smaller range = fewer pixels affected = faster rendering), (5) Artistic control (limit light spill for focused lighting). Common patterns: candle b3dLightRange(light, 5), torch b3dLightRange(light, 20), street lamp b3dLightRange(light, 50), explosion b3dLightRange(light, 100). Typical usage: set range during light creation based on light type (small for ambient fill, large for key lights), adjust range for performance (reduce range to improve framerate). Attenuation curve: typically quadratic (brightness = intensity / (1 + distance^2)), smooth falloff from center to range edge, no hard cutoff (gradual fade). Default range: lights default to 10.0 world units if not set. Performance: smaller range = better performance (fewer pixels/triangles affected, tighter culling), use smallest range that looks good. Directional lights: setting range on directional light has no effect (infinite range by design, simulates sun at infinite distance). Validation: prints error if invalid light handle or non-light entity. Related: b3dLightIntensity sets brightness (combines with attenuation), b3dCreateLight creates light entity (type determines if range applies), b3dLightColor sets light color.