Skip to content

LightMesh

Narta Xaymar Dirks edited this page Oct 28, 2026 · 5 revisions
Blitz3D

LightMesh

LightMesh:Void mesh:Int32, red:Float32, green:Float32, blue:Float32, range:Float32=0, x:Float32=0, y:Float32=0, z:Float32=0
Parameter Mode Type Default Description
mesh In Int32 required Mesh handle.
red In Float32 required Red part of the light, 0 to 255.
green In Float32 required Green part of the light, 0 to 255.
blue In Float32 required Blue part of the light, 0 to 255.
range In Float32 0 Strength of the light, 0 for the same amount on every vertex. Defaults to 0.
x In Float32 0 X position of the light in the mesh's own space. Defaults to 0.
y In Float32 0 Y position of the light in the mesh's own space. Defaults to 0.
z In Float32 0 Z position of the light in the mesh's own space. Defaults to 0.

Description

Lights a mesh without any light in the world, by adding color to its vertices once. It is a fast way to bake the look of a light into static geometry, or to fake lights beyond the limit of 8. The mesh must have vertex colors switched on with EntityFX mesh, 2 or the change stays invisible. New meshes have white vertices, so the added light has nothing to brighten until you darken them with VertexColor.

With a range of 0 the color is added to every vertex alike. Otherwise only vertices that face the position get light, and the more directly they face it and the closer they are, the more they get. range scales the strength, so doubling it doubles the light.

The color is added to what the vertices already have and is kept: calling the command again brightens the mesh further, and it is not undone by anything but painting the vertices again.

Examples

Graphics3D 320, 240, 0, 2
SetBuffer BackBuffer()
camera = CreateCamera()
PositionEntity camera, 0, 0, -4
ball = CreateSphere(24)
; Start from dark vertices, use them without any light in the world.
surf = GetSurface(ball, 1)
For v = 0 To CountVertices(surf) - 1
	VertexColor surf, v, 20, 20, 30
Next
EntityFX ball, 1 + 2
LightMesh ball, 255, 120, 40, 4, -3, 2, -3
RenderWorld
Flip
WaitKey

Media

LightMesh

Related Commands

CreateLight, LightColor, LightConeAngles, LightRange

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally