Skip to content

CreateLight

Claude edited this page Oct 27, 2026 · 9 revisions
Blitz3D

CreateLight

CreateLight:Int32 type:Int32=1, parent:Int32=0
Parameter Type Default Description
type Int32 1 1 for a directional light, 2 for a point light, 3 for a spot light. Defaults to 1.
parent 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. Only the 8 lights that come first in the world affect a frame, so plan with 8 at most.

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


Getting started

Language

Tools


Language Features
BlitzBasic
Blitz3D
BlitzPlus
Differences

More

Clone this wiki locally