Skip to content

CreateLight

Narta Xaymar Dirks edited this page Oct 29, 2026 · 6 revisions
Blitz3D

CreateLight

CreateLight:Int32 type:Int32=1, parent:Int32=0
Parameter Mode Type Default Description
type In Int32 1 1 for a directional light, 2 for a point light, 3 for a spot light. Defaults to 1.
parent In Int32 0 Entity the light follows, or 0 for none. Defaults to 0.

Returns: The handle of the new light.

Description

Creates a light and returns its handle. Without a light everything in the world is lit only by AmbientLight, which looks flat. A light is an entity: position and rotation work like on any other entity.

  • 1, directional (the default) is like the sun. Only its rotation matters, it shines along its own forward direction (+Z) and has no position or range.
  • 2, point is like a light bulb. It shines in all directions from its position and fades out until its range.
  • 3, spot is a cone of light that shines along its forward direction (+Z). See LightConeAngles.

A new light is white, sits at the origin and has a range of 1000. Any other value for type creates a directional light. An entity is lit by 8 lights at most, see Many-Lights, so plan with 8 at most. With EntityLightChannel an entity can be lit by some of the lights only.

Examples

Graphics3D 320, 240, 0, 2
SetBuffer BackBuffer()
camera = CreateCamera()
PositionEntity camera, 0, 0, -5
AmbientLight 20, 20, 20
; A point light to the left of the ball.
light = CreateLight(2)
PositionEntity light, -3, 2, -2
LightRange light, 12
ball = CreateSphere(24)
EntityColor ball, 230, 230, 230
RenderWorld
Flip
WaitKey

Media

CreateLight

Related Commands

LightColor, LightConeAngles, LightMesh, LightRange

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally